├── .gitignore ├── 99-plasma-pstate ├── LICENSE.md ├── README.md ├── gr.ictpro.jsalatas.plasma.pstate ├── contents │ ├── code │ │ ├── set_prefs.sh │ │ └── utils.js │ ├── config │ │ ├── config.qml │ │ └── main.xml │ ├── font │ │ └── plasma-pstate.ttf │ └── ui │ │ ├── ComboBox.qml │ │ ├── CompactRepresentation.qml │ │ ├── FullRepresentation.qml │ │ ├── Group.qml │ │ ├── Header.qml │ │ ├── PushButton.qml │ │ ├── Radio.qml │ │ ├── Slider.qml │ │ ├── Switch.qml │ │ ├── config │ │ ├── ConfigGeneral.qml │ │ └── IconPicker.qml │ │ └── main.qml └── metadata.desktop ├── install.sh ├── screenshots ├── screenshot_1.png ├── screenshot_2.png ├── screenshot_3.png └── screenshot_4.png └── uninstall.sh /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.qmlc 3 | 4 | *.jsc 5 | -------------------------------------------------------------------------------- /99-plasma-pstate: -------------------------------------------------------------------------------- 1 | %sudo ALL=NOPASSWD: /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 2, June 1991 4 | 5 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 6 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Lesser General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | 125 | Thus, it is not the intent of this section to claim rights or contest 126 | your rights to work written entirely by you; rather, the intent is to 127 | exercise the right to control the distribution of derivative or 128 | collective works based on the Program. 129 | 130 | In addition, mere aggregation of another work not based on the Program 131 | with the Program (or with a work based on the Program) on a volume of 132 | a storage or distribution medium does not bring the other work under 133 | the scope of this License. 134 | 135 | 3. You may copy and distribute the Program (or a work based on it, 136 | under Section 2) in object code or executable form under the terms of 137 | Sections 1 and 2 above provided that you also do one of the following: 138 | 139 | a) Accompany it with the complete corresponding machine-readable 140 | source code, which must be distributed under the terms of Sections 141 | 1 and 2 above on a medium customarily used for software interchange; or, 142 | 143 | b) Accompany it with a written offer, valid for at least three 144 | years, to give any third party, for a charge no more than your 145 | cost of physically performing source distribution, a complete 146 | machine-readable copy of the corresponding source code, to be 147 | distributed under the terms of Sections 1 and 2 above on a medium 148 | customarily used for software interchange; or, 149 | 150 | c) Accompany it with the information you received as to the offer 151 | to distribute corresponding source code. (This alternative is 152 | allowed only for noncommercial distribution and only if you 153 | received the program in object code or executable form with such 154 | an offer, in accord with Subsection b above.) 155 | 156 | The source code for a work means the preferred form of the work for 157 | making modifications to it. For an executable work, complete source 158 | code means all the source code for all modules it contains, plus any 159 | associated interface definition files, plus the scripts used to 160 | control compilation and installation of the executable. However, as a 161 | special exception, the source code distributed need not include 162 | anything that is normally distributed (in either source or binary 163 | form) with the major components (compiler, kernel, and so on) of the 164 | operating system on which the executable runs, unless that component 165 | itself accompanies the executable. 166 | 167 | If distribution of executable or object code is made by offering 168 | access to copy from a designated place, then offering equivalent 169 | access to copy the source code from the same place counts as 170 | distribution of the source code, even though third parties are not 171 | compelled to copy the source along with the object code. 172 | 173 | 4. You may not copy, modify, sublicense, or distribute the Program 174 | except as expressly provided under this License. Any attempt 175 | otherwise to copy, modify, sublicense or distribute the Program is 176 | void, and will automatically terminate your rights under this License. 177 | However, parties who have received copies, or rights, from you under 178 | this License will not have their licenses terminated so long as such 179 | parties remain in full compliance. 180 | 181 | 5. You are not required to accept this License, since you have not 182 | signed it. However, nothing else grants you permission to modify or 183 | distribute the Program or its derivative works. These actions are 184 | prohibited by law if you do not accept this License. Therefore, by 185 | modifying or distributing the Program (or any work based on the 186 | Program), you indicate your acceptance of this License to do so, and 187 | all its terms and conditions for copying, distributing or modifying 188 | the Program or works based on it. 189 | 190 | 6. Each time you redistribute the Program (or any work based on the 191 | Program), the recipient automatically receives a license from the 192 | original licensor to copy, distribute or modify the Program subject to 193 | these terms and conditions. You may not impose any further 194 | restrictions on the recipients' exercise of the rights granted herein. 195 | You are not responsible for enforcing compliance by third parties to 196 | this License. 197 | 198 | 7. If, as a consequence of a court judgment or allegation of patent 199 | infringement or for any other reason (not limited to patent issues), 200 | conditions are imposed on you (whether by court order, agreement or 201 | otherwise) that contradict the conditions of this License, they do not 202 | excuse you from the conditions of this License. If you cannot 203 | distribute so as to satisfy simultaneously your obligations under this 204 | License and any other pertinent obligations, then as a consequence you 205 | may not distribute the Program at all. For example, if a patent 206 | license would not permit royalty-free redistribution of the Program by 207 | all those who receive copies directly or indirectly through you, then 208 | the only way you could satisfy both it and this License would be to 209 | refrain entirely from distribution of the Program. 210 | 211 | If any portion of this section is held invalid or unenforceable under 212 | any particular circumstance, the balance of the section is intended to 213 | apply and the section as a whole is intended to apply in other 214 | circumstances. 215 | 216 | It is not the purpose of this section to induce you to infringe any 217 | patents or other property right claims or to contest validity of any 218 | such claims; this section has the sole purpose of protecting the 219 | integrity of the free software distribution system, which is 220 | implemented by public license practices. Many people have made 221 | generous contributions to the wide range of software distributed 222 | through that system in reliance on consistent application of that 223 | system; it is up to the author/donor to decide if he or she is willing 224 | to distribute software through any other system and a licensee cannot 225 | impose that choice. 226 | 227 | This section is intended to make thoroughly clear what is believed to 228 | be a consequence of the rest of this License. 229 | 230 | 8. If the distribution and/or use of the Program is restricted in 231 | certain countries either by patents or by copyrighted interfaces, the 232 | original copyright holder who places the Program under this License 233 | may add an explicit geographical distribution limitation excluding 234 | those countries, so that distribution is permitted only in or among 235 | countries not thus excluded. In such case, this License incorporates 236 | the limitation as if written in the body of this License. 237 | 238 | 9. The Free Software Foundation may publish revised and/or new versions 239 | of the General Public License from time to time. Such new versions will 240 | be similar in spirit to the present version, but may differ in detail to 241 | address new problems or concerns. 242 | 243 | Each version is given a distinguishing version number. If the Program 244 | specifies a version number of this License which applies to it and "any 245 | later version", you have the option of following the terms and conditions 246 | either of that version or of any later version published by the Free 247 | Software Foundation. If the Program does not specify a version number of 248 | this License, you may choose any version ever published by the Free Software 249 | Foundation. 250 | 251 | 10. If you wish to incorporate parts of the Program into other free 252 | programs whose distribution conditions are different, write to the author 253 | to ask for permission. For software which is copyrighted by the Free 254 | Software Foundation, write to the Free Software Foundation; we sometimes 255 | make exceptions for this. Our decision will be guided by the two goals 256 | of preserving the free status of all derivatives of our free software and 257 | of promoting the sharing and reuse of software generally. 258 | 259 | NO WARRANTY 260 | 261 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 262 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 263 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 264 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 265 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 266 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 267 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 268 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 269 | REPAIR OR CORRECTION. 270 | 271 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 272 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 273 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 274 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 275 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 276 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 277 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 278 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 279 | POSSIBILITY OF SUCH DAMAGES. 280 | 281 | END OF TERMS AND CONDITIONS 282 | 283 | How to Apply These Terms to Your New Programs 284 | 285 | If you develop a new program, and you want it to be of the greatest 286 | possible use to the public, the best way to achieve this is to make it 287 | free software which everyone can redistribute and change under these terms. 288 | 289 | To do so, attach the following notices to the program. It is safest 290 | to attach them to the start of each source file to most effectively 291 | convey the exclusion of warranty; and each file should have at least 292 | the "copyright" line and a pointer to where the full notice is found. 293 | 294 | 295 | Copyright (C) 296 | 297 | This program is free software; you can redistribute it and/or modify 298 | it under the terms of the GNU General Public License as published by 299 | the Free Software Foundation; either version 2 of the License, or 300 | (at your option) any later version. 301 | 302 | This program is distributed in the hope that it will be useful, 303 | but WITHOUT ANY WARRANTY; without even the implied warranty of 304 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 305 | GNU General Public License for more details. 306 | 307 | You should have received a copy of the GNU General Public License along 308 | with this program; if not, write to the Free Software Foundation, Inc., 309 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | {signature of Ty Coon}, 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Lesser General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intel P-state and CPUFreq Manager Widget 2 | 3 | Please don't use it any more. There is a maintained fork by frankenfruity at https://github.com/frankenfruity/plasma-pstate. 4 | 5 | If you are using Arch, AUR already points to the above repo. 6 | 7 | Thank you @frankenfruity for taking over! :) 8 | 9 | 10 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INTEL_PSTATE=/sys/devices/system/cpu/intel_pstate 4 | CPU_MIN_PERF=$INTEL_PSTATE/min_perf_pct 5 | CPU_MAX_PERF=$INTEL_PSTATE/max_perf_pct 6 | CPU_TURBO=$INTEL_PSTATE/no_turbo 7 | 8 | GPU=/sys/class/drm/card0 9 | GPU_MIN_FREQ=$GPU/gt_min_freq_mhz 10 | GPU_MAX_FREQ=$GPU/gt_max_freq_mhz 11 | GPU_MIN_LIMIT=$GPU/gt_RP1_freq_mhz 12 | GPU_MAX_LIMIT=$GPU/gt_RP0_freq_mhz 13 | GPU_BOOST_FREQ=$GPU/gt_boost_freq_mhz 14 | GPU_CUR_FREQ=$GPU/gt_cur_freq_mhz 15 | 16 | LG_LAPTOP_DRIVER=/sys/devices/platform/lg-laptop 17 | LG_FAN_MODE=$LG_LAPTOP_DRIVER/fan_mode 18 | LG_BATTERY_CHARGE_LIMIT=$LG_LAPTOP_DRIVER/battery_care_limit 19 | LG_USB_CHARGE=$LG_LAPTOP_DRIVER/usb_charge 20 | 21 | check_lg_drivers() { 22 | if [ -d $LG_LAPTOP_DRIVER ]; then 23 | return 0 24 | else 25 | return 1 26 | fi 27 | } 28 | 29 | check_dell_thermal () { 30 | smbios-thermal-ctl -g > /dev/null 2>&1 31 | OUT=$? 32 | if [ $OUT -eq 0 ]; then 33 | return 0 34 | else 35 | return 1 36 | fi 37 | } 38 | 39 | check_nvidia () { 40 | nvidia-settings -q GpuPowerMizerMode > /dev/null 2>&1 41 | OUT=$? 42 | if [ $OUT -eq 0 ]; then 43 | return 0 44 | else 45 | return 1 46 | fi 47 | } 48 | 49 | set_cpu_min_perf () { 50 | minperf=$1 51 | if [ -n "$minperf" ] && [ "$minperf" != "0" ]; then 52 | printf '%s\n' "$minperf" > $CPU_MIN_PERF; 2> /dev/null 53 | fi 54 | } 55 | 56 | set_cpu_max_perf () { 57 | maxperf=$1 58 | if [ -n "$maxperf" ] && [ "$maxperf" != "0" ]; then 59 | printf '%s\n' "$maxperf" > $CPU_MAX_PERF; 2> /dev/null 60 | fi 61 | } 62 | 63 | set_cpu_turbo () { 64 | turbo=$1 65 | if [ -n "$turbo" ]; then 66 | if [ "$turbo" == "true" ]; then 67 | printf '0\n' > $CPU_TURBO; 2> /dev/null 68 | else 69 | printf '1\n' > $CPU_TURBO; 2> /dev/null 70 | fi 71 | fi 72 | } 73 | 74 | set_gpu_min_freq () { 75 | gpuminfreq=$1 76 | if [ -n "$gpuminfreq" ] && [ "$gpuminfreq" != "0" ]; then 77 | printf '%s\n' "$gpuminfreq" > $GPU_MIN_FREQ; 2> /dev/null 78 | fi 79 | } 80 | 81 | set_gpu_max_freq () { 82 | gpumaxfreq=$1 83 | if [ -n "$gpumaxfreq" ] && [ "$gpumaxfreq" != "0" ]; then 84 | printf '%s\n' "$gpumaxfreq" > $GPU_MAX_FREQ; 2> /dev/null 85 | fi 86 | } 87 | 88 | set_gpu_boost_freq () { 89 | gpuboostfreq=$1 90 | if [ -n "$gpuboostfreq" ] && [ "$gpuboostfreq" != "0" ]; then 91 | printf '%s\n' "$gpuboostfreq" > $GPU_BOOST_FREQ; 2> /dev/null 92 | fi 93 | } 94 | 95 | set_cpu_governor () { 96 | gov=$1 97 | if [ -n "$gov" ]; then 98 | for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do 99 | printf '%s\n' "$gov" > $cpu; 2> /dev/null 100 | done 101 | fi 102 | } 103 | 104 | set_energy_perf () { 105 | energyperf=$1 106 | if [ -n "$energyperf" ]; then 107 | if [ -f /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference ]; then 108 | for cpu in /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference; do 109 | printf '%s\n' "$energyperf" > $cpu; 2> /dev/null 110 | done 111 | else 112 | pnum=$(echo $energyperf | sed -r 's/^performance$/0/; 113 | s/^balance_performance$/4/; 114 | s/^(default|normal)$/6/; 115 | s/^balance_power?$/8/; 116 | s/^power(save)?$/15/') 117 | 118 | x86_energy_perf_policy $pnum > /dev/null 2>&1 119 | fi 120 | fi 121 | } 122 | 123 | set_thermal_mode () { 124 | smbios-thermal-ctl --set-thermal-mode=$1 2> /dev/null 125 | } 126 | 127 | set_lg_battery_charge_limit(){ 128 | enabled=$1 129 | if [ -n "$enabled" ]; then 130 | if [ "$enabled" == "true" ]; then 131 | printf '80\n' > $LG_BATTERY_CHARGE_LIMIT; 2> /dev/null 132 | else 133 | printf '100\n' > $LG_BATTERY_CHARGE_LIMIT; 2> /dev/null 134 | fi 135 | fi 136 | } 137 | 138 | set_lg_fan_mode() { 139 | enabled=$1 140 | if [ -n "$enabled" ]; then 141 | if [ "$enabled" == "true" ]; then 142 | printf '0\n' > $LG_FAN_MODE; 2> /dev/null 143 | else 144 | printf '1\n' > $LG_FAN_MODE; 2> /dev/null 145 | fi 146 | fi 147 | } 148 | 149 | set_powermizer () { 150 | nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=$1" 2> /dev/null 151 | } 152 | 153 | set_lg_usb_charge() { 154 | enabled=$1 155 | if [ -n "$enabled" ]; then 156 | if [ "$enabled" == "true" ]; then 157 | printf '1\n' > $LG_USB_CHARGE; 2> /dev/null 158 | else 159 | printf '0\n' > $LG_USB_CHARGE; 2> /dev/null 160 | fi 161 | fi 162 | } 163 | 164 | read_all () { 165 | cpu_min_perf=`cat $CPU_MIN_PERF` 166 | cpu_max_perf=`cat $CPU_MAX_PERF` 167 | cpu_turbo=`cat $CPU_TURBO` 168 | if [ "$cpu_turbo" == "1" ]; then 169 | cpu_turbo="false" 170 | else 171 | cpu_turbo="true" 172 | fi 173 | gpu_min_freq=`cat $GPU_MIN_FREQ` 174 | gpu_max_freq=`cat $GPU_MAX_FREQ` 175 | gpu_min_limit=`cat $GPU_MIN_LIMIT` 176 | gpu_max_limit=`cat $GPU_MAX_LIMIT` 177 | gpu_boost_freq=`cat $GPU_BOOST_FREQ` 178 | gpu_cur_freq=`cat $GPU_CUR_FREQ` 179 | cpu_governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` 180 | energy_perf=`cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference` 181 | if [ -z "$energy_perf" ]; then 182 | energy_perf=`x86_energy_perf_policy -r 2>/dev/null | grep -v 'HWP_' | \ 183 | sed -r 's/://; 184 | s/(0x0000000000000000|EPB 0)/performance/; 185 | s/(0x0000000000000004|EPB 4)/balance_performance/; 186 | s/(0x0000000000000006|EPB 6)/default/; 187 | s/(0x0000000000000008|EPB 8)/balance_power/; 188 | s/(0x000000000000000f|EPB 15)/power/' | \ 189 | awk '{ printf "%s\n", $2; }' | head -n 1` 190 | fi 191 | if check_dell_thermal; then 192 | thermal_mode=`smbios-thermal-ctl -g | grep -C 1 "Current Thermal Modes:" | tail -n 1 | awk '{$1=$1;print}' | sed "s/\t//g" | sed "s/ /-/g" | tr "[A-Z]" "[a-z]" ` 193 | fi 194 | 195 | if check_lg_drivers; then 196 | lg_battery_charge_limit=`cat $LG_BATTERY_CHARGE_LIMIT` 197 | if [ "$lg_battery_charge_limit" == "80" ]; then 198 | lg_battery_charge_limit="true" 199 | else 200 | lg_battery_charge_limit="false" 201 | fi 202 | lg_usb_charge=`cat $LG_USB_CHARGE` 203 | if [ "$lg_usb_charge" == "1" ]; then 204 | lg_usb_charge="true" 205 | else 206 | lg_usb_charge="false" 207 | fi 208 | lg_fan_mode=`cat $LG_FAN_MODE` 209 | if [ "$lg_fan_mode" == "1" ]; then 210 | lg_fan_mode="false" 211 | else 212 | lg_fan_mode="true" 213 | fi 214 | fi 215 | 216 | if check_nvidia; then 217 | powermizer=`nvidia-settings -q GpuPowerMizerMode | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' ` 218 | fi 219 | 220 | json="{" 221 | json="${json}\"cpu_min_perf\":\"${cpu_min_perf}\"" 222 | json="${json},\"cpu_max_perf\":\"${cpu_max_perf}\"" 223 | json="${json},\"cpu_turbo\":\"${cpu_turbo}\"" 224 | json="${json},\"gpu_min_freq\":\"${gpu_min_freq}\"" 225 | json="${json},\"gpu_max_freq\":\"${gpu_max_freq}\"" 226 | json="${json},\"gpu_min_limit\":\"${gpu_min_limit}\"" 227 | json="${json},\"gpu_max_limit\":\"${gpu_max_limit}\"" 228 | json="${json},\"gpu_boost_freq\":\"${gpu_boost_freq}\"" 229 | json="${json},\"gpu_cur_freq\":\"${gpu_cur_freq}\"" 230 | json="${json},\"cpu_governor\":\"${cpu_governor}\"" 231 | json="${json},\"energy_perf\":\"${energy_perf}\"" 232 | if check_dell_thermal; then 233 | json="${json},\"thermal_mode\":\"${thermal_mode}\"" 234 | fi 235 | if check_lg_drivers; then 236 | json="${json},\"lg_battery_charge_limit\":\"${lg_battery_charge_limit}\"" 237 | json="${json},\"lg_usb_charge\":\"${lg_usb_charge}\"" 238 | json="${json},\"lg_fan_mode\":\"${lg_fan_mode}\"" 239 | fi 240 | if check_nvidia; then 241 | json="${json},\"powermizer\":\"${powermizer}\"" 242 | fi 243 | json="${json}}" 244 | echo $json 245 | } 246 | 247 | case $1 in 248 | "-cpu-min-perf") 249 | set_cpu_min_perf $2 250 | ;; 251 | 252 | "-cpu-max-perf") 253 | set_cpu_max_perf $2 254 | ;; 255 | 256 | "-cpu-turbo") 257 | set_cpu_turbo $2 258 | ;; 259 | 260 | "-gpu-min-freq") 261 | set_gpu_min_freq $2 262 | ;; 263 | 264 | "-gpu-max-freq") 265 | set_gpu_max_freq $2 266 | ;; 267 | 268 | "-gpu-boost-freq") 269 | set_gpu_boost_freq $2 270 | ;; 271 | 272 | "-cpu-governor") 273 | set_cpu_governor $2 274 | ;; 275 | 276 | "-energy-perf") 277 | set_energy_perf $2 278 | ;; 279 | 280 | "-thermal-mode") 281 | set_thermal_mode $2 282 | ;; 283 | 284 | "-lg-battery-charge-limit") 285 | set_lg_battery_charge_limit $2 286 | ;; 287 | 288 | "-lg-fan-mode") 289 | set_lg_fan_mode $2 290 | ;; 291 | 292 | "-lg-usb-charge") 293 | set_lg_usb_charge $2 294 | ;; 295 | 296 | "-powermizer") 297 | set_powermizer $2 298 | ;; 299 | 300 | "-read-all") 301 | read_all 302 | ;; 303 | 304 | *) 305 | echo "Usage:" 306 | echo "1: set_prefs.sh [ -cpu-min-perf |" 307 | echo " -cpu-max-perf |" 308 | echo " -cpu-turbo |" 309 | echo " -gpu-min-freq |" 310 | echo " -gpu-max-freq |" 311 | echo " -gpu-boost-freq |" 312 | echo " -cpu-governor |" 313 | echo " -energy-perf |" 314 | echo " -thermal-mode |" 315 | echo " -lg-battery-charge-limit |" 316 | echo " -lg-fan-mode |" 317 | echo " -lg-usb-charge |" 318 | echo " -powermizer ] value" 319 | echo "2: set_prefs.sh -read-all" 320 | exit 3 321 | ;; 322 | esac 323 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | function to_int(item) { 21 | var val = Math.round(parseFloat(item['value']), 0); 22 | return 0 == val || val ? val + item['unit'] : ''; 23 | } 24 | 25 | function array_to_int(items) { 26 | var res = ''; 27 | var keys = Object.keys(items['value']) 28 | for (var i=0; i< keys.length; i++) { 29 | var item = items['value'][keys[i]] 30 | var val = Math.round(parseFloat(item), 0); 31 | if(0 == val || val) { 32 | if(res) { 33 | res += ' | ' 34 | } 35 | res += val + items['unit']; 36 | } 37 | }; 38 | return res; 39 | } 40 | 41 | function to_time(item) { 42 | var val = Math.round(parseFloat(item['value']), 0); 43 | var hours = Math.floor(val / 3600); 44 | var minutes = Math.floor((val - (hours * 3600)) / 60); 45 | 46 | if (minutes < 10) {minutes = "0"+minutes;} 47 | return hours ? hours+':'+minutes : ''; 48 | } 49 | 50 | function to_bool(item) { 51 | return parseInt(item['value'], 10) == 1; 52 | } 53 | 54 | function to_string(item) { 55 | return item['value']; 56 | } 57 | 58 | var sensors = { 59 | // Informational 60 | 'cpu_cur_load': {'value': undefined, 'unit':'%', 'print': to_int}, 61 | 'cpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 62 | 'gpu_cur_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 63 | 'gpu_min_limit': {'value': undefined, 'unit':'', 'print': to_int}, 64 | 'gpu_max_limit': {'value': undefined, 'unit':'', 'print': to_int}, 65 | 'battery_percentage': {'value': undefined, 'unit': '%', 'print': to_int}, 66 | 'battery_remaining_time': {'value': undefined, 'print': to_time}, 67 | 'package_temp': {'value': undefined, 'unit': ' \u2103', 'print': to_int}, 68 | 'fan_speeds': {'value': {}, 'unit': ' RPM', 'print': array_to_int}, 69 | // Tunable 70 | 'cpu_min_perf': {'value': undefined, 'unit':'%', 'print': to_int}, 71 | 'cpu_max_perf': {'value': undefined, 'unit':'%', 'print': to_int}, 72 | 'cpu_turbo': {'value': undefined, 'unit':'', 'print': to_bool}, 73 | 'gpu_min_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 74 | 'gpu_max_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 75 | 'gpu_boost_freq': {'value': undefined, 'unit':' MHz', 'print': to_int}, 76 | 'cpu_governor': {'value': undefined, 'unit':'', 'print': to_string}, 77 | 'energy_perf': {'value': undefined, 'unit':'', 'print': to_string}, 78 | 'thermal_mode': {'value': undefined, 'unit':'', 'print': to_string}, 79 | 'lg_battery_charge_limit': {'value': undefined, 'unit':'', 'print': to_bool}, 80 | 'lg_usb_charge': {'value': undefined, 'unit':'', 'print': to_bool}, 81 | 'lg_fan_mode': {'value': undefined, 'unit':'', 'print': to_bool}, 82 | 'powermizer': {'value': undefined, 'unit':'', 'print': to_string}, 83 | 84 | } 85 | 86 | var vendors = { 87 | 'dell': {'provides': ['thermal_mode']}, 88 | 'lg-laptop': {'provides': ['lg_battery_charge_limit', 'lg_usb_charge', 'lg_fan_mode']}, 89 | 'nvidia': {'provides': ['powermizer']} 90 | } 91 | 92 | var model = [ 93 | {'type': 'header', 'text': 'Processor Settings', 'icon': 'd', 94 | 'sensors': ['cpu_cur_load', 'cpu_cur_freq', 'gpu_cur_freq'], 95 | 'items': [ 96 | {'type': 'group', 'text': 'CPU Frequencies', 'items' :[ 97 | {'type': 'slider', 'text': 'Min perf', 'min': 0, 'max': 100, 'sensor': 'cpu_min_perf'}, 98 | {'type': 'slider', 'text': 'Max perf', 'min': 0, 'max': 100, 'sensor': 'cpu_max_perf'}, 99 | {'type': 'switch', 'text': 'Turbo', 'sensor': 'cpu_turbo'} 100 | ]}, 101 | {'type': 'group', 'text': 'GPU Frequencies', 'visible': 'showIntelGPU', 'items' :[ 102 | {'type': 'slider', 'text': 'Min freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_min_freq'}, 103 | {'type': 'slider', 'text': 'Max freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_max_freq'}, 104 | {'type': 'slider', 'text': 'Boost freq', 'min': 'gpu_min_limit', 'max': 'gpu_max_limit', 'sensor': 'gpu_boost_freq'}, 105 | ]}, 106 | {'type': 'radio', 'text': 'CPU Governor', 'sensor': 'cpu_governor', 'items' :[ 107 | {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, 108 | {'symbol': 'f', 'text': 'Powersave', 'sensor_value': 'powersave'} 109 | ]} 110 | ] 111 | }, 112 | {'type': 'header', 'text': 'Energy Performance', 'icon': 'h', 113 | 'sensors': ['battery_percentage', 'battery_remaining_time'], 114 | 'items': [ 115 | {'type': 'radio', 'text': '', 'sensor': 'energy_perf', 'items' :[ 116 | {'symbol': 'i', 'text': 'Default', 'sensor_value': 'default'}, 117 | {'symbol': 'a', 'text': 'Performance', 'sensor_value': 'performance'}, 118 | {'symbol': 'k', 'text': 'Balance Performance', 'sensor_value': 'balance_performance'}, 119 | {'symbol': 'l', 'text': 'Balance Power', 'sensor_value': 'balance_power'}, 120 | {'symbol': 'f', 'text': 'Power', 'sensor_value': 'power'} 121 | ]} 122 | ] 123 | }, 124 | {'type': 'header', 'text': 'Thermal Management', 'icon': 'b', 125 | 'vendors': ['dell'], 126 | 'sensors': ['package_temp', 'fan_speeds'], 127 | 'items': [ 128 | {'type': 'radio', 'text': '', 'sensor': 'thermal_mode', 'items' :[ 129 | {'symbol': 'e', 'text': 'Performance', 'sensor_value': 'performance'}, 130 | {'symbol': 'j', 'text': 'Balanced', 'sensor_value': 'balanced'}, 131 | {'symbol': 'g', 'text': 'Cool Bottom', 'sensor_value': 'cool-bottom'}, 132 | {'symbol': 'c', 'text': 'Quiet', 'sensor_value': 'quiet'} 133 | ]} 134 | ] 135 | }, 136 | {'type': 'header', 'text': 'Power Supply Management', 'icon': 'm', 137 | 'vendors': ['lg-laptop'], 138 | 'items': [ 139 | {'type': 'switch', 'text': 'Battery Limit', 'sensor': 'lg_battery_charge_limit'}, 140 | {'type': 'switch', 'text': 'USB Charge', 'sensor': 'lg_usb_charge'} 141 | ] 142 | }, 143 | {'type': 'header', 'text': 'Fan Control', 'icon': 'n', 144 | 'vendors': ['lg-laptop'], 145 | 'items': [ 146 | {'type': 'switch', 'text': 'Silent Mode', 'sensor': 'lg_fan_mode'} 147 | ] 148 | }, 149 | {'type': 'header', 'text': 'Nvidia Settings', 'icon': 'o', 150 | 'vendors': ['nvidia'], 151 | 'items': [ 152 | {'type': 'combobox', 'text': 'PowerMizer', 'sensor': 'powermizer', 'items' :[ 153 | {'text': 'Adaptive', 'sensor_value': '0'}, 154 | {'text': 'Prefer Max Performance', 'sensor_value': '1'}, 155 | {'text': 'Auto', 'sensor_value': '2'} 156 | ]} 157 | ] 158 | } 159 | ] 160 | 161 | function get_model() { 162 | return model; 163 | } 164 | 165 | function get_sensors() { 166 | return sensors; 167 | } 168 | 169 | function get_vendors() { 170 | return vendors; 171 | } 172 | 173 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/config/config.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import org.kde.plasma.configuration 2.0 3 | 4 | ConfigModel { 5 | ConfigCategory { 6 | name: i18n('General') 7 | icon: 'preferences-system-windows' 8 | source: 'config/ConfigGeneral.qml' 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/config/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | true 11 | 12 | 13 | "" 14 | 15 | 16 | true 17 | 18 | 19 | true 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/font/plasma-pstate.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsalatas/plasma-pstate/06cf91521a431e3c202fa4057045d0b2a3bab226/gr.ictpro.jsalatas.plasma.pstate/contents/font/plasma-pstate.ttf -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/ComboBox.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | import org.kde.plasma.components 3.0 as PlasmaComponents3 24 | 25 | RowLayout { 26 | Layout.fillWidth: true 27 | 28 | property var sensor: [] 29 | 30 | property bool acceptingChanges: false 31 | property alias text: combobox_title.text 32 | property var props 33 | spacing: 10 34 | 35 | onPropsChanged: { 36 | acceptingChanges = false 37 | 38 | combobox.model = props['items'] 39 | text = props['text'] 40 | sensor.push(props['sensor']) 41 | 42 | acceptingChanges = true 43 | } 44 | 45 | Component.onCompleted: { 46 | acceptingChanges = true 47 | sensorsValuesChanged() 48 | } 49 | 50 | Connections { 51 | target: main 52 | onSensorsValuesChanged: { 53 | acceptingChanges = false 54 | if(sensor.length != 0) { 55 | var value = sensors_model[sensor[0]]['value']; 56 | for(var i = 0; i < combobox.model.length; i++) { 57 | if(combobox.model[i].sensor_value == value) { 58 | combobox.currentIndex = i 59 | } 60 | } 61 | } 62 | acceptingChanges = true 63 | } 64 | } 65 | 66 | PlasmaComponents.Label { 67 | Layout.alignment: Qt.AlignVCenter 68 | id: combobox_title 69 | font.pointSize: theme.smallestFont.pointSize 70 | color: theme.textColor 71 | horizontalAlignment: Text.AlignRight 72 | Layout.minimumWidth: units.gridUnit * 4 73 | } 74 | 75 | PlasmaComponents3.ComboBox { 76 | id: combobox 77 | textRole: "text" 78 | onActivated: { 79 | if(acceptingChanges) { 80 | updateSensor(sensor[0], combobox.model[currentIndex].sensor_value) 81 | } 82 | 83 | } 84 | Layout.minimumWidth: parent.width 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/CompactRepresentation.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.2 21 | import org.kde.plasma.core 2.0 as PlasmaCore 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | Item { 25 | PlasmaCore.IconItem { 26 | id: customIcon 27 | anchors.fill: parent 28 | visible: !plasmoid.configuration.useDefaultIcon 29 | source: plasmoid.configuration.customIcon 30 | } 31 | 32 | 33 | PlasmaComponents.Label { 34 | anchors.fill: parent 35 | visible: plasmoid.configuration.useDefaultIcon 36 | 37 | verticalAlignment: Text.AlignVCenter 38 | horizontalAlignment: Text.AlignHCenter 39 | 40 | font.pixelSize: Math.min(parent.height, parent.width) * (inTray ? 1: 0.7) 41 | font.pointSize: -1 42 | font.family: symbolsFont.name 43 | 44 | text: 'd' 45 | } 46 | 47 | MouseArea { 48 | id: mousearea 49 | anchors.fill: parent 50 | onClicked: { 51 | plasmoid.expanded = !plasmoid.expanded 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/FullRepresentation.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | import '../code/utils.js' as Utils 25 | 26 | Column { 27 | id: fullRoot 28 | spacing: 0.1 29 | Layout.minimumWidth: units.gridUnit * 15 30 | Layout.minimumHeight: units.gridUnit * 20 31 | 32 | property var model: Utils.get_model() 33 | property var vendors: Utils.get_vendors() 34 | 35 | Component { 36 | id: header 37 | Header { 38 | } 39 | } 40 | 41 | Component.onCompleted: { 42 | if(isReady) { 43 | initialize() 44 | sensorsValuesChanged() 45 | } 46 | } 47 | 48 | Connections { 49 | target: main 50 | onDataSourceReady: { 51 | initialize() 52 | sensorsValuesChanged() 53 | } 54 | } 55 | 56 | Connections { 57 | target: plasmoid.configuration 58 | onShowIntelGPUChanged: { 59 | if(isReady) { 60 | initialize() 61 | } 62 | } 63 | } 64 | 65 | Connections { 66 | target: plasmoid.configuration 67 | onUseSudoForReadingChanged: { 68 | if(isReady) { 69 | initialize() 70 | } 71 | } 72 | } 73 | 74 | function is_present(item_vendors) { 75 | if(item_vendors && item_vendors.length != 0) { 76 | for(var j=0; j< item_vendors.length; j++) { 77 | var vendor = vendors[item_vendors[j]] 78 | for(var k=0; k>>>>>>>>>>>> childrenRect: " + childrenRect.width + " - " + childrenRect.height) 114 | print(">>>>>>>>>>>>> w-h: " + w + " - " + h) 115 | Layout.minimumWidth = w 116 | Layout.minimumHeight = h 117 | Layout.maximumWidth = w 118 | Layout.maximumHeight = h 119 | } 120 | 121 | function removeChildren() { 122 | for(var i = fullRoot.children.length; i > 0 ; i--) { 123 | fullRoot.children[i-1].destroy() 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/Group.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | ColumnLayout { 25 | id: group 26 | 27 | property alias text: group_title.text 28 | property var items: [] 29 | property var props 30 | 31 | objectName: "Group" 32 | 33 | onPropsChanged: { 34 | text = props['text'] 35 | items = props['items'] 36 | visible = props['visible'] == undefined || eval('plasmoid.configuration.' + props['visible']) 37 | } 38 | 39 | Component { 40 | id: slider 41 | Slider { 42 | Layout.topMargin: 5 43 | Layout.bottomMargin: 5 44 | Layout.minimumWidth: units.gridUnit * 18 45 | } 46 | } 47 | 48 | Component { 49 | id: switchbutton 50 | Switch { 51 | Layout.topMargin: 5 52 | Layout.bottomMargin: 5 53 | } 54 | } 55 | 56 | onItemsChanged: { 57 | for(var i = 0; i < items.length; i++) { 58 | switch (items[i]['type']) { 59 | case 'slider': { 60 | slider.createObject(group, {'props': items[i]}) 61 | break 62 | } 63 | case 'switch': { 64 | switchbutton.createObject(group, {'props': items[i]}) 65 | break 66 | } 67 | default: console.log("header: unkonwn type: " + items[i]['type']) 68 | } 69 | } 70 | } 71 | 72 | PlasmaComponents.Label { 73 | id: group_title 74 | font.pointSize: theme.smallestFont.pointSize * 1.25 75 | color: theme.textColor 76 | visible: text != '' 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/Header.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.6 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | Row { 25 | id: header 26 | 27 | topPadding: 5 28 | bottomPadding: 10 29 | 30 | property alias symbol: icon.text 31 | property alias text: title.text 32 | property var sensors: [] 33 | property var items: [] 34 | 35 | property var props 36 | 37 | Component { 38 | id: group 39 | Group { 40 | Layout.topMargin: 5 41 | Layout.bottomMargin: 10 42 | } 43 | } 44 | 45 | Component { 46 | id: radio 47 | Radio { 48 | Layout.topMargin: 5 49 | Layout.bottomMargin: 10 50 | } 51 | } 52 | 53 | Component { 54 | id: switchbutton 55 | Switch { 56 | Layout.topMargin: 5 57 | Layout.bottomMargin: 5 58 | } 59 | } 60 | 61 | Component { 62 | id: combobox 63 | ComboBox { 64 | Layout.topMargin: 5 65 | Layout.bottomMargin: 5 66 | } 67 | } 68 | 69 | Connections { 70 | target: main 71 | onSensorsValuesChanged: { 72 | sensors_label.text = get_sensors_text(sensors); 73 | } 74 | } 75 | 76 | onItemsChanged: { 77 | // parent: controls 78 | for(var i = 0; i < items.length; i++) { 79 | switch (items[i]['type']) { 80 | case 'radio': { 81 | radio.createObject(controls, {'props': items[i]}) 82 | break 83 | } 84 | case 'group': { 85 | group.createObject(controls, {'props': items[i]}) 86 | break 87 | } 88 | case 'switch': { 89 | switchbutton.createObject(controls, {'props': items[i]}) 90 | break 91 | } 92 | case 'combobox': { 93 | combobox.createObject(controls, {'props': items[i]}) 94 | break 95 | } 96 | default: console.log("header: unkonwn type: " + items[i]['type']) 97 | } 98 | } 99 | } 100 | 101 | onPropsChanged: { 102 | symbol = props['icon'] 103 | text = props['text'] 104 | sensors = props['sensors'] 105 | items = props['items'] 106 | } 107 | 108 | GridLayout { 109 | id: grid 110 | 111 | columns: 2 112 | columnSpacing: 10 113 | rowSpacing: 0 114 | 115 | PlasmaComponents.Label { 116 | id: icon 117 | 118 | width: units.gridUnit * 2.2 119 | Layout.minimumWidth : width 120 | 121 | horizontalAlignment: Text.AlignHCenter 122 | 123 | font.pointSize: theme.smallestFont.pointSize * 2.5 124 | font.family: symbolsFont.name 125 | color: theme.textColor 126 | } 127 | 128 | PlasmaComponents.Label { 129 | id: title 130 | 131 | font.pointSize: theme.smallestFont.pointSize * 2 132 | color: theme.textColor 133 | } 134 | 135 | PlasmaComponents.Label { 136 | id: spacer0 137 | visible: sensors_label.text != 'N/A' 138 | } 139 | 140 | PlasmaComponents.Label { 141 | id: sensors_label 142 | 143 | Layout.bottomMargin: 5 144 | 145 | font.pointSize: theme.smallestFont.pointSize * 1.25 146 | color: theme.textColor 147 | opacity: 0.8 148 | 149 | visible: sensors_label.text != 'N/A' 150 | } 151 | 152 | PlasmaComponents.Label { 153 | id: spacer1 154 | } 155 | 156 | ColumnLayout { 157 | id: controls 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/PushButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import org.kde.plasma.components 2.0 as PlasmaComponents 22 | 23 | Item { 24 | width: units.gridUnit * 4.2 25 | height: units.gridUnit * 4 26 | 27 | objectName: "PushButton" 28 | 29 | property string symbol 30 | property alias text: label.text 31 | property string sensor_value 32 | property bool active: false 33 | property bool updating: false 34 | property var sensor: [] 35 | property bool acceptingChanges: false 36 | 37 | property color borderColor: updating ? '#ff0000' : (active ? Qt.rgba(theme.highlightColor.r, theme.highlightColor.g, theme.highlightColor.b, 0.6) : 38 | Qt.rgba(theme.textColor.r, theme.textColor.g, theme.textColor.b, 0.4)) 39 | property color buttonColor: active ? theme.highlightColor : theme.textColor 40 | 41 | Component.onCompleted: { 42 | sensorsValuesChanged() 43 | } 44 | 45 | Connections { 46 | target: main 47 | onSensorsValuesChanged: { 48 | acceptingChanges = false 49 | updating = false 50 | active = sensors_model[sensor[0]]['value'] == sensor_value 51 | acceptingChanges = true 52 | } 53 | } 54 | 55 | Rectangle { 56 | anchors.fill: parent 57 | border.width: 2 58 | border.color: borderColor 59 | color: "transparent" 60 | radius: 3 61 | id: button 62 | 63 | MouseArea { 64 | anchors.fill: parent 65 | onClicked: { 66 | if(acceptingChanges) { 67 | updating = true 68 | updateSensor(sensor[0], sensor_value) 69 | } 70 | } 71 | } 72 | 73 | PlasmaComponents.Label { 74 | id: icon 75 | anchors { 76 | margins: units.smallSpacing *1.5 77 | right: parent.right 78 | left: parent.left 79 | top: parent.top 80 | } 81 | 82 | verticalAlignment: Text.AlignTop 83 | horizontalAlignment: Text.AlignHCenter 84 | 85 | font.pointSize: theme.smallestFont.pointSize * 2.8 86 | font.family: symbolsFont.name 87 | color: buttonColor 88 | 89 | text: symbol 90 | } 91 | 92 | PlasmaComponents.Label { 93 | id: label 94 | anchors { 95 | margins: units.smallSpacing * 1.5 96 | right: parent.right 97 | left: parent.left 98 | bottom: parent.bottom 99 | } 100 | 101 | verticalAlignment: Text.AlignBottom 102 | horizontalAlignment: Text.AlignHCenter 103 | 104 | wrapMode: Text.WordWrap 105 | font.pointSize: theme.smallestFont.pointSize * 0.9 106 | lineHeight: 0.75 107 | 108 | color: buttonColor 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/Radio.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | ColumnLayout { 25 | id: radio 26 | 27 | property alias text: radio_title.text 28 | property var sensor: [] 29 | property var items: [] 30 | 31 | property var props 32 | 33 | objectName: "Radio" 34 | 35 | Component { 36 | id: pushButton 37 | PushButton {} 38 | } 39 | 40 | onPropsChanged: { 41 | text = props['text'] 42 | sensor.push(props['sensor']) 43 | items = props['items'] 44 | } 45 | 46 | onItemsChanged: { 47 | for(var i = 0; i < items.length; i++) { 48 | var props = items[i] 49 | props['sensor'] = sensor 50 | pushButton.createObject(buttons, props); 51 | } 52 | } 53 | 54 | PlasmaComponents.Label { 55 | id: radio_title 56 | font.pointSize: theme.smallestFont.pointSize * 1.25 57 | color: theme.textColor 58 | visible: text != '' 59 | } 60 | RowLayout { 61 | id: buttons 62 | spacing: -0.5 63 | Layout.topMargin: radio_title.visible ? 0 : 8 64 | Layout.rightMargin: 15 65 | 66 | height: units.gridUnit * 4 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/Slider.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | RowLayout { 25 | property alias min: slider.minimumValue 26 | property alias max: slider.maximumValue 27 | property alias value: slider.value 28 | property bool acceptingChanges: false 29 | property alias pressed: slider.pressed 30 | property bool updating: false 31 | 32 | 33 | property var sensor: [] 34 | property var min_sensor: [] 35 | property var max_sensor: [] 36 | 37 | 38 | property alias text: slider_title.text 39 | property var props 40 | spacing: 10 41 | 42 | onPropsChanged: { 43 | acceptingChanges = false 44 | text = props['text'] 45 | sensor.push(props['sensor']) 46 | if(isNaN(props['min'])) { 47 | min = 0 48 | min_sensor.push(props['min']) 49 | } else { 50 | min = props['min'] 51 | min_sensor = [] 52 | } 53 | if(isNaN(props['max'])) { 54 | max = 100 55 | max_sensor.push(props['max']) 56 | } else { 57 | max = props['max'] 58 | max_sensor = [] 59 | } 60 | acceptingChanges = true 61 | } 62 | 63 | Component.onCompleted: { 64 | acceptingChanges = true 65 | sensorsValuesChanged() 66 | } 67 | 68 | Connections { 69 | target: main 70 | onSensorsValuesChanged: { 71 | if(!pressed) { 72 | acceptingChanges = false 73 | if(sensor.length != 0) { 74 | value = parseInt(sensors_model[sensor[0]]['value'], 10); 75 | slider_value.text = get_sensors_text(sensor); 76 | updating = false 77 | } 78 | if(min_sensor.length != 0) { 79 | min = parseInt(sensors_model[min_sensor[0]]['value'], 10); 80 | } 81 | if(max_sensor.length != 0) { 82 | max = parseInt(sensors_model[max_sensor[0]]['value'], 10); 83 | } 84 | acceptingChanges = true 85 | } 86 | } 87 | } 88 | 89 | PlasmaComponents.Label { 90 | Layout.alignment: Qt.AlignTop 91 | id: slider_title 92 | font.pointSize: theme.smallestFont.pointSize 93 | color: theme.textColor 94 | horizontalAlignment: Text.AlignRight 95 | Layout.minimumWidth: units.gridUnit * 4 96 | } 97 | 98 | PlasmaComponents.Slider { 99 | Layout.fillWidth: true 100 | Layout.alignment: Qt.AlignBottom 101 | id: slider 102 | stepSize: 1 103 | onPressedChanged: { 104 | //need to resend here 105 | if(acceptingChanges) { 106 | updateSensor(sensor[0], value) 107 | } 108 | } 109 | onValueChanged: { 110 | if(pressed) { 111 | updating = true 112 | slider_value.text = get_value_text(sensor[0], value) 113 | } else { 114 | if(acceptingChanges) { 115 | updateSensor(sensor[0], value) 116 | } 117 | } 118 | } 119 | } 120 | 121 | PlasmaComponents.Label { 122 | Layout.alignment: Qt.AlignTop 123 | id: slider_value 124 | font.pointSize: theme.smallestFont.pointSize 125 | color: pressed || updating? '#ff0000' : theme.textColor 126 | horizontalAlignment: Text.AlignRight 127 | Layout.minimumWidth: units.gridUnit * 3 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/Switch.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import org.kde.plasma.components 2.0 as PlasmaComponents 23 | 24 | RowLayout { 25 | property alias text: checkbox_title.text 26 | property alias checked: checkBox.checked 27 | property var sensor: [] 28 | property bool acceptingChanges: false 29 | 30 | property var props 31 | spacing: 10 32 | 33 | onPropsChanged: { 34 | acceptingChanges = false 35 | 36 | text = props['text'] 37 | sensor.push(props['sensor']) 38 | acceptingChanges = true 39 | } 40 | 41 | Component.onCompleted: { 42 | acceptingChanges = true 43 | sensorsValuesChanged() 44 | } 45 | 46 | Connections { 47 | target: main 48 | onSensorsValuesChanged: { 49 | acceptingChanges = false 50 | 51 | if(sensor.length != 0) { 52 | checked = sensors_model[sensor[0]]['value'] == 'true'; 53 | } 54 | 55 | acceptingChanges = true 56 | } 57 | } 58 | 59 | PlasmaComponents.Label { 60 | Layout.alignment: Qt.AlignVCenter 61 | id: checkbox_title 62 | font.pointSize: theme.smallestFont.pointSize 63 | color: theme.textColor 64 | horizontalAlignment: Text.AlignRight 65 | Layout.minimumWidth: units.gridUnit * 4 66 | } 67 | 68 | PlasmaComponents.CheckBox { 69 | id: checkBox 70 | onCheckedChanged: { 71 | if(acceptingChanges) { 72 | updateSensor(sensor[0], checked) 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/ConfigGeneral.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Layouts 1.1 4 | 5 | Item { 6 | property alias cfg_useDefaultIcon: useDefaultIconCheckbox.checked 7 | property alias cfg_showIntelGPU: showIntelGPUCheckbox.checked 8 | property string cfg_customIcon: plasmoid.configuration.customIcon 9 | property alias cfg_useSudoForReading: useSudoForReadingCheckbox.checked 10 | 11 | GridLayout { 12 | Layout.fillWidth: true 13 | columns: 2 14 | 15 | CheckBox { 16 | id: useDefaultIconCheckbox 17 | text: i18n('Use Default Icon') 18 | Layout.columnSpan: 2 19 | } 20 | 21 | Label { 22 | text: i18n("Custom Icon:") 23 | Layout.alignment: Qt.AlignRight 24 | } 25 | 26 | IconPicker { 27 | currentIcon: cfg_customIcon 28 | onIconChanged: cfg_customIcon = iconName 29 | onIconCleared: { 30 | useDefaultIconCheckbox.checked = true 31 | } 32 | enabled: !useDefaultIconCheckbox.checked 33 | } 34 | 35 | CheckBox { 36 | id: showIntelGPUCheckbox 37 | text: i18n('Show Intel GPU') 38 | Layout.columnSpan: 2 39 | } 40 | 41 | CheckBox { 42 | id: useSudoForReadingCheckbox 43 | text: i18n('Use sudo for reading values') 44 | Layout.columnSpan: 2 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/config/IconPicker.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.2 2 | import QtQuick.Controls 1.3 3 | import QtQuick.Layouts 1.1 4 | import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons 5 | import org.kde.plasma.core 2.0 as PlasmaCore 6 | import org.kde.plasma.components 2.0 as PlasmaComponents 7 | 8 | // basically taken from kickoff 9 | Button { 10 | id: iconButton 11 | 12 | property string currentIcon 13 | property string defaultIcon 14 | 15 | signal iconChanged(string iconName) 16 | signal iconCleared 17 | 18 | Layout.minimumWidth: previewFrame.width + units.smallSpacing * 2 19 | Layout.maximumWidth: Layout.minimumWidth 20 | Layout.minimumHeight: previewFrame.height + units.smallSpacing * 2 21 | Layout.maximumHeight: Layout.minimumWidth 22 | 23 | KQuickAddons.IconDialog { 24 | id: iconDialog 25 | onIconNameChanged: { 26 | iconPreview.source = iconName 27 | iconChanged(iconName) 28 | } 29 | } 30 | 31 | // just to provide some visual feedback, cannot have checked without checkable enabled 32 | checkable: true 33 | onClicked: { 34 | checked = Qt.binding(function() { // never actually allow it being checked 35 | return iconMenu.status === PlasmaComponents.DialogStatus.Open 36 | }) 37 | 38 | iconMenu.open(0, height) 39 | } 40 | 41 | PlasmaCore.FrameSvgItem { 42 | id: previewFrame 43 | anchors.centerIn: parent 44 | imagePath: plasmoid.location === PlasmaCore.Types.Vertical || plasmoid.location === PlasmaCore.Types.Horizontal 45 | ? "widgets/panel-background" : "widgets/background" 46 | width: units.iconSizes.large + fixedMargins.left + fixedMargins.right 47 | height: units.iconSizes.large + fixedMargins.top + fixedMargins.bottom 48 | 49 | PlasmaCore.IconItem { 50 | id: iconPreview 51 | anchors.centerIn: parent 52 | width: units.iconSizes.large 53 | height: width 54 | source: currentIcon 55 | } 56 | } 57 | 58 | function setDefaultIcon() { 59 | iconPreview.source = defaultIcon 60 | iconChanged(defaultIcon) 61 | iconCleared 62 | } 63 | 64 | // QQC Menu can only be opened at cursor position, not a random one 65 | PlasmaComponents.ContextMenu { 66 | id: iconMenu 67 | visualParent: iconButton 68 | 69 | PlasmaComponents.MenuItem { 70 | text: i18nc("@item:inmenu Open icon chooser dialog", "Choose...") 71 | icon: "document-open-folder" 72 | onClicked: iconDialog.open() 73 | } 74 | PlasmaComponents.MenuItem { 75 | text: i18nc("@item:inmenu Reset icon to default", "Clear Icon") 76 | icon: "edit-clear" 77 | onClicked: setDefaultIcon() 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/contents/ui/main.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 John Salatas 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Library General Public License as 6 | * published by the Free Software Foundation; either version 2 or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details 13 | * 14 | * You should have received a copy of the GNU Library General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | import QtQuick 2.3 21 | import QtQuick.Layouts 1.1 22 | import QtQuick.Controls 1.0 as QtControls 23 | 24 | import org.kde.plasma.plasmoid 2.0 25 | import org.kde.plasma.core 2.0 as PlasmaCore 26 | import org.kde.plasma.extras 2.0 as PlasmaExtras 27 | 28 | import '../code/utils.js' as Utils 29 | 30 | Item { 31 | id: main 32 | 33 | signal sensorsValuesChanged 34 | signal dataSourceReady 35 | signal updateSensor(string name, string value) 36 | 37 | FontLoader { 38 | id: symbolsFont; 39 | source: '../font/plasma-pstate.ttf' 40 | } 41 | 42 | property var monitor_sources: [/cpu\/system\/AverageClock/g, /cpu\/system\/TotalLoad/g, /lmsensors\/.*Package_id_0/g, /lmsensors\/.*fan/g] 43 | property var sensors_model: Utils.get_sensors() 44 | property alias isReady: monitorDS.isReady 45 | property bool inTray: (plasmoid.parent === null || plasmoid.parent.objectName === 'taskItemContainer') 46 | property var readCommand: (plasmoid.configuration.useSudoForReading ? 'sudo ' : '') + '/usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -read-all' 47 | 48 | function sensor_short_name(long_name) { 49 | var parts = long_name.split('/'); 50 | return parts[parts.length - 1]; 51 | } 52 | 53 | Plasmoid.compactRepresentation: CompactRepresentation { } 54 | Plasmoid.fullRepresentation: FullRepresentation { } 55 | 56 | Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation 57 | Plasmoid.switchWidth: units.gridUnit * 15 58 | Plasmoid.switchHeight: units.gridUnit * 20 59 | 60 | 61 | Plasmoid.toolTipMainText: '' //i18n('Intel pstate and Thermal Management') 62 | Plasmoid.toolTipSubText: '' 63 | Plasmoid.toolTipTextFormat: Text.RichText 64 | Plasmoid.icon: '' 65 | 66 | Component.onCompleted: { 67 | if (!inTray) { 68 | // not in tray 69 | } 70 | } 71 | 72 | onUpdateSensor: { 73 | print("updating sensor " + name +": " + value) 74 | if(value != sensors_model[name]['value']) { 75 | updater.update(name, value) 76 | } else { 77 | print(" same value") 78 | } 79 | } 80 | 81 | function get_value_text(sensor, value) { 82 | // lol! Is this the bwsat way to do it? 83 | var obj = {'value': value, 'unit': sensors_model[sensor]['unit']} 84 | return sensors_model[sensor]['print'](obj) 85 | } 86 | 87 | function get_sensors_text(sensors) { 88 | var res = ''; 89 | if(sensors != undefined) { 90 | for(var i = 0 ; i < sensors.length; i++) { 91 | var value = sensors_model[sensors[i]]['print'](sensors_model[sensors[i]]); 92 | if(value) { 93 | if(res) { 94 | res += ' | '; 95 | } 96 | res += value; 97 | } 98 | } 99 | } 100 | 101 | return res || 'N/A'; 102 | } 103 | 104 | function monitor_source(src) { 105 | for(var i=0; i < monitor_sources.length; i++) { 106 | if(src.match(monitor_sources[i])) { 107 | return true; 108 | } 109 | } 110 | 111 | return false; 112 | } 113 | 114 | onSensorsValuesChanged: { 115 | updateTooltip(); 116 | } 117 | 118 | PlasmaCore.DataSource { 119 | id: systemmonitorDS 120 | engine: 'systemmonitor' 121 | property var seenSources: [] 122 | 123 | onSourceAdded: { 124 | if(monitor_source(source)) { 125 | if(systemmonitorDS.connectedSources.indexOf(source) == -1) { 126 | systemmonitorDS.connectedSources.push(source); 127 | } 128 | } 129 | } 130 | 131 | onNewData: { 132 | var show = false 133 | if(systemmonitorDS.seenSources.indexOf(sourceName) == -1 && data.value != undefined) { 134 | systemmonitorDS.seenSources.push(sourceName) 135 | } 136 | 137 | var source_short_name = sensor_short_name(sourceName); 138 | 139 | if(source_short_name.startsWith('fan')) { 140 | if (sensors_model['fan_speeds'] != undefined && sensors_model['fan_speeds']['value'] != undefined) { 141 | sensors_model['fan_speeds']['value'][source_short_name] = data.value; 142 | } 143 | } else { 144 | switch (source_short_name) { 145 | case 'AverageClock': { 146 | sensors_model['cpu_cur_freq']['value'] = data.value 147 | break; 148 | } 149 | case 'Package_id_0': { 150 | sensors_model['package_temp']['value'] = data.value 151 | break; 152 | } 153 | case 'TotalLoad': { 154 | sensors_model['cpu_cur_load']['value'] = data.value 155 | break; 156 | } 157 | } 158 | } 159 | 160 | sensorsValuesChanged() 161 | } 162 | 163 | Component.onCompleted: { 164 | systemmonitorDS.connectedSources = []; 165 | systemmonitorDS.connectedSources.length = 0; 166 | 167 | for(var i=0; i< systemmonitorDS.sources.length; i++) { 168 | if(monitor_source(systemmonitorDS.sources[i])) { 169 | if(systemmonitorDS.connectedSources.indexOf(systemmonitorDS.sources[i]) == -1) { 170 | systemmonitorDS.connectedSources.push(systemmonitorDS.sources[i]); 171 | } 172 | } 173 | } 174 | } 175 | interval: 2000 176 | } 177 | 178 | PlasmaCore.DataSource { 179 | id: powermanagementDS 180 | engine: "powermanagement" 181 | connectedSources: ['Battery'] 182 | onDataChanged: { 183 | if(powermanagementDS.data["Battery"]) { 184 | sensors_model['battery_remaining_time']['value'] = Number(powermanagementDS.data["Battery"]["Remaining msec"]) / 1000; 185 | sensors_model['battery_percentage']['value'] = powermanagementDS.data["Battery"]["Percent"]; 186 | sensorsValuesChanged() 187 | } 188 | } 189 | interval: 2000 190 | } 191 | 192 | Connections { 193 | target: plasmoid.configuration 194 | onUseSudoForReadingChanged: { 195 | monitorDS.commandSource = readCommand 196 | monitorDS.connectedSources = []; 197 | monitorDS.connectedSources.length = 0; 198 | monitorDS.connectedSources.push(monitorDS.commandSource); 199 | } 200 | } 201 | 202 | PlasmaCore.DataSource { 203 | id: monitorDS 204 | engine: 'executable' 205 | 206 | property bool isReady: false 207 | property string commandSource: readCommand 208 | 209 | onNewData: { 210 | if (data['exit code'] > 0) { 211 | print('monitorDS error: ' + data.stderr) 212 | } else { 213 | var obj = JSON.parse(data.stdout); 214 | var keys = Object.keys(obj); 215 | for(var i=0; i< keys.length; i++) { 216 | sensors_model[keys[i]]['value'] = obj[keys[i]]; 217 | } 218 | if(!isReady) { 219 | dataSourceReady(); 220 | isReady = true; 221 | } 222 | sensorsValuesChanged(); 223 | } 224 | } 225 | Component.onCompleted: { 226 | monitorDS.connectedSources = []; 227 | monitorDS.connectedSources.length = 0; 228 | monitorDS.connectedSources.push(monitorDS.commandSource); 229 | 230 | } 231 | interval: 2000 232 | } 233 | 234 | PlasmaCore.DataSource { 235 | id: updater 236 | engine: 'executable' 237 | 238 | property string commandSource: 'sudo /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh -' 239 | 240 | onNewData: { 241 | updater.connectedSources = [] 242 | updater.connectedSources.length = 0 243 | if (data['exit code'] > 0) { 244 | print(" error: " + data.stderr) 245 | } else { 246 | print(" done") 247 | } 248 | } 249 | Component.onCompleted: { 250 | updater.connectedSources = []; 251 | updater.connectedSources.length = 0; 252 | } 253 | function update(parameter, value) { 254 | var command = updater.commandSource + parameter.replace(/_/g, '-') + ' ' + value 255 | print("exec: " + command) 256 | updater.connectedSources.push(command); 257 | 258 | } 259 | } 260 | 261 | function updateTooltip() { 262 | var toolTipSubText =''; 263 | var txt = ''; 264 | 265 | toolTipSubText += '' 266 | 267 | toolTipSubText += '' 268 | toolTipSubText += '' 271 | toolTipSubText += '' 274 | toolTipSubText += '' 275 | 276 | txt = get_sensors_text(['battery_percentage', 'battery_remaining_time']); 277 | if(txt != 'N/A') { 278 | toolTipSubText += '' 279 | toolTipSubText += '' 282 | toolTipSubText += '' 285 | toolTipSubText += '' 286 | } 287 | 288 | txt = get_sensors_text(['package_temp', 'fan_speeds']); 289 | if (txt != 'N/A') { 290 | toolTipSubText += '' 291 | toolTipSubText += '' 294 | toolTipSubText += '' 297 | toolTipSubText += '' 298 | } 299 | toolTipSubText += '
' 269 | toolTipSubText += 'd' 270 | toolTipSubText += '' 272 | toolTipSubText += '  '+get_sensors_text(['cpu_cur_load', 'cpu_cur_freq', 'gpu_cur_freq'])+'' 273 | toolTipSubText += '
' 280 | toolTipSubText += 'h' 281 | toolTipSubText += '' 283 | toolTipSubText += '  '+ txt +'' 284 | toolTipSubText += '
' 292 | toolTipSubText += 'b' 293 | toolTipSubText += '' 295 | toolTipSubText += '  '+ txt +'' 296 | toolTipSubText += '
' 300 | 301 | Plasmoid.toolTipSubText = toolTipSubText 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /gr.ictpro.jsalatas.plasma.pstate/metadata.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Comment=Intel P-state and CPUFreq Manager 3 | Name=Intel P-state and CPUFreq Manager 4 | Icon=cpu 5 | Type=Service 6 | X-KDE-ParentApp= 7 | X-KDE-PluginInfo-Author=John Salatas 8 | X-KDE-PluginInfo-Category=System Information 9 | X-KDE-PluginInfo-Email=jsalatas@ictpro.gr 10 | X-KDE-PluginInfo-License=GPL2+ 11 | X-KDE-PluginInfo-Name=gr.ictpro.jsalatas.plasma.pstate 12 | X-KDE-PluginInfo-Version=1.0.6 13 | X-KDE-PluginInfo-Website=https://jsalatas.ictpro.gr 14 | X-KDE-ServiceTypes=Plasma/Applet 15 | X-Plasma-API=declarativeappletscript 16 | X-Plasma-MainScript=ui/main.qml 17 | X-Plasma-StandAloneApp=true 18 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $EUID -ne 0 ]]; then 4 | echo "This script must be run as root." 2>&1 5 | exit 1 6 | fi 7 | 8 | SUDOERS_FILE="99-plasma-pstate" 9 | 10 | cp -R ${SUDOERS_FILE} /etc/sudoers.d/ 11 | kpackagetool5 -g -t Plasma/Applet -i gr.ictpro.jsalatas.plasma.pstate 12 | 13 | chmod 755 /usr/share/plasma/plasmoids/gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh 14 | 15 | chown root:root /etc/sudoers.d/${SUDOERS_FILE} 16 | chmod 400 /etc/sudoers.d/${SUDOERS_FILE} 17 | 18 | # Test for wheel group instead of sudo 19 | # this is the case of arch based distros 20 | wheelgroup=`grep wheel /etc/group | wc -l` 21 | sudogroup=`grep sudo /etc/group | wc -l` 22 | if [ "$wheelgroup" -eq "1" ] && [ "$sudogroup" -eq "0" ]; then 23 | # seems to be safe enough: there is a wheel group and not a sudo group 24 | sed -i 's/sudo/wheel/' /etc/sudoers.d/${SUDOERS_FILE} 25 | fi 26 | 27 | echo -e "\nSetup complete." 28 | exit 0 29 | -------------------------------------------------------------------------------- /screenshots/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsalatas/plasma-pstate/06cf91521a431e3c202fa4057045d0b2a3bab226/screenshots/screenshot_1.png -------------------------------------------------------------------------------- /screenshots/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsalatas/plasma-pstate/06cf91521a431e3c202fa4057045d0b2a3bab226/screenshots/screenshot_2.png -------------------------------------------------------------------------------- /screenshots/screenshot_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsalatas/plasma-pstate/06cf91521a431e3c202fa4057045d0b2a3bab226/screenshots/screenshot_3.png -------------------------------------------------------------------------------- /screenshots/screenshot_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsalatas/plasma-pstate/06cf91521a431e3c202fa4057045d0b2a3bab226/screenshots/screenshot_4.png -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $EUID -ne 0 ]]; then 4 | echo "This script must be run as root." 2>&1 5 | exit 1 6 | fi 7 | 8 | SUDOERS_FILE="/etc/sudoers.d/99-plasma-pstate" 9 | 10 | rm -f ${SUDOERS_FILE} 11 | kpackagetool5 -g -t Plasma/Applet -r gr.ictpro.jsalatas.plasma.pstate 12 | 13 | echo "Uninstall complete." 14 | exit 0 15 | --------------------------------------------------------------------------------