Compare commits
252 Commits
V.1.10.2
...
release-2.
Author | SHA1 | Date | |
---|---|---|---|
fe2f147d45 | |||
6c42b3dc7e | |||
000708b6a2 | |||
4300e1d18a | |||
c244166016 | |||
e3cb503b2e | |||
fba0a91eb9 | |||
a098c9d2c4 | |||
4a6ec00b20 | |||
7ae90bf82d | |||
bcf26156d1 | |||
4cee2535ee | |||
e1ebd87871 | |||
4cef889fd4 | |||
d785839d1d | |||
cf6ccc293b | |||
e9ee6150c1 | |||
30577e91ec | |||
e5006ed2d6 | |||
3bd73d0458 | |||
4dbf5150fc | |||
061244b1d0 | |||
8055647f34 | |||
d74c7cb030 | |||
f5006af977 | |||
16d7d2bc20 | |||
6e27717dc8 | |||
d1f1d79752 | |||
862d14dc0e | |||
685c0390b4 | |||
35a5aa6a6c | |||
681fec4cac | |||
bb88892125 | |||
f01fd96cf6 | |||
eac1319889 | |||
86d4bd76ea | |||
27fd4e8f1e | |||
9611677254 | |||
a61cff7caa | |||
4966a0a5bf | |||
b1abf74e89 | |||
16170c72b0 | |||
c5a0ba3796 | |||
cce37d66e5 | |||
c850aaf2a3 | |||
43efbbba72 | |||
3a0cbee39f | |||
213595b3c1 | |||
f5fbb80d91 | |||
0288e6e1eb | |||
6667b45919 | |||
9ff07241b1 | |||
cc7b7b5659 | |||
3e709f549d | |||
adcf6c942f | |||
7415a6830f | |||
c23846f7b4 | |||
e957a2723b | |||
5369bbda65 | |||
6a8842163e | |||
56e7ee3d11 | |||
ce72c46cd9 | |||
78ab09c1da | |||
498a965488 | |||
d1d4a97fa4 | |||
8f1e8606d4 | |||
b682c6dbd6 | |||
c8bf047e76 | |||
a336d9aa04 | |||
2272b0c2c0 | |||
0533ee8cd5 | |||
be792a4c5a | |||
997e13706b | |||
6bcb6798a2 | |||
4e3593a2a9 | |||
4b471593c7 | |||
695a85be29 | |||
bae34ba898 | |||
93db63b16c | |||
0cd2ff6813 | |||
222db43dc1 | |||
e4be3b2e02 | |||
543e39a7ac | |||
ca60a85241 | |||
2c3c575493 | |||
5f37a9d8c7 | |||
c3420a8393 | |||
5ce3a5c213 | |||
179a97b01b | |||
f0c79a4dab | |||
f56f319075 | |||
f7b7d5b6b4 | |||
3193de1a85 | |||
8cdfdd4e81 | |||
16d7ca2005 | |||
e54ab7e1a5 | |||
a335979830 | |||
8460d07875 | |||
5ec26c7747 | |||
8aafdb6fc4 | |||
9eedaf246f | |||
e7714042bb | |||
0f4bbbfba1 | |||
7069758b73 | |||
bbc9d72606 | |||
b53b1111f9 | |||
64fdc4bebe | |||
583046e195 | |||
71b3a4e6ab | |||
4b90fac0c4 | |||
2fa0acf13d | |||
0f9d2e52ab | |||
373bab14db | |||
7e095c4349 | |||
a4af7ffc07 | |||
0ab4878b22 | |||
1748829901 | |||
6a41fa2b8a | |||
2cd04e1f7f | |||
0a61d926f8 | |||
45c248b101 | |||
6a784d2e28 | |||
13023a4985 | |||
6463ed3bf7 | |||
5bf3847bc9 | |||
4fc2e238bd | |||
c18bb61521 | |||
9e82210463 | |||
171d545562 | |||
c6fa1f2a79 | |||
14cee9dbc7 | |||
5759273e4c | |||
4387bb1e76 | |||
03af5f0e49 | |||
7f6afbcb4d | |||
4a320bc5d6 | |||
29d34525a3 | |||
0ab74b493c | |||
952fa97fcc | |||
677ed1ab5e | |||
deb0b3bdbb | |||
20c85f0d42 | |||
f9a37f0cb2 | |||
0c8013c26b | |||
6b9e19ed58 | |||
432ab694fd | |||
c506183247 | |||
fe822518d5 | |||
1f9e8221f0 | |||
d7e93e83a3 | |||
17c3383616 | |||
830bab7cb6 | |||
0b3832cc32 | |||
e64ca5ec08 | |||
84b93098f2 | |||
17bef06c98 | |||
db7573de80 | |||
4907496a2e | |||
43daae5529 | |||
1d1fe469f8 | |||
99049164be | |||
f61948d9b3 | |||
ea54c54d42 | |||
c843c5260d | |||
a8912074dd | |||
2be0edcb40 | |||
fcf7ca233f | |||
aa127574c4 | |||
d72f827984 | |||
b7d607bfcc | |||
c727947557 | |||
6864e5bda0 | |||
4babb3ba04 | |||
e0aadc48c4 | |||
18b6fc6eef | |||
5406f6f66f | |||
ab966504cc | |||
ce761db924 | |||
f91c80b5b1 | |||
97fbb4acc1 | |||
554354ce36 | |||
c007fabe12 | |||
3b11e39e99 | |||
653cc4fd84 | |||
eae742c559 | |||
e339f5aa1a | |||
21a1d8cd1b | |||
0ea17555b1 | |||
eec87be7a2 | |||
0cd293c4c3 | |||
e5c70b9535 | |||
3ef68f7a43 | |||
1fbc9e315e | |||
28dafcb721 | |||
4164c7fe04 | |||
bc8aadc17b | |||
cd48ac8245 | |||
0751d080eb | |||
6c6cfe9a04 | |||
b61d514cb2 | |||
a5c352bc06 | |||
54174974b1 | |||
fd81fda9a1 | |||
c69957e905 | |||
a65f4cb02f | |||
3b89b30a98 | |||
5921bd4c1d | |||
5b26d835df | |||
38c4d3bfaf | |||
eac50a8799 | |||
6e5a068ad2 | |||
7f639805e6 | |||
8a6650f833 | |||
96cfeb520d | |||
7cd80e14a7 | |||
b55d453aeb | |||
7eb5197318 | |||
e603ad9977 | |||
068a976499 | |||
5b44fa5c75 | |||
87614084ab | |||
8ccad0b86c | |||
0240dee6ea | |||
81105fb12d | |||
93abb86340 | |||
5584ba0e9f | |||
2c35031549 | |||
d28d7156ce | |||
123cfcb475 | |||
7fa541bc06 | |||
03574461a9 | |||
f588c9af8d | |||
ee39ac9203 | |||
5ea8c97094 | |||
edf3a72564 | |||
b9c9aac686 | |||
7dd7251a45 | |||
1ccbc264ed | |||
334189b8a1 | |||
6c7d6a5443 | |||
e37f2a7190 | |||
baf21549d5 | |||
07c2abd5bc | |||
2ea73b2261 | |||
7c3b47693e | |||
0fe67ce323 | |||
bfb7d72faf | |||
662b952961 | |||
a81cbe3d9c | |||
0462bb186e | |||
9985fe6260 | |||
11a6f01ae3 |
12
.gitmodules
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
[submodule "sources/3rdparty/pdebug"]
|
||||
path = sources/3rdparty/pdebug
|
||||
url = https://github.com/arcan1s/qtadds-pdebug.git
|
||||
[submodule "sources/3rdparty/task"]
|
||||
path = sources/3rdparty/task
|
||||
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
|
||||
[submodule "sources/3rdparty/tasks"]
|
||||
path = sources/3rdparty/tasks
|
||||
url = https://github.com/mhogomchungu/tasks.git
|
||||
[submodule "sources/3rdparty/fontdialog"]
|
||||
path = sources/3rdparty/fontdialog
|
||||
url = https://github.com/arcan1s/qtadds-fontdialog.git
|
1
AUTHORS
@ -6,3 +6,4 @@ Translators:
|
||||
Ernesto Avilés Vzqz (Spanish translation)
|
||||
@underr (Brazillian Portuguese translation)
|
||||
Виктор Слободян (Ukrainian translation)
|
||||
Steve Lemuel (Chinese translation)
|
||||
|
251
CHANGELOG
@ -1,3 +1,100 @@
|
||||
Ver.2.2.1:
|
||||
+ add key X-AW-Interval to ExtUpgrade (ApiVer = 1, default = 3600)
|
||||
+ add values cache to ExtScript and ExtUpgrade
|
||||
+ add support isActive to ExtUpgrade
|
||||
* change cmake version check
|
||||
* improve logic of ExtScript and ExtUpgrade
|
||||
|
||||
Ver.2.2.0:
|
||||
* port to Plasma 5
|
||||
+ add support of windows list in tooltip
|
||||
+ add notifications on system events
|
||||
+ add ability to show selected tag
|
||||
+ add tags $downN, $upN
|
||||
+ add new engine netdev
|
||||
+ add support of smartctl
|
||||
- remove ability to hide panel on hotkey
|
||||
* small changes in widget logic
|
||||
* edit window preview painting
|
||||
* KDE4 code upgrade to new ABI
|
||||
* dataengine optimization
|
||||
* PKGCMD was replaced by ExtUpgrade
|
||||
|
||||
Ver.2.1.0:
|
||||
+ add support of custom scripts
|
||||
+ add support of desktop preview to DP
|
||||
+ add bar support
|
||||
+ add autoupdate function
|
||||
- remove custom command
|
||||
- fix #34
|
||||
* fix notifications
|
||||
* rewrite UI to KDE standards
|
||||
* fix margins on graphical objects
|
||||
* rewrite DP abd DE to use library calls
|
||||
* edit GPU properties definition
|
||||
* edit regexp matching
|
||||
|
||||
Ver.2.0.5:
|
||||
+ add tooltip bottom (#30)
|
||||
* fix network interface update
|
||||
* fix battery tooltip bug
|
||||
* edit DP layout (#31)
|
||||
|
||||
Ver.2.0.4:
|
||||
* more correct work with batteries
|
||||
|
||||
Ver.2.0.3:
|
||||
+ add support of several $bat tags
|
||||
* edit layout
|
||||
|
||||
Ver.2.0.2:
|
||||
+ add $fan* tags
|
||||
+ add Chinese translation (thanks to @Lemueler)
|
||||
+ add net devices checking is it p2p device
|
||||
- remove ps stats from notification
|
||||
* yet another fix cpu* and cpucl*
|
||||
* rewrite DP configuration interface
|
||||
* fix non-standard temp units
|
||||
|
||||
Ver.2.0.1:
|
||||
+ add support of custom interfaces
|
||||
* fix label edge's shading
|
||||
* fix cpu*, cpucl*, gpu*, ps* tags
|
||||
|
||||
Ver.2.0.0:
|
||||
+ add new widget - awesome widget
|
||||
+ add new tags $hddfreemb, $hddfreegb, $memusedmb, $memusedgb, $memfreemb $memfreegb, $swapfreemb, $swapfreegb
|
||||
+ add new DataEngine - battery
|
||||
+ add new tooltip - battery
|
||||
+ add new temperature units cm^-1, kcal/mol, kJ/mol, Reamur
|
||||
+ add ability to hide panels by hotkey pressing
|
||||
- remove widget pytextmonitor
|
||||
- remove separate fields
|
||||
- remove README
|
||||
* project has been renamed to Awesome Widgets
|
||||
* rename tag $custom (time) to $ctime
|
||||
* rename tag $custom (uptime) to $cuptime
|
||||
* rename tag $time (player) to $duration
|
||||
* rename tag $number to $ndesktop
|
||||
* rename tag $name to $desktop
|
||||
* rename tag $total to $tdesktops
|
||||
* debug flag is DEBUG now
|
||||
* rewrite project to C++
|
||||
* tooltip doesn't depend on widget now
|
||||
* text align now can be configured only by using HTML tags
|
||||
* move battery and AC settings to DataEngine
|
||||
* changes in configuration interface
|
||||
|
||||
Ver.1.11.0:
|
||||
+ add ability to disable background image
|
||||
+ add desktop DataEngine
|
||||
+ add PTM desktop panel
|
||||
+ add desktop label (tags $name, $number, $total)
|
||||
+ add ability to interact with players using mpris
|
||||
* rewrite to use submodules
|
||||
* rewrite dataengine to use tasks
|
||||
* fix nvidia temperature definition
|
||||
|
||||
Ver.1.10.2:
|
||||
- fix error with tempUnits in hddtemp label
|
||||
|
||||
@ -7,61 +104,61 @@ Ver.1.10.1:
|
||||
- fix checking of qmmp
|
||||
|
||||
Ver.1.10.0:
|
||||
+ added tags $hddtotmb, $hddtotgb
|
||||
+ added tags $memtotmb, $memtotgb, $swaptotmb, $swaptotgb
|
||||
+ added ability for force update text
|
||||
+ added support of clementine
|
||||
+ added support of hddtemp cmd
|
||||
+ added support of disable option for HDDDEV and GPUDEV
|
||||
+ added error checking of DataEngine variables
|
||||
+ added multithreading to DataEngine
|
||||
+ added ability to disable popup messages
|
||||
+ added ability to use vertical layout
|
||||
+ added ability to add stretch
|
||||
+ added ability to show debug information (set environment variable 'PTM_DEBUG' to 'yes')
|
||||
+ added Brazillian Portuguese translation (@underr)
|
||||
+ added Ukrainian translation (Виктор Слободян)
|
||||
- removed util.py
|
||||
- removed createNotifyrc since it isn't needed
|
||||
+ add tags $hddtotmb, $hddtotgb
|
||||
+ add tags $memtotmb, $memtotgb, $swaptotmb, $swaptotgb
|
||||
+ add ability for force update text
|
||||
+ add support of clementine
|
||||
+ add support of hddtemp cmd
|
||||
+ add support of disable option for HDDDEV and GPUDEV
|
||||
+ add error checking of DataEngine variables
|
||||
+ add multithreading to DataEngine
|
||||
+ add ability to disable popup messages
|
||||
+ add ability to use vertical layout
|
||||
+ add ability to add stretch
|
||||
+ add ability to show debug information (set environment variable 'PTM_DEBUG' to 'yes')
|
||||
+ add Brazillian Portuguese translation (@underr)
|
||||
+ add Ukrainian translation (Виктор Слободян)
|
||||
- remove util.py
|
||||
- remove createNotifyrc since it isn't needed
|
||||
* refactoring of configuration interface
|
||||
* player settings was moved from plasmoid to dataengine
|
||||
* edited readme call
|
||||
* changed readme from md to html
|
||||
* edit readme call
|
||||
* change readme from md to html
|
||||
|
||||
Ver.1.9.0:
|
||||
+ added support of several custom commands ($customN)
|
||||
+ added hdd speed label ($hddrN, $hddwN)
|
||||
+ added actions to context menu (open readme and run ksysguard)
|
||||
- removed doubleclick event
|
||||
+ add support of several custom commands ($customN)
|
||||
+ add hdd speed label ($hddrN, $hddwN)
|
||||
+ add actions to context menu (open readme and run ksysguard)
|
||||
- remove doubleclick event
|
||||
* fix parsing pkg label
|
||||
|
||||
Ver.1.8.3:
|
||||
+ added Spanish translation (thanks to Ernesto Avilés Vzqz)
|
||||
+ added readme to the package
|
||||
+ add Spanish translation (thanks to Ernesto Avilés Vzqz)
|
||||
+ add readme to the package
|
||||
|
||||
Ver.1.8.2:
|
||||
+ added different temperature units (Farenheit and Kelvin)
|
||||
+ add different temperature units (Farenheit and Kelvin)
|
||||
|
||||
Ver.1.8.1:
|
||||
* change pkg update time to hour
|
||||
|
||||
Ver.1.8.0:
|
||||
+ added scrollbar to configuration interface
|
||||
+ added AC lines configuration
|
||||
+ added $hddmbN, %hddgbN tags
|
||||
+ added support of ps ($ps, $pscount, $pstotal tags)
|
||||
+ added support of package managers ($pkgcountN tags)
|
||||
+ add scrollbar to configuration interface
|
||||
+ add AC lines configuration
|
||||
+ add $hddmbN, $hddgbN tags
|
||||
+ add support of ps ($ps, $pscount, $pstotal tags)
|
||||
+ add support of package managers ($pkgcountN tags)
|
||||
* refactoring of DataEngine
|
||||
|
||||
Ver.1.7.4:
|
||||
+ added support more than 10 tags in cpu, cpuclock, hdd, hddtemp, temp labels
|
||||
+ add support more than 10 tags in cpu, cpuclock, hdd, hddtemp, temp labels
|
||||
- format bug fixes
|
||||
* changes in custom uptime format
|
||||
|
||||
Ver.1.7.3:
|
||||
+ added tags $memgb, $swapgb
|
||||
+ added readme directory
|
||||
+ added french translation (@Mermouy)
|
||||
+ add tags $memgb, $swapgb
|
||||
+ add readme directory
|
||||
+ add french translation (@Mermouy)
|
||||
- fix tooltip for custom uptime format
|
||||
- fix #12
|
||||
* more refactoring to the god of refactoring
|
||||
@ -70,108 +167,108 @@ Ver.1.7.3:
|
||||
* player_name now has str type
|
||||
|
||||
Ver.1.7.2:
|
||||
+ added tags $dd, $d, $hh, $h, $mm, $m to custom uptime format
|
||||
+ added scalling to tooltips
|
||||
+ added dataengine configuration from ptm
|
||||
+ added custom command to dataengine
|
||||
- removed custom command from ptm
|
||||
- removed tags $ds, $hs, $ms
|
||||
+ add tags $dd, $d, $hh, $h, $mm, $m to custom uptime format
|
||||
+ add scalling to tooltips
|
||||
+ add dataengine configuration from ptm
|
||||
+ add custom command to dataengine
|
||||
- remove custom command from ptm
|
||||
- remove tags $ds, $hs, $ms
|
||||
|
||||
Ver.1.7.1:
|
||||
- removed error label
|
||||
- remove error label
|
||||
* fix bug with zero values in tooltip
|
||||
|
||||
Ver.1.7.0:
|
||||
+ added support of several tags in temperature label
|
||||
+ added tags $cpuN, $cpuclN, $hddN, $tempN, $hddtempN, $up, $down
|
||||
+ added label with custom command
|
||||
+ added tooltips for CPU, CPU clock, memory, swap and network labels
|
||||
- removed tags @@...@@, $temp, $ccpu, $ccpucl, $net
|
||||
+ add support of several tags in temperature label
|
||||
+ add tags $cpuN, $cpuclN, $hddN, $tempN, $hddtempN, $up, $down
|
||||
+ add label with custom command
|
||||
+ add tooltips for CPU, CPU clock, memory, swap and network labels
|
||||
- remove tags @@...@@, $temp, $ccpu, $ccpucl, $net
|
||||
* changes in settings
|
||||
* ptm now does not require net-tools
|
||||
* refactoring
|
||||
|
||||
Ver.1.6.1:
|
||||
+ added support of several devices in hddtemp label
|
||||
+ add support of several devices in hddtemp label
|
||||
- fixed #6
|
||||
|
||||
Ver.1.6.0:
|
||||
+ added $custom tag to time and uptime labels (#8)
|
||||
+ add $custom tag to time and uptime labels (#8)
|
||||
+ russian translation
|
||||
- fixed #6, #10
|
||||
* changed license to GPLv3
|
||||
* changed project build
|
||||
- fix #6, #10
|
||||
* change license to GPLv3
|
||||
* change project build
|
||||
|
||||
Ver.1.5.3:
|
||||
+ added $album, $progress and $time tags to player label (#7)
|
||||
- fixed zero swap
|
||||
+ add $album, $progress and $time tags to player label (#7)
|
||||
- fix zero swap
|
||||
|
||||
Ver.1.5.2:
|
||||
+ added $isotime, $shorttime and $longtime tags to time label
|
||||
+ add $isotime, $shorttime and $longtime tags to time label
|
||||
|
||||
Ver.1.5.1:
|
||||
+ added time label
|
||||
+ add time label
|
||||
|
||||
Ver.1.5.0:
|
||||
+ added player label
|
||||
+ add player label
|
||||
|
||||
Ver.1.4.0:
|
||||
+ added notifications
|
||||
+ add notifications
|
||||
|
||||
Ver.1.3.6:
|
||||
- fixed #1, #2
|
||||
- fix #1, #2
|
||||
|
||||
Ver.1.3.5:
|
||||
- fix bug with definition network device
|
||||
|
||||
Ver.1.3.4:
|
||||
+ added double click event
|
||||
+ added auto selection of network device
|
||||
- fixed yet another plasma crash
|
||||
+ add double click event
|
||||
+ add auto selection of network device
|
||||
- fix yet another plasma crash
|
||||
|
||||
Ver.1.3.3:
|
||||
* edited reading temperature device
|
||||
* edit reading temperature device
|
||||
|
||||
Ver.1.3.2b:
|
||||
- fixed plasma crash
|
||||
- fix plasma crash
|
||||
|
||||
Ver.1.3.2:
|
||||
+ added GPU, GPU temperature, HDD and HDD temperature labels
|
||||
+ added $ccpu and $ccpucl tags
|
||||
+ add GPU, GPU temperature, HDD and HDD temperature labels
|
||||
+ add $ccpu and $ccpucl tags
|
||||
- bug fixes
|
||||
* optimization and refactoring
|
||||
|
||||
Ver.1.2.2:
|
||||
+ added tooltip to lineEdit
|
||||
+ add tooltip to lineEdit
|
||||
|
||||
Ver.1.2.1:
|
||||
* if battery doesn't exist return 'off'
|
||||
* if AC doesn't exist return '(?)'
|
||||
|
||||
Ver.1.2.0:
|
||||
+ added $ac tag to battery label
|
||||
+ added battery and ac device configurations
|
||||
+ added error cheking
|
||||
+ add $ac tag to battery label
|
||||
+ add battery and ac device configurations
|
||||
+ add error cheking
|
||||
* $bat tag now reading from /sys/*
|
||||
|
||||
Ver.1.1.4:
|
||||
* changed parsing acpi output (battery label)
|
||||
* change parsing acpi output (battery label)
|
||||
|
||||
Ver.1.1.3:
|
||||
+ added font weight
|
||||
* edited font setup line. Now setup for font family works normaly
|
||||
+ add font weight
|
||||
* edit font setup line. Now setup for font family works normaly
|
||||
* small bug fix
|
||||
|
||||
Ver.1.1.2:
|
||||
+ added CPU clock lable
|
||||
+ added function to update network device (100*time_interval)
|
||||
+ changed update sliders
|
||||
+ add CPU clock lable
|
||||
+ add function to update network device (100*time_interval)
|
||||
+ change update sliders
|
||||
|
||||
Ver.1.1.1:
|
||||
+ added $swapmb, $memmb, $netdev, @@netdev=...@@ tags
|
||||
+ add $swapmb, $memmb, $netdev, @@netdev=...@@ tags
|
||||
- some bug fixes
|
||||
* widget consists of several labels
|
||||
* edited configuration interface
|
||||
* edit configuration interface
|
||||
|
||||
Ver.1.0:
|
||||
First release
|
||||
|
97
CHANGELOG-RU
@ -1,3 +1,100 @@
|
||||
Вер.2.2.1:
|
||||
+ добавлен ключ X-AW-Interval в ExtUpgrade (ApiVer = 1, default = 3600)
|
||||
+ добавлено кеширование значений в ExtScript и ExtUpgrade
|
||||
+ добавлена поддержка isActive в ExtUpgrade
|
||||
* изменена проверка версий cmake
|
||||
* улучшена логика работы ExtScript и ExtUpgrade
|
||||
|
||||
Вер.2.2.0:
|
||||
* портирование на Plasma 5
|
||||
+ добавлена поддержка списка окон в тултипе
|
||||
+ добавлены уведомления на системные события
|
||||
+ добавлена возможность показать выбранный тег
|
||||
+ добавлены теги $downN, $upN
|
||||
+ добавлен инструмент netdev
|
||||
+ добавлена поддержка smartctl
|
||||
- убрана возможность сокрытия панелей
|
||||
* незначительно изменена логика работы виджета
|
||||
* исправлена отрисовка превью окон
|
||||
* обновление кодовой базы KDE4 под новый ABI
|
||||
* оптимизация работы dataengine
|
||||
* PKGCMD были заменены на ExtUpgrade
|
||||
|
||||
Вер.2.1.0:
|
||||
+ добавлена функция автообновления
|
||||
+ добавлена поддерка кастомных скриптов
|
||||
+ добавлена поддержка превью рабочего стола для DP
|
||||
+ добавлена поддержка баров
|
||||
- удалена поддержка кастомных команд
|
||||
- фикс #34
|
||||
* исправлены уведомления
|
||||
* переписан UI в соответствии со стандартами KDE
|
||||
* исправлены границы для графических объектов
|
||||
* переписан DP и DE на использование библиотечных функций
|
||||
* изменено определение свойств GPU
|
||||
* изменен поиск регулярных выражений
|
||||
|
||||
Вер.2.0.5:
|
||||
+ добавлен нижний край к тултипу (#30)
|
||||
* исправлен баг с обновлением сетевого интерфейса
|
||||
* исправлен баг с тултипом батареи
|
||||
* отредактирована разметка DP (#31)
|
||||
|
||||
Вер.2.0.4:
|
||||
* более корректная работа с батареями
|
||||
|
||||
Вер.2.0.3:
|
||||
+ добавлена поддержка нескольких тегов $bat
|
||||
* отредактирована разметка
|
||||
|
||||
Вер.2.0.2:
|
||||
+ добавлены теги $fan*
|
||||
+ добавлен китайский перевод (спасибо @Lemueler)
|
||||
+ добавлена проверка сетевых устройств на p2p
|
||||
- удалено ps stats из уведомлений
|
||||
* еще один фикс тегов cpu* и cpucl
|
||||
* переписан конфигурационный интерфейс DP
|
||||
* исправлены нестандартные единицы температуры
|
||||
|
||||
Вер.2.0.1:
|
||||
+ добавлена поддержка кастомных интерфейсов
|
||||
* фикс затенения краев поля
|
||||
* фикс тегов cpu*, cpucl*, gpu*, ps*
|
||||
|
||||
Вер.2.0.0:
|
||||
+ добавлен виджет awesome widget
|
||||
+ новые теги $hddfreemb, $hddfreegb, $memusedmb, $memusedgb, $memfreemb $memfreegb, $swapfreemb, $swapfreegb
|
||||
+ новый DataEngine - battery
|
||||
+ новый тултип - battery
|
||||
+ новые температурные единицы см^-1, ккал/моль, кДж/моль, Реамюр
|
||||
+ добавлена возможность скрывать панели по хоткею
|
||||
- удален виджет pytextmonitor
|
||||
- убраны отдельные поля
|
||||
- удалены README
|
||||
* проект переименован в Awesome Widgets
|
||||
* тег $custom (время) переименован в $ctime
|
||||
* тег $custom (время работы) переименован в $cuptime
|
||||
* тег $time (плеер) переименован в $duration
|
||||
* тег $number переименован в $ndesktop
|
||||
* тег $name переименован в $desktop
|
||||
* тег $total переименован в $tdesktops
|
||||
* дебаг флаг теперь DEBUG
|
||||
* проект полностью переписан на C++
|
||||
* тултип независит теперь от самого виджета
|
||||
* настройка выравнивания текста теперь осуществляется только HTML тегами
|
||||
* настройки батареи и адаптора питания вынесены в DataEngine
|
||||
* изменения в конфигурационном интерфейсе
|
||||
|
||||
Вер.1.11.0:
|
||||
+ добавлена возможность отключения фона
|
||||
+ добавлен desktop DataEngine
|
||||
+ добавлен виджет PTM desktop panel
|
||||
+ добавлено поле текущий рабочий стол (теги $name, $number, $total)
|
||||
+ добавлена возможность взаимодействия с плеерами через mpris
|
||||
* добавлено использование сабмодулей
|
||||
* dataengine переписан с использованием tasks
|
||||
* фикс чтения температуры nvidia
|
||||
|
||||
Вер.1.10.2:
|
||||
- фикс ошибки с tempUnits в поле hddtemp
|
||||
|
||||
|
4
COPYING
@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
pytextmonitor
|
||||
awesome-widgets
|
||||
Copyright (C) 2013-2014 Evgeniy Alekseev
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
pytextmonitor Copyright (C) 2013 Evgeniy Alekseev
|
||||
awesome-widgets Copyright (C) 2013 Evgeniy Alekseev
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
43
PKGBUILD
@ -1,43 +0,0 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgname=kdeplasma-applets-pytextmonitor
|
||||
_pkgname=pytextmonitor
|
||||
pkgver=1.10.2
|
||||
pkgrel=1
|
||||
pkgdesc="Minimalistic Plasmoid script written on Python2. It looks like widgets in Awesome WM"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/pytextmonitor"
|
||||
license=('GPL3')
|
||||
depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors')
|
||||
optdepends=("amarok: for music player monitor"
|
||||
"clementine: for music player monitor"
|
||||
"catalyst: for GPU monitor"
|
||||
"hddtemp: for HDD temperature monitor"
|
||||
"mpd: for music player monitor"
|
||||
"net-tools: for popup messages"
|
||||
"nvidia-utils: for GPU monitor"
|
||||
"qmmp: for music player monitor"
|
||||
"sysstat: for popup messages")
|
||||
makedepends=('automoc4' 'cmake')
|
||||
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('62b7cb57cb996282bb7decc2dbdf27c1')
|
||||
backup=('usr/share/config/extsysmon.conf')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build"
|
||||
mkdir "${srcdir}/build"
|
||||
}
|
||||
|
||||
build () {
|
||||
cd "${srcdir}/build"
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) \
|
||||
"../${_pkgname}"
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/build"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
249
README.md
@ -1,217 +1,28 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
awesome-widgets (ex-pytextmonitor)
|
||||
==================================
|
||||
|
||||
**NOTE** KDE4 version is dropped from development since 2.2.1. Only critical bug
|
||||
fixes will be applied.
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm.
|
||||
A collection of minimalistic widgets which looks like Awesome Window Manager widgets.
|
||||
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/pytextmonitor/issues/14)
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/awesome-widgets/issues/14)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
Features
|
||||
========
|
||||
|
||||
For edited output you must open Settings window and setup output format in lines:
|
||||
* easy and fully configurable native Plasma widget which may be used as Conky widget or as Awesome-like information panel
|
||||
* panel which shows active desktop status
|
||||
* clear Conky-like configuration with html tags support
|
||||
* custom command support (it may be simple action as well as special custom tag)
|
||||
* graphical item support - tooltips, bars
|
||||
|
||||
* tag `$time` - time in default format. For example, *fri Nov 6 04:48:01 2013*
|
||||
* tag `$isotime` - time in iso format
|
||||
* tag `$shorttime` - time in short locale format
|
||||
* tag `$longtime` - time in long locale format
|
||||
* tag `$custom` - custom time format
|
||||
* tag `$uptime` - uptime, *---d--h--m*
|
||||
* tag `$custom` - custom uptime format
|
||||
* tag `$cpu` - total load cpu, *%*
|
||||
* tag `$cpuN` - load CPU for core N, *%*
|
||||
* tag `$cpucl` - average cpu clock, *MHz*
|
||||
* tag `$cpuclN` - cpu clock for core N, *MHz*
|
||||
* tag `$tempN` - temperature for device N. For example, `$temp0`
|
||||
* tag `$gpu` - GPU usage, *%*. `aticonfig` or `nvidia-smi` must be installed
|
||||
* tag `$gputemp` - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
|
||||
* tag `$mem` - usage memory, *%*
|
||||
* tag `$memmb` - usage memory, *MB*
|
||||
* tag `$memgb` - usage memory, *GB*
|
||||
* tag `$memtotmb` - total RAM, *MB*
|
||||
* tag `$memtotgb` - total RAM, *GB*
|
||||
* tag `$swap` - swap, *%*
|
||||
* tag `$swapmb` - swap, *MB*
|
||||
* tag `$swapgb` - swap, *GB*
|
||||
* tag `$swaptotmb` - total swap, *MB*
|
||||
* tag `$swaptotgb` - total swap, *GB*
|
||||
* tag `$hddN` - usage for mount point N, *%*. For example, `$hdd0`
|
||||
* tag `$hddmbN` - usage for mount point N, *MB*. For example, `$hddmb0`
|
||||
* tag `$hddgbN` - usage for mount point N, *GB*. For example, `$hddgb0`
|
||||
* tag `$hddtotmbN` - total size of mount point N, *MB*. For example, `$hddtotmb0`
|
||||
* tag `$hddtotgbN` - total size of mount point N, *GB*. For example, `$hddtotgb0`
|
||||
* tag `$hddrN` - read speed of disk N, *KB/s*. For example, `$hddr0`
|
||||
* tag `$hddwN` - write speed of disk N, *KB/s*. For example, `$hddw0`
|
||||
* tag `$hddtempN` - temperature for HDD N. For example, `$hddtemp0`
|
||||
* tag `$down` - download speed, *KB/s*
|
||||
* tag `$up` - upload speed, *KB/s*
|
||||
* tag `$netdev` - current network device
|
||||
* tag `$bat` - battery charge, *%*
|
||||
* tag `$ac` - status AC device. Return (\*) if AC device is online or *( )* if offline
|
||||
* tag `$album` - current song album. One of supported music players must be installed
|
||||
* tag `$artist` - current song artist. One of supported music players must be installed
|
||||
* tag `$progress` - current song progress. One of supported music players must be installed
|
||||
* tag `$time` - current song duration. One of supported music players must be installed
|
||||
* tag `$title` - current song title. One of supported music players must be installed
|
||||
* tag `$pscount` - number of running processes
|
||||
* tag `$pstotal` - total number of processes
|
||||
* tag `$ps` - list of running processes
|
||||
* tag `$pkgcountN` - number of packages, which available to upgrade for command N. For example, `$pkgcount0`
|
||||
* tag `$customN` - returns output for custom command N. For example, `$custom0`
|
||||
See [links](#Links) for more details.
|
||||
|
||||
Label order will changed if you change slider position. HTML tags in label work normally.
|
||||
|
||||
**NOTE** you don't may set to show `$cpu` tag in swap label for example. **`$cpu` will work only in cpu label**.
|
||||
|
||||
Tips & tricks
|
||||
-------------
|
||||
|
||||
You may use different colors for labels. Just put label text into html code. See [issue](https://github.com/arcan1s/pytextmonitor/issues/9) for more details.
|
||||
|
||||
Numbering of elements of temperature, HDD usage, HDD speed, HDD temperature refers to elements order from second tab (*Advanced settings*). You should add item to the required listWidget first. And the first element in the listWidget will be `$tag0`. See [issue](https://github.com/arcan1s/pytextmonitor/issues/17) for more details.
|
||||
|
||||
Advanced settings
|
||||
-----------------
|
||||
|
||||
**Vertical layout**
|
||||
|
||||
Use vertical layout instead of horizontal one.
|
||||
|
||||
**Enable popup**
|
||||
|
||||
Uncheck box if you do not use popup messages.
|
||||
|
||||
**Add stretch**
|
||||
|
||||
Add stretch (spacer) to the selected side of the widget.
|
||||
|
||||
**Custom time**
|
||||
|
||||
* tag `$dddd` - weekday in long format
|
||||
* tag `$ddd` - weekday in short format
|
||||
* tag `$dd` - day
|
||||
* tag `$d` - day without zero
|
||||
* tag `$MMMM` - month in long format
|
||||
* tag `$MMM` - month in short format
|
||||
* tag `$MM` - month
|
||||
* tag `$M` - month without zero
|
||||
* tag `$yyyy` - year
|
||||
* tag `$yy` - year in short format
|
||||
* tag `$hh` - hours
|
||||
* tag `$h` - hours without zero
|
||||
* tag `$mm` - minutes
|
||||
* tag `$m` - minutes without zero
|
||||
* tag `$ss` - seconds
|
||||
* tag `$s` - seconds without zero
|
||||
|
||||
**Custom uptime**
|
||||
|
||||
* tag `$dd` - uptime days
|
||||
* tag `$d` - uptime days without zero
|
||||
* tag `$hh` - uptime hours
|
||||
* tag `$h` - uptime hours without zero
|
||||
* tag `$mm` - uptime minutes
|
||||
* tag `$m` - uptime minutes without zero
|
||||
|
||||
**Temperature units**
|
||||
|
||||
Select units for temperature. Available units are Celsius, Farenheit and Kelvin.
|
||||
|
||||
**Temperature devices**
|
||||
|
||||
List of devices, which will be observed in temp label (combo box items come from `sensors`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**Mount points**
|
||||
|
||||
List of mount points, which will be observed in hdd label (combo box items come from `mount`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**HDD (speed)**
|
||||
|
||||
List of hard disk devices, which will be observed in hddspeed label (combo box items come from DataEngine). List widget is editable, delete key will remove current item.
|
||||
|
||||
**HDD (temperature)**
|
||||
|
||||
List of hard disk devices, which will be observed in hddtemp label (combo box items come from `find`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**Network directory**
|
||||
|
||||
Path to directory, which contains network devices information. Default is `/sys/class/net`. Required for auto select network device.
|
||||
|
||||
**Network device**
|
||||
|
||||
Use specified device as active. Combo box items come from **network directory**. Will disable auto select network device.
|
||||
|
||||
**Battery device**
|
||||
|
||||
File with battery information. File (`/sys/class/power_supply/BAT0/capacity` by default) should contain only battery charge in percent.
|
||||
|
||||
**AC online tag**
|
||||
|
||||
Line which will be shown when AC is online.
|
||||
|
||||
**AC offline tag**
|
||||
|
||||
Line which will be shown when AC is offline.
|
||||
|
||||
**AC device**
|
||||
|
||||
File with AC information. File (`/sys/class/power_supply/AC/online` by default) must contain `1` if AC is online.
|
||||
|
||||
Tooltip settings
|
||||
----------------
|
||||
|
||||
Since version 1.7.0 CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make the needed checkboxes a fully checked. The number of stored values can be set in the tab. Colors of graphs are configurable too.
|
||||
|
||||
DataEngine settings
|
||||
-------------------
|
||||
|
||||
**Custom command**
|
||||
|
||||
*NOTE* This can cause the computer freeze.
|
||||
|
||||
Commands, which will be run for custom label.
|
||||
|
||||
**GPU device**
|
||||
|
||||
Select one of supported GPU devices. `auto` will enable auto selection, `disable` will disable definition of GPU states. Default is `auto`.
|
||||
|
||||
**HDD**
|
||||
|
||||
Select one of HDDs for HDD temperature monitor. `all` will enable monitor for all devices, `disable` will disable definition of HDD temperature. Default is `all`.
|
||||
|
||||
**hddtemp cmd**
|
||||
|
||||
Type a command which will be run for hddtemp DataEngine. Default is `sudo hddtemp`.
|
||||
|
||||
**MPD address**
|
||||
|
||||
Address of MPD server. Default is `localhost`.
|
||||
|
||||
**MPD port**
|
||||
|
||||
Port of MPD server. Default is `6600`.
|
||||
|
||||
**Package manager**
|
||||
|
||||
List of commands, which will be run. Number of null lines is a number of unneeded lines. Defaults:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Music player**
|
||||
|
||||
Select one of supported music playes for player label.
|
||||
|
||||
DataEngine configuration
|
||||
------------------------
|
||||
|
||||
You may edit DataEngine configuration. It is `/usr/share/config/extsysmon.conf` or `$HOME/share/config/extsysmon.conf` depending on the type of installation. Uncomment needed line and edit it.
|
||||
**Didn't find required feature?** [Just ask for it!](https://github.com/arcan1s/awesome-widgets/issues)
|
||||
|
||||
Instruction
|
||||
===========
|
||||
@ -220,22 +31,21 @@ Dependencies
|
||||
------------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*for definition temperature device*)
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* sysstat (*for notification*)
|
||||
* proprietary video driver
|
||||
* hddtemp (make sure that it may be run with `sudo` without password. Just add following line to `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* music player (amarok, clementine, mpd or qmmp)
|
||||
* hddtemp
|
||||
* smartmontools
|
||||
* music player (mpd or supported MPRIS)
|
||||
|
||||
Make dependencies
|
||||
-----------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
* automoc4
|
||||
|
||||
Installation
|
||||
------------
|
||||
@ -244,13 +54,7 @@ Installation
|
||||
* install
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
Also you may install it to `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../
|
||||
make && sudo make install
|
||||
|
||||
Additional information
|
||||
@ -259,10 +63,15 @@ Additional information
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
See [milestones](https://github.com/arcan1s/awesome-widgets/milestones) for more details.
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* [Homepage](http://arcanis.name/projects/awesome-widgets/)
|
||||
* [Migration to 2.*](http://arcanis.name/en/2014/09/04/migration-to-v2/)
|
||||
* [Scripts and bars](http://arcanis.name/en/2014/12/19/aw-v21-bells-and-whistles/)
|
||||
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Awesome+Widgets?content=157124)
|
||||
* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/) package
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-awesome-widgets-git/) package
|
||||
* [OpenSuse](http://software.opensuse.org/package/awesome-widgets) package
|
||||
|
268
README.md.orig
@ -1,268 +0,0 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm.
|
||||
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/pytextmonitor/issues/14)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
For edited output you must open Settings window and setup output format in lines:
|
||||
|
||||
* tag `$time` - time in default format. For example, *fri Nov 6 04:48:01 2013*
|
||||
* tag `$isotime` - time in iso format
|
||||
* tag `$shorttime` - time in short locale format
|
||||
* tag `$longtime` - time in long locale format
|
||||
* tag `$custom` - custom time format
|
||||
* tag `$uptime` - uptime, *---d--h--m*
|
||||
* tag `$custom` - custom uptime format
|
||||
* tag `$cpu` - total load cpu, *%*
|
||||
* tag `$cpuN` - load CPU for core N, *%*
|
||||
* tag `$cpucl` - average cpu clock, *MHz*
|
||||
* tag `$cpuclN` - cpu clock for core N, *MHz*
|
||||
* tag `$tempN` - temperature for device N. For example, `$temp0`
|
||||
* tag `$gpu` - GPU usage, *%*. `aticonfig` or `nvidia-smi` must be installed
|
||||
* tag `$gputemp` - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
|
||||
* tag `$mem` - usage memory, *%*
|
||||
* tag `$memmb` - usage memory, *MB*
|
||||
* tag `$memgb` - usage memory, *GB*
|
||||
* tag `$memtotmb` - total RAM, *MB*
|
||||
* tag `$memtotgb` - total RAM, *GB*
|
||||
* tag `$swap` - swap, *%*
|
||||
* tag `$swapmb` - swap, *MB*
|
||||
* tag `$swapgb` - swap, *GB*
|
||||
* tag `$swaptotmb` - total swap, *MB*
|
||||
* tag `$swaptotgb` - total swap, *GB*
|
||||
* tag `$hddN` - usage for mount point N, *%*. For example, `$hdd0`
|
||||
* tag `$hddmbN` - usage for mount point N, *MB*. For example, `$hddmb0`
|
||||
* tag `$hddgbN` - usage for mount point N, *GB*. For example, `$hddgb0`
|
||||
* tag `$hddtotmbN` - total size of mount point N, *MB*. For example, `$hddtotmb0`
|
||||
* tag `$hddtotgbN` - total size of mount point N, *GB*. For example, `$hddtotgb0`
|
||||
* tag `$hddrN` - read speed of disk N, *KB/s*. For example, `$hddr0`
|
||||
* tag `$hddwN` - write speed of disk N, *KB/s*. For example, `$hddw0`
|
||||
* tag `$hddtempN` - temperature for HDD N. For example, `$hddtemp0`
|
||||
* tag `$down` - download speed, *KB/s*
|
||||
* tag `$up` - upload speed, *KB/s*
|
||||
* tag `$netdev` - current network device
|
||||
* tag `$bat` - battery charge, *%*
|
||||
* tag `$ac` - status AC device. Return (\*) if AC device is online or *( )* if offline
|
||||
* tag `$album` - current song album. One of supported music players must be installed
|
||||
* tag `$artist` - current song artist. One of supported music players must be installed
|
||||
* tag `$progress` - current song progress. One of supported music players must be installed
|
||||
* tag `$time` - current song duration. One of supported music players must be installed
|
||||
* tag `$title` - current song title. One of supported music players must be installed
|
||||
* tag `$pscount` - number of running processes
|
||||
* tag `$pstotal` - total number of processes
|
||||
* tag `$ps` - list of running processes
|
||||
* tag `$pkgcountN` - number of packages, which available to upgrade for command N. For example, `$pkgcount0`
|
||||
* tag `$customN` - returns output for custom command N. For example, `$custom0`
|
||||
|
||||
Label order will changed if you change slider position. HTML tags in label work normally.
|
||||
|
||||
**NOTE** you don't may set to show `$cpu` tag in swap label for example. **`$cpu` will work only in cpu label**.
|
||||
|
||||
Tips & tricks
|
||||
-------------
|
||||
|
||||
You may use different colors for labels. Just put label text into html code. See [issue](https://github.com/arcan1s/pytextmonitor/issues/9) for more details.
|
||||
|
||||
Numbering of elements of temperature, HDD usage, HDD speed, HDD temperature refers to elements order from second tab (*Advanced settings*). You should add item to the required listWidget first. And the first element in the listWidget will be `$tag0`. See [issue](https://github.com/arcan1s/pytextmonitor/issues/17) for more details.
|
||||
|
||||
Advanced settings
|
||||
-----------------
|
||||
|
||||
**Vertical layout**
|
||||
|
||||
Use vertical layout instead of horizontal one.
|
||||
|
||||
**Enable popup**
|
||||
|
||||
Uncheck box if you do not use popup messages.
|
||||
|
||||
**Add stretch**
|
||||
|
||||
Add stretch (spacer) to the selected side of the widget.
|
||||
|
||||
**Custom time**
|
||||
|
||||
* tag `$dddd` - weekday in long format
|
||||
* tag `$ddd` - weekday in short format
|
||||
* tag `$dd` - day
|
||||
* tag `$d` - day without zero
|
||||
* tag `$MMMM` - month in long format
|
||||
* tag `$MMM` - month in short format
|
||||
* tag `$MM` - month
|
||||
* tag `$M` - month without zero
|
||||
* tag `$yyyy` - year
|
||||
* tag `$yy` - year in short format
|
||||
* tag `$hh` - hours
|
||||
* tag `$h` - hours without zero
|
||||
* tag `$mm` - minutes
|
||||
* tag `$m` - minutes without zero
|
||||
* tag `$ss` - seconds
|
||||
* tag `$s` - seconds without zero
|
||||
|
||||
**Custom uptime**
|
||||
|
||||
* tag `$dd` - uptime days
|
||||
* tag `$d` - uptime days without zero
|
||||
* tag `$hh` - uptime hours
|
||||
* tag `$h` - uptime hours without zero
|
||||
* tag `$mm` - uptime minutes
|
||||
* tag `$m` - uptime minutes without zero
|
||||
|
||||
**Temperature units**
|
||||
|
||||
Select units for temperature. Available units are Celsius, Farenheit and Kelvin.
|
||||
|
||||
**Temperature devices**
|
||||
|
||||
List of devices, which will be observed in temp label (combo box items come from `sensors`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**Mount points**
|
||||
|
||||
List of mount points, which will be observed in hdd label (combo box items come from `mount`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**HDD (speed)**
|
||||
|
||||
List of hard disk devices, which will be observed in hddspeed label (combo box items come from DataEngine). List widget is editable, delete key will remove current item.
|
||||
|
||||
**HDD (temperature)**
|
||||
|
||||
List of hard disk devices, which will be observed in hddtemp label (combo box items come from `find`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**Network directory**
|
||||
|
||||
Path to directory, which contains network devices information. Default is `/sys/class/net`. Required for auto select network device.
|
||||
|
||||
**Network device**
|
||||
|
||||
Use specified device as active. Combo box items come from **network directory**. Will disable auto select network device.
|
||||
|
||||
**Battery device**
|
||||
|
||||
File with battery information. File (`/sys/class/power_supply/BAT0/capacity` by default) should contain only battery charge in percent.
|
||||
|
||||
**AC online tag**
|
||||
|
||||
Line which will be shown when AC is online.
|
||||
|
||||
**AC offline tag**
|
||||
|
||||
Line which will be shown when AC is offline.
|
||||
|
||||
**AC device**
|
||||
|
||||
File with AC information. File (`/sys/class/power_supply/AC/online` by default) must contain `1` if AC is online.
|
||||
|
||||
Tooltip settings
|
||||
----------------
|
||||
|
||||
Since version 1.7.0 CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make the needed checkboxes a fully checked. The number of stored values can be set in the tab. Colors of graphs are configurable too.
|
||||
|
||||
DataEngine settings
|
||||
-------------------
|
||||
|
||||
**Custom command**
|
||||
|
||||
*NOTE* This can cause the computer freeze.
|
||||
|
||||
Commands, which will be run for custom label.
|
||||
|
||||
**GPU device**
|
||||
|
||||
Select one of supported GPU devices. `auto` will enable auto selection, `disable` will disable definition of GPU states. Default is `auto`.
|
||||
|
||||
**HDD**
|
||||
|
||||
Select one of HDDs for HDD temperature monitor. `all` will enable monitor for all devices, `disable` will disable definition of HDD temperature. Default is `all`.
|
||||
|
||||
**hddtemp cmd**
|
||||
|
||||
Type a command which will be run for hddtemp DataEngine. Default is `sudo hddtemp`.
|
||||
|
||||
**MPD address**
|
||||
|
||||
Address of MPD server. Default is `localhost`.
|
||||
|
||||
**MPD port**
|
||||
|
||||
Port of MPD server. Default is `6600`.
|
||||
|
||||
**Package manager**
|
||||
|
||||
List of commands, which will be run. Number of null lines is a number of unneeded lines. Defaults:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Music player**
|
||||
|
||||
Select one of supported music playes for player label.
|
||||
|
||||
DataEngine configuration
|
||||
------------------------
|
||||
|
||||
You may edit DataEngine configuration. It is `/usr/share/config/extsysmon.conf` or `$HOME/share/config/extsysmon.conf` depending on the type of installation. Uncomment needed line and edit it.
|
||||
|
||||
Instruction
|
||||
===========
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*for definition temperature device*)
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* sysstat (*for notification*)
|
||||
* proprietary video driver
|
||||
* hddtemp (make sure that it may be run with `sudo` without password. Just add following line to `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* music player (amarok, clementine, mpd or qmmp)
|
||||
|
||||
Make dependencies
|
||||
-----------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
* download sources
|
||||
* install
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
Also you may install it to `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
make && sudo make install
|
||||
|
||||
Additional information
|
||||
======================
|
||||
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/) package
|
@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
./update_files.sh
|
||||
|
||||
SRCDIR="sources"
|
||||
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
MINOR=$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
PATCH=$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
# build dataengine
|
||||
ARCHIVE="ext-sysmon"
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f ${ARCHIVE}-${VERSION}-src.tar.xz
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}/${ARCHIVE}" "${ARCHIVE}"
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
rm -rf "${ARCHIVE}"
|
||||
|
||||
# build widget
|
||||
ARCHIVE="pytextmonitor"
|
||||
FILES="AUTHORS CHANGELOG CHANGELOG-RU COPYING"
|
||||
IGNORELIST="build usr"
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}" "${ARCHIVE}"
|
||||
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
||||
for FILE in ${IGNORELIST[*]}; do rm -rf "${ARCHIVE}/${FILE}"; done
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
rm -rf "${ARCHIVE}"
|
||||
|
||||
# update md5sum
|
||||
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD
|
@ -1,18 +0,0 @@
|
||||
func_update() {
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_install() {
|
||||
func_update
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
func_update
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
func_update
|
||||
}
|
268
md_readme/en.md
@ -1,268 +0,0 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
|
||||
Information
|
||||
-----------
|
||||
|
||||
PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm.
|
||||
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/pytextmonitor/issues/14)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
For edited output you must open Settings window and setup output format in lines:
|
||||
|
||||
* tag `$time` - time in default format. For example, *fri Nov 6 04:48:01 2013*
|
||||
* tag `$isotime` - time in iso format
|
||||
* tag `$shorttime` - time in short locale format
|
||||
* tag `$longtime` - time in long locale format
|
||||
* tag `$custom` - custom time format
|
||||
* tag `$uptime` - uptime, *---d--h--m*
|
||||
* tag `$custom` - custom uptime format
|
||||
* tag `$cpu` - total load cpu, *%*
|
||||
* tag `$cpuN` - load CPU for core N, *%*
|
||||
* tag `$cpucl` - average cpu clock, *MHz*
|
||||
* tag `$cpuclN` - cpu clock for core N, *MHz*
|
||||
* tag `$tempN` - temperature for device N. For example, `$temp0`
|
||||
* tag `$gpu` - GPU usage, *%*. `aticonfig` or `nvidia-smi` must be installed
|
||||
* tag `$gputemp` - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
|
||||
* tag `$mem` - usage memory, *%*
|
||||
* tag `$memmb` - usage memory, *MB*
|
||||
* tag `$memgb` - usage memory, *GB*
|
||||
* tag `$memtotmb` - total RAM, *MB*
|
||||
* tag `$memtotgb` - total RAM, *GB*
|
||||
* tag `$swap` - swap, *%*
|
||||
* tag `$swapmb` - swap, *MB*
|
||||
* tag `$swapgb` - swap, *GB*
|
||||
* tag `$swaptotmb` - total swap, *MB*
|
||||
* tag `$swaptotgb` - total swap, *GB*
|
||||
* tag `$hddN` - usage for mount point N, *%*. For example, `$hdd0`
|
||||
* tag `$hddmbN` - usage for mount point N, *MB*. For example, `$hddmb0`
|
||||
* tag `$hddgbN` - usage for mount point N, *GB*. For example, `$hddgb0`
|
||||
* tag `$hddtotmbN` - total size of mount point N, *MB*. For example, `$hddtotmb0`
|
||||
* tag `$hddtotgbN` - total size of mount point N, *GB*. For example, `$hddtotgb0`
|
||||
* tag `$hddrN` - read speed of disk N, *KB/s*. For example, `$hddr0`
|
||||
* tag `$hddwN` - write speed of disk N, *KB/s*. For example, `$hddw0`
|
||||
* tag `$hddtempN` - temperature for HDD N. For example, `$hddtemp0`
|
||||
* tag `$down` - download speed, *KB/s*
|
||||
* tag `$up` - upload speed, *KB/s*
|
||||
* tag `$netdev` - current network device
|
||||
* tag `$bat` - battery charge, *%*
|
||||
* tag `$ac` - status AC device. Return (\*) if AC device is online or *( )* if offline
|
||||
* tag `$album` - current song album. One of supported music players must be installed
|
||||
* tag `$artist` - current song artist. One of supported music players must be installed
|
||||
* tag `$progress` - current song progress. One of supported music players must be installed
|
||||
* tag `$time` - current song duration. One of supported music players must be installed
|
||||
* tag `$title` - current song title. One of supported music players must be installed
|
||||
* tag `$pscount` - number of running processes
|
||||
* tag `$pstotal` - total number of processes
|
||||
* tag `$ps` - list of running processes
|
||||
* tag `$pkgcountN` - number of packages, which available to upgrade for command N. For example, `$pkgcount0`
|
||||
* tag `$customN` - returns output for custom command N. For example, `$custom0`
|
||||
|
||||
Label order will changed if you change slider position. HTML tags in label work normally.
|
||||
|
||||
**NOTE** you don't may set to show `$cpu` tag in swap label for example. **`$cpu` will work only in cpu label**.
|
||||
|
||||
Tips & tricks
|
||||
-------------
|
||||
|
||||
You may use different colors for labels. Just put label text into html code. See [issue](https://github.com/arcan1s/pytextmonitor/issues/9) for more details.
|
||||
|
||||
Numbering of elements of temperature, HDD usage, HDD speed, HDD temperature refers to elements order from second tab (*Advanced settings*). You should add item to the required listWidget first. And the first element in the listWidget will be `$tag0`. See [issue](https://github.com/arcan1s/pytextmonitor/issues/17) for more details.
|
||||
|
||||
Advanced settings
|
||||
-----------------
|
||||
|
||||
**Vertical layout**
|
||||
|
||||
Use vertical layout instead of horizontal one.
|
||||
|
||||
**Enable popup**
|
||||
|
||||
Uncheck box if you do not use popup messages.
|
||||
|
||||
**Add stretch**
|
||||
|
||||
Add stretch (spacer) to the selected side of the widget.
|
||||
|
||||
**Custom time**
|
||||
|
||||
* tag `$dddd` - weekday in long format
|
||||
* tag `$ddd` - weekday in short format
|
||||
* tag `$dd` - day
|
||||
* tag `$d` - day without zero
|
||||
* tag `$MMMM` - month in long format
|
||||
* tag `$MMM` - month in short format
|
||||
* tag `$MM` - month
|
||||
* tag `$M` - month without zero
|
||||
* tag `$yyyy` - year
|
||||
* tag `$yy` - year in short format
|
||||
* tag `$hh` - hours
|
||||
* tag `$h` - hours without zero
|
||||
* tag `$mm` - minutes
|
||||
* tag `$m` - minutes without zero
|
||||
* tag `$ss` - seconds
|
||||
* tag `$s` - seconds without zero
|
||||
|
||||
**Custom uptime**
|
||||
|
||||
* tag `$dd` - uptime days
|
||||
* tag `$d` - uptime days without zero
|
||||
* tag `$hh` - uptime hours
|
||||
* tag `$h` - uptime hours without zero
|
||||
* tag `$mm` - uptime minutes
|
||||
* tag `$m` - uptime minutes without zero
|
||||
|
||||
**Temperature units**
|
||||
|
||||
Select units for temperature. Available units are Celsius, Farenheit and Kelvin.
|
||||
|
||||
**Temperature devices**
|
||||
|
||||
List of devices, which will be observed in temp label (combo box items come from `sensors`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**Mount points**
|
||||
|
||||
List of mount points, which will be observed in hdd label (combo box items come from `mount`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**HDD (speed)**
|
||||
|
||||
List of hard disk devices, which will be observed in hddspeed label (combo box items come from DataEngine). List widget is editable, delete key will remove current item.
|
||||
|
||||
**HDD (temperature)**
|
||||
|
||||
List of hard disk devices, which will be observed in hddtemp label (combo box items come from `find`). List widget is editable, delete key will remove current item.
|
||||
|
||||
**Network directory**
|
||||
|
||||
Path to directory, which contains network devices information. Default is `/sys/class/net`. Required for auto select network device.
|
||||
|
||||
**Network device**
|
||||
|
||||
Use specified device as active. Combo box items come from **network directory**. Will disable auto select network device.
|
||||
|
||||
**Battery device**
|
||||
|
||||
File with battery information. File (`/sys/class/power_supply/BAT0/capacity` by default) should contain only battery charge in percent.
|
||||
|
||||
**AC online tag**
|
||||
|
||||
Line which will be shown when AC is online.
|
||||
|
||||
**AC offline tag**
|
||||
|
||||
Line which will be shown when AC is offline.
|
||||
|
||||
**AC device**
|
||||
|
||||
File with AC information. File (`/sys/class/power_supply/AC/online` by default) must contain `1` if AC is online.
|
||||
|
||||
Tooltip settings
|
||||
----------------
|
||||
|
||||
Since version 1.7.0 CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make the needed checkboxes a fully checked. The number of stored values can be set in the tab. Colors of graphs are configurable too.
|
||||
|
||||
DataEngine settings
|
||||
-------------------
|
||||
|
||||
**Custom command**
|
||||
|
||||
*NOTE* This can cause the computer freeze.
|
||||
|
||||
Commands, which will be run for custom label.
|
||||
|
||||
**GPU device**
|
||||
|
||||
Select one of supported GPU devices. `auto` will enable auto selection, `disable` will disable definition of GPU states. Default is `auto`.
|
||||
|
||||
**HDD**
|
||||
|
||||
Select one of HDDs for HDD temperature monitor. `all` will enable monitor for all devices, `disable` will disable definition of HDD temperature. Default is `all`.
|
||||
|
||||
**hddtemp cmd**
|
||||
|
||||
Type a command which will be run for hddtemp DataEngine. Default is `sudo hddtemp`.
|
||||
|
||||
**MPD address**
|
||||
|
||||
Address of MPD server. Default is `localhost`.
|
||||
|
||||
**MPD port**
|
||||
|
||||
Port of MPD server. Default is `6600`.
|
||||
|
||||
**Package manager**
|
||||
|
||||
List of commands, which will be run. Number of null lines is a number of unneeded lines. Defaults:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Music player**
|
||||
|
||||
Select one of supported music playes for player label.
|
||||
|
||||
DataEngine configuration
|
||||
------------------------
|
||||
|
||||
You may edit DataEngine configuration. It is `/usr/share/config/extsysmon.conf` or `$HOME/share/config/extsysmon.conf` depending on the type of installation. Uncomment needed line and edit it.
|
||||
|
||||
Instruction
|
||||
===========
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*for definition temperature device*)
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* sysstat (*for notification*)
|
||||
* proprietary video driver
|
||||
* hddtemp (make sure that it may be run with `sudo` without password. Just add following line to `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* music player (amarok, clementine, mpd or qmmp)
|
||||
|
||||
Make dependencies
|
||||
-----------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
* download sources
|
||||
* install
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
Also you may install it to `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
make && sudo make install
|
||||
|
||||
Additional information
|
||||
======================
|
||||
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/) package
|
245
md_readme/es.md
@ -1,245 +0,0 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
|
||||
Información
|
||||
-----------
|
||||
PyTextMonitor es un plasmoide minimalista escrito en Python2. Luce como los componentes visuales de awesome-wm.
|
||||
|
||||
**NOTA** [¡Se buscan traductores!](https://github.com/arcan1s/pytextmonitor/issues/14)
|
||||
|
||||
Configuración
|
||||
-------------
|
||||
|
||||
Para editar la visualización debes abrir la ventana de Ajustes y establecer el formato de visualización en líneas:
|
||||
|
||||
* etiqueta `$time` - hora en formato por defecto. Por ejemplo, *vie 06 Nov 04:48:01 2013*
|
||||
* etiqueta `$isotime` - hora en formato ISO
|
||||
* etiqueta `$shorttime` - hora en formato local corto
|
||||
* etiqueta `$longtime` - hora en formato local largo
|
||||
* etiqueta `$custom` - formato de hora personalizado
|
||||
* etiqueta `$uptime` - tiempo de actividad del sistema, *---d--h--m*
|
||||
* etiqueta `$custom` - formato personalizado del tiempo de actividad del sistema
|
||||
* etiqueta `$cpu` - carga total de la CPU, *%*
|
||||
* etiqueta `$cpuN` - carga de la CPU para el núcleo N, *%*
|
||||
* etiqueta `$cpucl` - frecuencia promedio de la CPU, *MHz*
|
||||
* etiqueta `$cpuclN` - frecuencia de la CPU para el núcleo N, *MHz*
|
||||
* etiqueta `$tempN` - temperatura para el dispositivo N. Por ejemplo, `$temp0`
|
||||
* etiqueta `$gpu` - uso de la GPU, *%*. Debe estar instalado `aticonfig` o `nvidia-smi`
|
||||
* etiqueta `$gputemp` - temperatura de la GPU. Debe estar instalado `aticonfig` o `nvidia-smi`
|
||||
* etiqueta `$mem` - uso de la memoria, *%*
|
||||
* etiqueta `$memmb` - uso de la memoria, *MB*
|
||||
* etiqueta `$memgb` - uso de la memoria, *GB*
|
||||
* etiqueta `$memtotmb` - uso total de memoria, *MB*
|
||||
* etiqueta `$memtotgb` - uso total de memoria, *GB*
|
||||
* etiqueta `$swap` - swap, *%*
|
||||
* etiqueta `$swapmb` - swap, *MB*
|
||||
* etiqueta `$swapgb` - swap, *GB*
|
||||
* etiqueta `$swaptotmb` - uso total de swap, *MB*
|
||||
* etiqueta `$swaptotgb` - uso total de swap, *GB*
|
||||
* etiqueta `$hddN` - uso para el punto de montaje N, *%*. Por ejemplo, `$hdd0`
|
||||
* etiqueta `$hddmbN` - uso para el punto de montaje N, *MB*. Por ejemplo, `$hddmb0`
|
||||
* etiqueta `$hddgbN` - uso para el punto de montaje N, *GB*. Por ejemplo, `$hddgb0`
|
||||
* etiqueta `$hddtotmbN` - tamaño completo del punto de montaje N, *MB*. Por ejemplo, `$hddtotmb0`
|
||||
* etiqueta `$hddtotgbN` - tamaño completo del punto de montaje N, *GB*. Por ejemplo, `$hddtotgb0`
|
||||
* etiqueta `$hddrN` - leer la velocidad del disco N, *KB/s*. Por ejemplo, `$hddr0`
|
||||
* etiqueta `$hddwN` - velocidad de escritura del disco N, *KB/s*. Por ejemplo: `$hddw0`
|
||||
* etiqueta `$hddtempN` - temperatura para el disco duro N. Por ejemplo, `$hddtemp0`
|
||||
|
||||
**NOTA** no puedes establecer la etiqueta `$cpu` para que se muestre en la información de la swap, por citar un ejemplo. **`$cpu` solo funcionará en la etiqueta de la CPU**.
|
||||
|
||||
Trucos
|
||||
------
|
||||
|
||||
Es posible usar diferentes colores para las etiquetas. Solo tienes que ponerles el texto en formato HTML. Para más detalles, ver [el tema](https://github.com/arcan1s/pytextmonitor/issues/9) relacionado.
|
||||
|
||||
La enumeración de los elementos de temperatura, uso del disco duro, velocidad del disco duro y la temperatura del disco duro, se refiere al orden de los elementos de la segunda pestaña (*Ajustes avanzados*). Primeramente deberías añadir el elemento a la lista requerida. El primer elemento de la lista será $tag0. Para más información, ver [el tema](https://github.com/arcan1s/pytextmonitor/issues/17) relacionado.
|
||||
|
||||
Ajustes avanzados
|
||||
-----------------
|
||||
|
||||
**Orientación vertical**
|
||||
|
||||
Usar la orientación vertical en lugar de la horizontal.
|
||||
|
||||
**Habilitar ventanas emergentes**
|
||||
|
||||
Desmarcar esta caja si no deseas usar ventanas emergentes.
|
||||
|
||||
**Añadir extensión**
|
||||
|
||||
Añadir extensión (espaciador) al lado seleccionado del widget.
|
||||
|
||||
**Hora personalizada**
|
||||
|
||||
* etiqueta `$dddd` - día de la semana en foramto largo
|
||||
* etiqueta `$ddd` - día de la semana en formato corto
|
||||
* etiqueta `$dd` - día
|
||||
* etiqueta `$d` - día sin ceros
|
||||
* etiqueta `$MMMM` - mes en formato largo
|
||||
* etiqueta `$MMM` - mes en formato corto
|
||||
* etiqueta `$MM` - mes
|
||||
* etiqueta `$M` - mes sin ceros
|
||||
* etiqueta `$yyyy` - año
|
||||
* etiqueta `$yy` - año en formato corto
|
||||
* etiqueta `$hh` - horas
|
||||
* etiqueta `$h` - horas sin ceros
|
||||
* etiqueta `$mm` - minutos
|
||||
* etiqueta `$m` - minutos sin ceros
|
||||
* etiqueta `$ss` - segundos
|
||||
* etiqueta `$s` - segundos sin ceros
|
||||
|
||||
**Tiempo de ejecución del sistema personalizado**
|
||||
|
||||
* etiqueta `$dd` - días
|
||||
* etiqueta `$d` - días sin ceros
|
||||
* etiqueta `$hh` - horas
|
||||
* etiqueta `$h` - horas sin ceros
|
||||
* etiqueta `$mm` - minutos
|
||||
* etiqueta `$m` - minutos sin ceros
|
||||
|
||||
**Unidades de temperatura**
|
||||
|
||||
Elija las unidades de temperatura. Las unidades disponibles son: Celsius, Farenheit y Kelvin.
|
||||
|
||||
**Dispositivos de temperatura**
|
||||
|
||||
El listado de dispositivos, será observado en la etiqueta de temperatura (los elementos de la lista desplegable provienen de `sensors`). El listado es editable, la tecla Suprimir borrará el elemento activo.
|
||||
|
||||
**Puntos de montaje**
|
||||
|
||||
El listado de puntos de montaje, será observado en la etiqueta de disco duro (los elementos de la lista desplegable provienen de `mount`). El listado es editable, la tecla Suprimir borrará el elemento activo.
|
||||
|
||||
**Disco duro (velocidad)**
|
||||
|
||||
Listado de dispositivos de disco duro, será observado en la etiqueta hddspeed (los elementos de la lista desplegable provienen de DataEngine).
|
||||
|
||||
**Disco duro (temperatura)**
|
||||
|
||||
El listado de dispositivos de disco duro, será observado desde la etiqueta disco duro (los elementos de la lista desplegable provienen de `find`). El listado es editable, la tecla Suprimir borrará el elemento activo.
|
||||
|
||||
**Directorio de red**
|
||||
|
||||
Ruta hacia el directorio que contiene información de los dispositivos de red. Por defecto es `/sys/class/net`. Se requiere para la selección automática del dispositivo de red.
|
||||
|
||||
**Dispositivo de red**
|
||||
|
||||
Usar el dispositivo especificado como activo. Los elementos de la lista desplegable provienen del **directorio de red**. Esto inhabilitará la selección automática del dispositivo de red.
|
||||
|
||||
**Dispositivo de batería**
|
||||
|
||||
El archivo que contiene información de la batería. El archivo (`/sys/class/power_supply/BAT0/capacity` por defecto) solo debería contener la carga de la batería en por ciento.
|
||||
|
||||
**Etiqueta alimentación conectada**
|
||||
|
||||
Línea que será mostrada cuando la alimentación esté conectada.
|
||||
|
||||
**Etiqueta alimentación conectada**
|
||||
|
||||
Línea que será mostrada cuando la alimentación esté desconectada.
|
||||
|
||||
**Dispositivo de alimentación**
|
||||
|
||||
El archivo con información de la alimentación. El archivo (`/sys/class/power_supply/AC/online` por defecto) debe contener `1` si la alimentación está conectada.
|
||||
|
||||
Ajustes de las ventanas emergentes
|
||||
----------------------------------
|
||||
|
||||
Desde la versión 1.7.0 las etiquetas CPU, frecuencia de la CPU, memoria, swap y red soportan ventanas emergentes. Para habilitarlas es necesario tener marcadas las casillas de verificación pertinentes. El número de valores almacenados puede ser establecido en la pestaña. También es posible configurar los colores de los gráficos.
|
||||
|
||||
Ajustes de DataEngine
|
||||
---------------------
|
||||
|
||||
**Comando personalizado**
|
||||
|
||||
*NOTA* Esto puede causar congelamiento de la computadora.
|
||||
|
||||
**Dispositivo GPU**
|
||||
|
||||
Elegir uno de los dispositivos GPU soportados. `auto` habilitará la selección automática, `disable` inhabilitará la definición de los estados de la GPU. El valor por defecto es `auto`.
|
||||
|
||||
**Disco duro**
|
||||
|
||||
Elegir uno de los discos duros para el monitor de temperatura del disco. `all` habilitará el monitor para todos los dispositivos, `disable` inhabilitará la definición de la temperatura del disco. El valor por defecto es `all`.
|
||||
|
||||
**Comando hddtemp**
|
||||
|
||||
Escriba el comando que será ejecutado por el DataEngine hddtemp. El valor por defecto es `sudo hddtemp`.
|
||||
|
||||
**Dirección MPD**
|
||||
|
||||
Dirección del servidor MPD. El valor por defecto es `localhost`.
|
||||
|
||||
**Puerto MPD**
|
||||
|
||||
Puerto del servidor MPD. El valor por defecto es `6600`.
|
||||
|
||||
**Gestor de paquetes**
|
||||
|
||||
Listado de comandos que serán ejecutados. La cantidad de líneas nulas es el número de líneas innecesarias. Predeterminados:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Reproductor de música**
|
||||
|
||||
Selecciona uno de los reproductores de música soportados para la etiqueta del reproductor.
|
||||
|
||||
Configuración de DataEngine
|
||||
---------------------------
|
||||
Se puede editar la configuración de DataEngine. Se encuentra en `/usr/share/config/extsysmon.conf` o `$HOME/share/config/extsysmon.conf` en dependencia del tipo de instalación. Quitar el comentario de la línea requerida y editarlo.
|
||||
|
||||
Instrucción
|
||||
===========
|
||||
|
||||
Dependencias
|
||||
------------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*para definir el dispositivo de temperatura*)
|
||||
|
||||
Dependencias opcionales
|
||||
-----------------------
|
||||
|
||||
* sysstat (*para las notificaciones*)
|
||||
* controlador propietario de video
|
||||
* hddtemp (asegúrate de que puede ser ejecutado con `sudo` y sin contraseña. Solo hay que agregar la siguiente línea al archivo `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* reproductor de música (amarok, clementine, mpd o qmmp)
|
||||
|
||||
Dependencias de construcción
|
||||
----------------------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Instalación
|
||||
-----------
|
||||
* descargar fuentes
|
||||
* instalar
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
También es posible instalarlo en `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
make && sudo make install
|
||||
|
||||
Información adicional
|
||||
=====================
|
||||
|
||||
TODO (funcionalidades solicitadas)
|
||||
----------------------------------
|
||||
|
||||
Enlaces
|
||||
-----
|
||||
* [Sitio oficial](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Plasmoide en [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* DataEngine en [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/) package
|
@ -1,268 +0,0 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
|
||||
Informação
|
||||
-----------
|
||||
|
||||
PyTextMonitor é um script Plasmoid escrito em Python2. Assemelha-se com widgets no awesome-wm.
|
||||
|
||||
**NOTA** [PROCURA_SE TRADUTORES!](https://github.com/arcan1s/pytextmonitou/issues/14)
|
||||
|
||||
Configuração
|
||||
------------
|
||||
|
||||
Para editar o output, você deve abrir a janela de Configurações e configurar o formato de output na linhas:
|
||||
|
||||
* tag `$time` - hora no formato padrão. Por exemplo, *sex Nov 6 04:48:01 2013*
|
||||
* tag `$isotime` - hora no formato ISO.
|
||||
* tag `$shouttime` - hora em formato curto
|
||||
* tag `$longtime` - hora em formato longo
|
||||
* tag `$custom` - formato personalizado de houa
|
||||
* tag `$uptime` - tempo em atividade, *---d--h--m*
|
||||
* tag `$custom` - formato personalizado de tempo em atividade
|
||||
* tag `$cpu` - carga total da CPU, *%*
|
||||
* tag `$cpuN` - carga total da CPU no núcleo N, *%*
|
||||
* tag `$cpucl` - frequência média da CPU, *MHz*
|
||||
* tag `$cpuclN` - frequência do núcleo N da CPU, *MHz*
|
||||
* tag `$tempN` - temperatura do dispositivo N. Por exemplo, `$temp0`
|
||||
* tag `$gpu` - uso da GPU, *%*. `aticonfig` ou `nvidia-smi` devem estar instalados
|
||||
* tag `$gputemp` - temperatura da GPU. `aticonfig` ou `nvidia-smi` devem estar instalados
|
||||
* tag `$mem` - uso de memória, *%*
|
||||
* tag `$memmb` - uso de memória, *MB*
|
||||
* tag `$memgb` - uso de memória, *GB*
|
||||
* tag `$memtotmb` - RAM total, *MB*
|
||||
* tag `$memtotgb` - RAM total, *GB*
|
||||
* tag `$swap` - swap, *%*
|
||||
* tag `$swapmb` - swap, *MB*
|
||||
* tag `$swapgb` - swap, *GB*
|
||||
* tag `$swaptotmb` - swap total, *MB*
|
||||
* tag `$swaptotgb` - swap total, *GB*
|
||||
* tag `$hddN` - uso do ponto de montagem N, *%*. Pou exemplo, `$hdd0`
|
||||
* tag `$hddmbN` - uso do ponto de montagem, *MB*. Por exemplo, `$hddmb0`
|
||||
* tag `$hddgbN` - uso do ponto de montagem, *GB*. Por exemplo, `$hddgb0`
|
||||
* tag `$hddtotmbN` - tamanho total do ponto de montagem N, *MB*. Por exemplo, `$hddtotmb0`
|
||||
* tag `$hddtotgbN` - tamanho total do ponto de montagem N,, *GB*. Por exemplo, `$hddtotgb0`
|
||||
* tag `$hddrN` - velocidade de leitura do disco N, *KB/s*. Por exemplo, `$hddr0`
|
||||
* tag `$hddwN` - velocidade de escrita do disco N, *KB/s*. Por exemplo, `$hddw0`
|
||||
* tag `$hddtempN` - temperatura do HDD N. Por exemplo, `$hddtemp0`
|
||||
* tag `$down` - velocidade de download, *KB/s*
|
||||
* tag `$up` - velocidade de upload, *KB/s*
|
||||
* tag `$netdev` - dispositivo atual de rede
|
||||
* tag `$bat` - carga da bateria, *%*
|
||||
* tag `$ac` - status do dispositivo carregador. Retorna (\*) se o carregador estiver plugado ou *( )* se estiver desplugado
|
||||
* tag `$album` - álbum da música atual . Um dos reprodutores de músicas suportados deve estar instalado
|
||||
* tag `$artist` - artista da música atual. Um dos reprodutores de músicas suportados deve estar instalado
|
||||
* tag `$progress` - progresso da música atual. Um dos reprodutores de músicas suportados deve estar instalado
|
||||
* tag `$time` - tempo da música atual. Um dos reprodutores de músicas suportados deve estar instalado
|
||||
* tag `$title` - título da música atual. Um dos reprodutores de músicas suportados deve estar instalado
|
||||
* tag `$pscount` - número de processos rodando
|
||||
* tag `$pstotal` - número total de processos
|
||||
* tag `$ps` - lista de processos rodando
|
||||
* tag `$pkgcountN` - número de pacotes disponíveis para atualizar pelo comando N available to upgrade. Por exemplo, `$pkgcount0`
|
||||
* tag `$customN` - retorna o output do comando N. Por exemplo, `$custom0`
|
||||
|
||||
A ordem dos rótulos mudará se você mudar a posição do slider. Tags HTML funcionarão normalmente.
|
||||
|
||||
**NOTA** você não deve usar a tag `$cpu` no rótulo de swap, por exemplo. **`$cpu` somente funcionará no rótulo da cpu**.
|
||||
|
||||
Dicas & truques
|
||||
---------------
|
||||
|
||||
Você pode usar cores diferentes para os rótulos. Só coloque o texto do rótulo em código HTML. Veja este [issue](https://github.com/arcan1s/pytextmonitor/issues/9) para mais detalhes.
|
||||
|
||||
A numeração dos elementos de temperatura, uso de HDD, velocidade do HDD, temperatura do HDD refere à ordem dos elementos da segunda aba (*Configurações Avançadas*). Você deve adicionar o item para a lista requerida listWidget primeiro. E o primeiro elemento na listWidget será `$tag0`. Veja este [issue](https://github.com/arcan1s/pytextmonitor/issues/17) para mais detalhes.
|
||||
|
||||
Configurações Avançadas
|
||||
-----------------------
|
||||
|
||||
**Layout vertical**
|
||||
|
||||
Use o layout vertical ao invés do horizontal.
|
||||
|
||||
**Habilitar popup**
|
||||
|
||||
Desmarque esta caixa se não quiser usar mensagens popup
|
||||
|
||||
**Adicionar esticamento**
|
||||
|
||||
Adicionar esticamento (espaço) para o lado selecionado do widget.
|
||||
|
||||
**Hora customizada**
|
||||
|
||||
* tag `$dddd` - dia da semana em formato completo
|
||||
* tag `$ddd` - dia da semana em format curto
|
||||
* tag `$dd` - dia
|
||||
* tag `$d` - dia sem zeros
|
||||
* tag `$MMMM` - mês em formato completo
|
||||
* tag `$MMM` - mês em formato curto
|
||||
* tag `$MM` - mês
|
||||
* tag `$M` - mês sem zeros
|
||||
* tag `$yyyy` - ano
|
||||
* tag `$yy` - ano em formato curto
|
||||
* tag `$hh` - horas
|
||||
* tag `$h` - horas sem zeros
|
||||
* tag `$mm` - minutos
|
||||
* tag `$m` - minutos sem zeros
|
||||
* tag `$ss` - segundos
|
||||
* tag `$s` - segundos sem zeros
|
||||
|
||||
**Tempo em Atividade personalizado**
|
||||
|
||||
* tag `$dd` - tempo em atividade em dias
|
||||
* tag `$d` - tempo em atividade em dias sem zeros
|
||||
* tag `$hh` - tempo em atividade em horas
|
||||
* tag `$h` - tempo em atividade em horas sem zeros
|
||||
* tag `$mm` - tempo em atividade em minutos
|
||||
* tag `$m` - tempo em atividade em minutos sem zeros
|
||||
|
||||
**Unidades de Temperatura**
|
||||
|
||||
Seleciona as unidades de temperatura. Unidades disponíveis são Celsius, Farenheit e Kelvin.
|
||||
|
||||
**Dispositivos de Temperatura**
|
||||
|
||||
Lista de dispositovos, a serem observados no rótulo de temperatura (os itens de seleção vêm do `sensors`). A lista de widgets é editável, a tecla delete removerá o item selecionado.
|
||||
|
||||
**Pontos de Montagem**
|
||||
|
||||
Lista de pontos de montagem, a serem observados no rótulo de hdd (os itens de seleção vêm do `mount`). A lista de widgets é editável, a tecla delete removerá o item selecionado.
|
||||
|
||||
**HDD (velocidade)**
|
||||
|
||||
Lista de dispositivos HDD, a serem observados no rótulo de hddspeed (os itens de seleção vêm do DataEngine). A lista de widgets é editável, a tecla delete removerá o item selecionado.
|
||||
|
||||
**HDD (temperatura)**
|
||||
|
||||
Lista de dispositivos HDD, a serem observados no rótulo de hddtemp (os itens de seleção vêm do `find`). A lista de widgets é editável, a tecla delete removerá o item selecionado.
|
||||
|
||||
**Diretório de rede**
|
||||
|
||||
Caminho para o diretório, que contém a informação dos dispositivos de rede. O padrão é `/sys/class/net`. Requerido para seleção automática de dispositivo de rede.
|
||||
|
||||
**Dispositivo de rede**
|
||||
|
||||
Usa o dispositivo especificado como ativo. Os itens de seleção vêm do **diretório de rede**. Desativará a seleção automática do dispositivo de rede.
|
||||
|
||||
**Dispositivo de bateria**
|
||||
|
||||
Arquivo com informações da bateria. O arquivo (`/sys/class/power_supply/BAT0/capacity` por padrão) deve conter somente a carga da bateria em porcentagem.
|
||||
|
||||
**Tag do carregador plugado**
|
||||
|
||||
Linha a ser mostrada quando o carregador está plugado.
|
||||
|
||||
**Tag do carregador desplugado**
|
||||
|
||||
Linha a ser mostrada quando o carregador está desplugado.
|
||||
|
||||
**Dispositivo carregador**
|
||||
|
||||
Arquivo com informações do carregador. O arquivo (`/sys/class/power_supply/AC/online` por padrão) deve conter `1` se o carregador estiver plugado.
|
||||
|
||||
Configurações da dica de contexto
|
||||
---------------------------------
|
||||
|
||||
Desde a versão 1.7.0, os rótulos de CPU, frequência da CPU, memória, swap e rede suportam dica de contexto gráfica. Para ativar, certifique-se de ter marcado as caixas necessárias. O número de valores armazenados pode ser configurado nesta aba. Cores de gráficos também são configuráveis.
|
||||
|
||||
Configurações de DataEngine
|
||||
---------------------------
|
||||
|
||||
**Comando personalizado**
|
||||
|
||||
*NOTA* Isso pode travar o seu computador.
|
||||
|
||||
Comandos que serão executados para o rótulo personalizado.
|
||||
|
||||
**Dispositivo GPU**
|
||||
|
||||
Seleciona um dos dispositivos GPU sportador. `auto` ativará a seleção automática, `disable` desativará a definição dos estados de GPU. O padrão é `auto`.
|
||||
|
||||
**HDD**
|
||||
|
||||
Seleciona um dos HDDs para o monitor de temperatura do HDD. `all` ativará o monitoramento de todos dispositivos, `disable` desativará o monitoramento para todos dispositivos. O padrão é `all`.
|
||||
|
||||
**hddtemp cmd**
|
||||
|
||||
Digite um comando que será executado para o hddtemp DataEngine. O padrão é `sudo hddtemp`.
|
||||
|
||||
**Endereço MPD**
|
||||
|
||||
Endereço do servidor MPD. O padrão é `localhost`.
|
||||
|
||||
**Porta MPD**
|
||||
|
||||
Porta do servidor MPD. O padrão é `6600`.
|
||||
|
||||
**Gerenciador de pacotes**
|
||||
|
||||
Lista de comandos a serem executador. O número de linhas nulas é o número de linhas desnecessárias. Por padrão:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Reprodutor de música**
|
||||
|
||||
Selecione um dos reprodutores de música suportados para o rótulo de música.
|
||||
|
||||
Configuração do DataEngine
|
||||
--------------------------
|
||||
|
||||
Você pode editar a configuração do DataEngine. Ela está em `/usr/share/config/extsysmon.conf` ou `$HOME/share/config/extsysmon.conf` dependendo do tipo de instalação. Remova os comentários das linhas necessárias e edite-as.
|
||||
|
||||
Instruções
|
||||
==========
|
||||
|
||||
Dependências
|
||||
------------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*para definir a temperatura dos dispositivos*)
|
||||
|
||||
Dependências opcionais
|
||||
----------------------
|
||||
|
||||
* sysstat (*para notificações*)
|
||||
* driver de vídeo proprietário
|
||||
* hddtemp (certifique-se de que pode ser executado com `sudo` sem senha. Para isso, adicione a seguinte linha ao arquivo `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* music player (amarok, clementine, mpd or qmmp)
|
||||
|
||||
Dependências para compilar
|
||||
--------------------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Instalação
|
||||
----------
|
||||
|
||||
* baixe o código-fonte
|
||||
* instale
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
Caso queira instalar na `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
make && sudo make install
|
||||
|
||||
Informações adicionais
|
||||
======================
|
||||
|
||||
TODO (lista de desejos)
|
||||
-----------------------
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Plasmoid na [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* DataEngine na [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Pacote para ArchLinux no [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/)
|
268
md_readme/ru.md
@ -1,268 +0,0 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
|
||||
Информация
|
||||
----------
|
||||
|
||||
PyTextMonitor - минималистичный плазмоид, написанный на Python2. Он выглядит как виджеты в Awesome WM.
|
||||
|
||||
**ВНИМАНИЕ** [НУЖНЫ ПЕРЕВОДЧИКИ!](https://github.com/arcan1s/pytextmonitor/issues/14)
|
||||
|
||||
Настройка
|
||||
---------
|
||||
|
||||
Для редактирования внешнего вида, откройте окно настроек и установите требуемый формат в поля:
|
||||
|
||||
* тег `$time` - время в стандартном формате. Например, *fri Nov 6 04:48:01 2013*
|
||||
* тег `$isotime` - время в ISO формате
|
||||
* тег `$shorttime` - время в коротком формате
|
||||
* тег `$longtime` - время в длинном формате
|
||||
* тег `$custom` - свой формат времени
|
||||
* тег `$uptime` - время работы, *---d--h--m*
|
||||
* тег `$custom` - свой формат аптайма
|
||||
* тег `$cpu` - общая загрузка CPU, *%*
|
||||
* тег `$cpuN` - загрузка CPU для ядра N, *%*
|
||||
* тег `$cpucl` - средняя частота CPU, *MHz*
|
||||
* тег `$cpuclN` - частота CPU для ядра N, *MHz
|
||||
* тег `$tempN` - температура для устройства N. Например, `$temp0`
|
||||
* тег `$gpu` - использование GPU, *%*. `aticonfig` или `nvidia-smi` должны быть установлены
|
||||
* тег `$gputemp` - температура GPU. `aticonfig` или `nvidia-smi` должны быть установлены
|
||||
* тег `$mem` - использование RAM, *%*
|
||||
* тег `$memmb` - использование RAM, *MB*
|
||||
* тег `$memgb` - использование RAM, *GB*
|
||||
* тег `$memtotmb` - RAM, *MB*
|
||||
* тег `$memtotgb` - RAM, *GB*
|
||||
* тег `$swap` - swap, *%*
|
||||
* тег `$swapmb` - swap, *MB*
|
||||
* тег `$swapgb` - swap, *GB*
|
||||
* тег `$swaptotmb` - размер swap, *MB*
|
||||
* тег `$swaptotgb` - размер swap, *GB*
|
||||
* тег `$hddN` - использование точки монтирования N, *%*. Например, `$hdd0`
|
||||
* тег `$hddmbN` - использование точки монтирования N, *MB*. Например, `$hddmb0`
|
||||
* тег `$hddgbN` - использование точки монтирования N, *GB*. Например, `$hddgb0`
|
||||
* тег `$hddtotmbN` - размер точки монтирования N, *MB*. Например, `$hddtotmb0`
|
||||
* тег `$hddtotgbN` - размер точки монтирования N, *GB*. Например, `$hddtotgb0`
|
||||
* тег `$hddrN` - скорость записи на диск N, *KB/s*. Например, `$hddr0`
|
||||
* тег `$hddwN` - скорость чтения с диска N, *KB/s*. Например, `$hddw0`
|
||||
* тег `$hddtempN` - температура HDD N. Например, `$hddtemp0`
|
||||
* тег `$down` - скорость загрузки, *KB/s*
|
||||
* тег `$up` - скорость отдачи, *KB/s*
|
||||
* тег `$netdev` - текущий сетевой интерфейс
|
||||
* тег `$bat` - заряд батареи, *%*
|
||||
* тег `$ac` - статус адаптера питания. Возвращает (\*), если AC подключен или *( )*, если нет
|
||||
* тег `$album` - альбом. Один из поддерживаемых плееров должен быть установлен
|
||||
* тег `$artist` - исполнитель. Один из поддерживаемых плееров должен быть установлен
|
||||
* тег `$progress` - прогресс. Один из поддерживаемых плееров должен быть установлен
|
||||
* тег `$time` - длительность. Один из поддерживаемых плееров должен быть установлен
|
||||
* тег `$title` - название. Один из поддерживаемых плееров должен быть установлен
|
||||
* тег `$pscount` - число запущенных процессов
|
||||
* тег `$pstotal` - общее число процессов
|
||||
* тег `$ps` - список процессов
|
||||
* тег `$pkgcountN` - число пакетов, которые могут быть обновлены, для команды N. Например, `$pkgcount0`
|
||||
* тег `$customN` - возвращает результат своей команды N. Например, `$custom0`
|
||||
|
||||
Порядок полей изменится, если вы измените позицию слайдеров. HTML теги в полях работают корректно.
|
||||
|
||||
**ЗАМЕЧАНИЕ** вы не можете установить тег `$cpu`, например, в поле swap. **`$cpu` будет работать только в поле CPU**.
|
||||
|
||||
Советы и хитрости
|
||||
-----------------
|
||||
|
||||
Вы можете использовать различные цвета в полях. Просто вставьте нужный текст в html код. Смотри [вопрос](https://github.com/arcan1s/pytextmonitor/issues/9) для более подробной информации.
|
||||
|
||||
Нумерация элементов в полях "Температура", "Использование HDD", "Скорость HDD", "Температура HDD" ссылается на порядок элементов во второй вкладке (*Расширенные настройки*). Вы должны сначала добавить требуемые элементы в нужный listWidget. И первый элемент в listWdiget будет связан c `$tag0`. Смотри [вопрос](https://github.com/arcan1s/pytextmonitor/issues/17) для более подробной информации.
|
||||
|
||||
Расширенные настройки
|
||||
---------------------
|
||||
|
||||
**Вертикальная разметка**
|
||||
|
||||
Использовать вертикальную разметку вместо горизонтальной.
|
||||
|
||||
**Включить всплывающие сообщения**
|
||||
|
||||
Нажмите на чекбокс, если вы не используете всплывающие сообщения.
|
||||
|
||||
**Добавить пустое пространство**
|
||||
|
||||
Добавить пустое пространство в указанное место виджета.
|
||||
|
||||
**Свой формат времени**
|
||||
|
||||
* тег `$dddd` - день недели в длинном формате
|
||||
* тег `$ddd` - день недели в коротком формате
|
||||
* тег `$dd` - день
|
||||
* тег `$d` - день без нуля
|
||||
* тег `$MMMM` - месяц в длинном формате
|
||||
* тег `$MMM` - месяц в коротком формате
|
||||
* тег `$MM` - месяц
|
||||
* тег `$M` - месяц без нуля
|
||||
* тег `$yyyy` - год
|
||||
* тег `$yy` - год в коротком формате
|
||||
* тег `$hh` - часы
|
||||
* тег `$h` - часы без нуля
|
||||
* тег `$mm` - минуты
|
||||
* тег `$m` - минуты без нуля
|
||||
* тег `$ss` - секунды
|
||||
* тег `$s` - секунды без нуля
|
||||
|
||||
**Свой формат аптайма**
|
||||
|
||||
* тег `$dd` - дни аптайма
|
||||
* тег `$d` - дни аптайма без нуля
|
||||
* тег `$hh` - часы аптайма
|
||||
* тег `$h` - часы аптайма без нуля
|
||||
* тег `$mm` - минуты аптайма
|
||||
* тег `$m` - минуты аптайма без нуля
|
||||
|
||||
**Температурные единицы**
|
||||
|
||||
Выберите единицы температуры. Доступные единицы следующие: Цельсий, Фаренгейт и Кельвин.
|
||||
|
||||
**Датчики температуры**
|
||||
|
||||
Список датчиков, которые будут наблюдаться в поле temo (содержимое комбо бокса берется из `sensors`). Виджет редактируем, клавиша delete удалит текущую строку.
|
||||
|
||||
**Точки монтирования**
|
||||
|
||||
Список точек монтирования, которые будут наблюдаться в поле hdd (содержимое комбо бокса берется из `mount`). Виджет редактируем, клавиша delete удалит текущую строку.
|
||||
|
||||
**HDD (скорость)**
|
||||
|
||||
Список HDD, которые будут наблюдаться в поле hddspeed (содержимое комбо бокса берется из DataEngine). Виджет редактируем, клавиша delete удалит текущую строку.
|
||||
|
||||
**HDD (температура)**
|
||||
|
||||
Список HDD, которые будут наблюдаться в поле hddtemp (содержимое комбо бокса берется из `find`). Виджет редактируем, клавиша delete удалит текущую строку.
|
||||
|
||||
**Директория с сетевыми интерфейсами**
|
||||
|
||||
Путь к директории, которая содержит информацию о сетевых интерфейсах. По умолчанию `/sys/class/net`. Требуется для определения сетевого устройства.
|
||||
|
||||
**Сетевое устройство**
|
||||
|
||||
Использовать указанный интерфейс, как активный. Содержимое комбо бокса берется из **директории с сетевыми интерфейсами**. Эта опция отключит автоопределение интерфейса.
|
||||
|
||||
**Устройство батареи**
|
||||
|
||||
Файл с информацией о батарее. Данный файл (`/sys/class/power_supply/BAT0/capacity` по умолчанию) должен содержать только заряд батареи в процентах.
|
||||
|
||||
**AC online тег**
|
||||
|
||||
Строка, которая будет показана, когда AC онлайн.
|
||||
|
||||
**AC offline тег**
|
||||
|
||||
Строка, которая будет показана, когда AC оффлайн.
|
||||
|
||||
**Устройство AC**
|
||||
|
||||
Файл с информацией об адаптере питания. Данный файл (`/sys/class/power_supply/AC/online` по умолчанию) должен содержать `1`, если адаптер подключен.
|
||||
|
||||
Настройки тултипа
|
||||
-----------------
|
||||
|
||||
Начиная с версии 1.7.0 поля "CPU", "Частота CPU", "Память", "Swap" и "Сеть" поддерживают графический тултип. Чтобы включить их, просто сделайте требуемые чекбоксы полностью чекнутыми. Число хранимых значений может быть выставленно в данной вкладке. Цвета графиков также настраиваются.
|
||||
|
||||
Настройки DataEngine
|
||||
--------------------
|
||||
|
||||
**Своя команда**
|
||||
|
||||
*ЗАМЕЧАНИЕ* Может вызвать зависание компьютера.
|
||||
|
||||
Команды, которые будут запущены для соответствующего поля.
|
||||
|
||||
**Устройство GPU**
|
||||
|
||||
Выберите одно из поддерживаемых устройств GPU. `auto` включит автоматическое определение, `disable` отключит все мониторы GPU. По умолчанию `auto`.
|
||||
|
||||
**HDD**
|
||||
|
||||
Выберете один из HDD для монитора его температуры. `all` включит монитор для всех доступных устройств, `disable` отключит определение температуры HDD. По умолчанию `all`.
|
||||
|
||||
**Команда hddtemp**
|
||||
|
||||
Введите команду, которая будет запущена для hddtemp DataEngine. По умолчанию `sudo hddtemp`.
|
||||
|
||||
**Адрес MPD**
|
||||
|
||||
Адрес MPD сервера. По умолчанию `localhost`.
|
||||
|
||||
**Порт MPD**
|
||||
|
||||
Порт MPD сервера. По умолчанию `6600`.
|
||||
|
||||
**Package manager**
|
||||
|
||||
Список команд, которые будут запущены. Число пустых строк - число ненужных для подсчета строк. Стандартные настройки:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Музыкальный плеер**
|
||||
|
||||
Выберите один из поддерживаемых музыкальных плееров.
|
||||
|
||||
Настройка DataEngine
|
||||
--------------------
|
||||
|
||||
Вы можете отредактировать настройки DataEngine вручную. Откройте файл `/usr/share/config/extsysmon.conf` или `$HOME/.kde4/share/config/extsysmon.conf`, в зависимости от типа установки. Раскомментируйте требуемые строки и отредактируйте их.
|
||||
|
||||
Инструкция
|
||||
==========
|
||||
|
||||
Зависимости
|
||||
-----------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*для определения датчиков температуры*)
|
||||
|
||||
Опциональные зависимости
|
||||
------------------------
|
||||
|
||||
* sysstat (*для уведомлений*)
|
||||
* проприетарный видеодрайвер
|
||||
* hddtemp (убедитесь, что может быть запущен с `sudo` без пароля. Просто добавьте следующую строку в `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* музыкальный плеер (amarok, clementine, mpd или qmmp)
|
||||
|
||||
Зависимости сборки
|
||||
------------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Установка
|
||||
---------
|
||||
|
||||
* скачать исходный архив
|
||||
* установить
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
Для установки в `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
make && sudo make install
|
||||
|
||||
Дополнительная информация
|
||||
=========================
|
||||
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
Ссылки
|
||||
------
|
||||
|
||||
* [Домашняя страница](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Виджет на [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* DataEngine на [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Пакет для Archlinux в [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/)
|
263
md_readme/uk.md
@ -1,263 +0,0 @@
|
||||
pytextmonitor
|
||||
=============
|
||||
|
||||
Інформація
|
||||
----------
|
||||
|
||||
PyTextMonitor - мінімалістичний плазмоїд, що написаний на Python2. Він виглядає як віджети в Awesome WM.
|
||||
|
||||
**УВАГА** [ПОТРІБНІ ПЕРЕКЛАДАЧІ!](https://github.com/arcan1s/pytextmonitor/issues/14)
|
||||
|
||||
Налаштування
|
||||
------------
|
||||
|
||||
Для редагування зовнішного вигляду, відкрийте вікно налаштувань та встановіть потрібний формат в поля:
|
||||
|
||||
* тег `$time` - час у стандартному форматі. Наприклад, *fri Nov 6 04:48:01 2013*
|
||||
* тег `$isotime` - час в ISO форматі
|
||||
* тег `$shorttime` - час в короткому форматі
|
||||
* тег `$longtime` - час у довгому форматі
|
||||
* тег `$custom` - свій формат часу
|
||||
* тег `$uptime` - час роботи, *---d--h--m*
|
||||
* тег `$custom` - свій формат аптайму
|
||||
* тег `$cpu` - загальне завантаження CPU, *%*
|
||||
* тег `$cpuN` - завантаження CPU для ядра N, *%*
|
||||
* тег `$cpucl` - середня частота CPU, *MHz*
|
||||
* тег `$cpuclN` - частота CPU для ядра N, *MHz*
|
||||
* тег `$tempN` - температура для пристрою N. Наприклад, `$temp0`
|
||||
* тег `$gpu` - використання GPU, *%*. `aticonfig` або `nvidia-smi` мають бути встановлені
|
||||
* тег `$gputemp` - температура GPU. `aticonfig` або `nvidia-smi` мають бути встановлені
|
||||
* тег `$mem` - використання RAM, *%*
|
||||
* тег `$memmb` - використання RAM, *MB*
|
||||
* тег `$memgb` - використання RAM, *GB*
|
||||
* тег `$swap` - swap, *%*
|
||||
* тег `$swapmb` - swap, *MB*
|
||||
* тег `$swapgb` - swap, *GB*
|
||||
* тег `$swaptotmb` - розмір swap, *MB*
|
||||
* тег `$swaptotgb` - розмір swap, *GB*
|
||||
* тег `$hddN` - використання точки монтування N, *%*. Наприклад, `$hdd0`
|
||||
* тег `$hddmbN` - використання точки монтування N, *MB*. Наприклад, `$hddmb0`
|
||||
* тег `$hddgbN` - використання точки монтування N, *GB*. Наприклад, `$hddgb0`
|
||||
* тег `$hddtotmbN` - розмір точки монтування N, *MB*. Наприклад, `$hddtotmb0`
|
||||
* тег `$hddtotgbN` - розмір точки монтування N, *GB*. Наприклад, `$hddtotgb0`
|
||||
* тег `$hddrN` - швидкість запису на диск N, *KB/s*. Наприклад, `$hddr0`
|
||||
* тег `$hddwN` - швидкість читання з диска N, *KB/s*. Наприклад, `$hddw0`
|
||||
* тег `$hddtempN` - температура HDD N. Наприклад, `$hddtemp0`
|
||||
* тег `$down` - швидкість завантаження, *KB/s*
|
||||
* тег `$up` - швидкість віддачі, *KB/s*
|
||||
* тег `$netdev` - поточний мережний інтерфейс
|
||||
* тег `$bat` - заряд батареї, *%*
|
||||
* тег `$ac` - статус адаптера живлення. Повертає `(*)`, якщо AC підключений або `( )`, якщо ні
|
||||
* тег `$album` - альбом. Один з підтримуваних плеєрів повинен бути встановлений
|
||||
* тег `$artist` - виконавець. Один з підтримуваних плеєрів повинен бути встановлений
|
||||
* тег `$progress` - прогрес. Один з підтримуваних плеєрів повинен бути встановлений
|
||||
* тег `$time` - тривалість. Один з підтримуваних плеєрів повинен бути встановлений
|
||||
* тег `$title` - назва. Один з підтримуваних плеєрів повинен бути встановлений
|
||||
* тег `$pscount` - кількість запущених процесів
|
||||
* тег `$pstotal` - загальна кількість процесів
|
||||
* тег `$ps` - перелік процесів
|
||||
* тег `$pkgcountN` - кількість пакетів, що можуть бути оновлені, для команди N. Наприклад, `$pkgcount0`
|
||||
* тег `$customN` - повертає результат своєї команди N. Наприклад, `$custom0`
|
||||
|
||||
Порядок полів зміниться, якщо ви зміните позицію слайдерів. HTML теги в полях працюють коректно.
|
||||
|
||||
**ЗАУВАЖЕННЯ** ви не зможете встановити тег `$cpu`, наприклад, в полі swap. **`$cpu` буде працювати тільки в полі CPU**.
|
||||
|
||||
Поради та хитрощі
|
||||
-----------------
|
||||
|
||||
Ви можете використовувати різні кольори в полях. Просто встановіть потрібний текст в html код. Дивись [питання](https://github.com/arcan1s/pytextmonitor/issues/9) для більш детальної інформації.
|
||||
|
||||
Нумерація элементів в полях температура, використання HDD, швидкість HDD, температура HDD посилається на порядок елементів у другій вкладці (*Розширені налаштування*). Ви повинні спочатку додати потрібні елементи в потрібний listWidget. Тоді перший елемент в listWdiget буде пов’язаний з `$tag0`. Дивись [питання](https://github.com/arcan1s/pytextmonitor/issues/17) для більш детальної інформації.
|
||||
|
||||
Розширені налаштування
|
||||
----------------------
|
||||
|
||||
**Вертикальна розмітка**
|
||||
|
||||
Використовувати вертикальну розмітку замість горизонтальної.
|
||||
|
||||
**Включити спливаючі повідомлення**
|
||||
|
||||
Натисніть на чекбокс, якщо ви не користуєтесь спливаючими повідомленнями.
|
||||
|
||||
**Додати порожній простір**
|
||||
|
||||
Додати порожній простір у вказане місце віджета.
|
||||
|
||||
**Свій формат часу**
|
||||
|
||||
* тег `$dddd` - день тижня у довгому форматі
|
||||
* тег `$ddd` - день тижня в короткому форматі
|
||||
* тег `$dd` - день
|
||||
* тег `$d` - день без нуля
|
||||
* тег `$MMMM` - місяць у довгому форматі
|
||||
* тег `$MMM` - місяць в короткому форматі
|
||||
* тег `$MM` - місяць
|
||||
* тег `$M` - місяця без нуля
|
||||
* тег `$yyyy` - рік
|
||||
* тег `$yy` - рік в короткому форматіе
|
||||
* тег `$hh` - години
|
||||
* тег `$h` - години без нуля
|
||||
* тег `$mm` - хвилини
|
||||
* тег `$m` - хвилини без нуля
|
||||
* тег `$ss` - секунди
|
||||
* тег `$s` - секунди без нуля
|
||||
|
||||
**Свій формат аптайму**
|
||||
|
||||
* тег `$dd` - дні аптайму
|
||||
* тег `$d` - дні аптайму без нуля
|
||||
* тег `$hh` - години аптайму
|
||||
* тег `$h` - години аптайму без нуля
|
||||
* тег `$mm` - хвилини аптайму
|
||||
* тег `$m` - хвилини аптайму без нуля
|
||||
|
||||
**Одиниці виміру температури**
|
||||
|
||||
Оберіть одиниці виміру температур. Доступні такі одиниці: Цельсій, Фаренгейт та Кельвін.
|
||||
|
||||
**Датчики температури**
|
||||
|
||||
Перелік датчиків, що будуть спостерігатись в полі temo (вміст комбо боксу береться із `sensors`). Віджет можна редагувати, клавіша delete видаляє поточний рядок.
|
||||
|
||||
**Точки монтування**
|
||||
|
||||
Перелік точок монтування, які будуть спостерігатися в полі hdd (вміст комбо боксу береться із `mount`). Віджет можна редагувати, клавіша delete видаляє поточний рядок.
|
||||
|
||||
**HDD (швидкість)**
|
||||
|
||||
Перелік HDD, які будуть спостерігатися в полі hddspeed (вміст комбо боксу береться із DataEngine). Віджет можна редагувати, клавіша delete видаляє поточний рядок.
|
||||
|
||||
**HDD (температура)**
|
||||
|
||||
Перелік HDD, які будуть спостерігатися в полі hddtemp (вміст комбо боксу береться iз `find`). Віджет можна редагувати, клавіша delete видаляє поточний рядок.
|
||||
|
||||
**Директорія з мережевими інтерфейсами**
|
||||
|
||||
Шлях до директорії, яка містить інформацію про мережеві інтерфейси. За замовчуванням `/sys/class/net`. Потрібно для визначення мережевого пристрою.
|
||||
|
||||
**Мережевий пристрій**
|
||||
|
||||
Використовувати вказаний інтерфейс, як активний. Вміст комбо боксу береться із **директорії з мережевими інтерфейсами**. Ця опція вимкне автовизначення інтерфейсу.
|
||||
|
||||
**Пристрій батареї**
|
||||
|
||||
Файл з інформацією про батарею. Даний файл (`/sys/class/power_supply/BAT0/capacity` за замовчуванням) повинен містити тільки заряд батареї в процентах.
|
||||
|
||||
**AC online тег**
|
||||
|
||||
Рядок, що буде показаний, коли AC онлайн.
|
||||
|
||||
**AC offline тег**
|
||||
|
||||
Рядок, що буде показаний, коли AC оффлайн.
|
||||
|
||||
**Пристрій AC**
|
||||
|
||||
Файл з інформациею про адаптер живлення. Даний файл (`/sys/class/power_supply/AC/online` за замовчуванням) повинен містити `1`, якщо адаптер підключений.
|
||||
|
||||
Налаштування тултіпу
|
||||
--------------------
|
||||
Починаючи з версії 1.7.0 поля CPU, частота CPU, пам’ять, swap та мережа підтримують графічний тултіп. Щоб їх ввімкнути, просто зробіть необхідні чекбокси повністю чекнутими. Кількість зберігаємих значень може бути виставлена в даній вкладці. Кольори графіків також налаштовуються.
|
||||
|
||||
Налаштування DataEngine
|
||||
-----------------------
|
||||
**Своя команда**
|
||||
|
||||
*ЗАУВАЖЕННЯ* Може призвести до зависання комп’ютера.
|
||||
|
||||
Команда, що буде запущена для відповідного поля.
|
||||
|
||||
**Пристрій GPU**
|
||||
|
||||
Оберіть один з підтримуваних пристроїв GPU. `auto` ввімкне автоматичне визначення. За замовчуванням `auto`.
|
||||
|
||||
**HDD**
|
||||
|
||||
Оберіть один з HDD для контролю його температури. `all` ввімкне контроль для всих доступних пристроїв. За замовчуванням `all`.
|
||||
|
||||
**Команда hddtemp**
|
||||
|
||||
Оберіть команду, яка буде запущена для hddtemp DataEngine. За замовчуванням `sudo hddtemp`.
|
||||
|
||||
**Адреса MPD**
|
||||
|
||||
Адреса MPD серверу. За замовчуванням `localhost`.
|
||||
|
||||
**Порт MPD**
|
||||
|
||||
Порт MPD серверу. За замовчуванням `6600`.
|
||||
|
||||
**Package manager**
|
||||
|
||||
Перелік команд, які будуть запущені. Кількість пустих рядків - кількість непотрібних для підрахунку рядків. Стандартні налаштування:
|
||||
|
||||
* *Arch*: `PKGCMD=pacman -Qu`, `PKGNULL=0`
|
||||
* *Debian*: `PKGCMD=apt-show-versions -u -b`, `PKGNULL=0`
|
||||
* *Ubuntu*: `PKGCMD=aptitude search '~U'`, `PKGNULL=0`
|
||||
* *Fedora*: `PKGCMD=yum list updates`, `PKGNULL=3`
|
||||
* *FreeBSD*: `PKGCMD=pkg_version -I -l '<'`, `PKGNULL=0`
|
||||
* *Mandriva*: `PKGCMD=urpmq --auto-select`, `PKGNULL=0`
|
||||
|
||||
**Музичний плеєр**
|
||||
|
||||
Виберіть один з підтримуваних музичних плеєрів.
|
||||
|
||||
Налаштування DataEngine
|
||||
-----------------------
|
||||
Ви можете відредагувати налаштування DataEngine вручну. Відкрийте файл `/usr/share/config/extsysmon.conf` або `$HOME/.kde4/share/config/extsysmon.conf`, в залежності від типу установки. Розкоментуйте потрібні рядки та відредагуйте їх.
|
||||
|
||||
Інструкція
|
||||
==========
|
||||
|
||||
Залежності
|
||||
----------
|
||||
|
||||
* kdebase-workspace
|
||||
* kdebindings-python2
|
||||
* lm_sensors (*для визначення датчиків температури*)
|
||||
|
||||
Опціональні залежності
|
||||
----------------------
|
||||
|
||||
* sysstat (*для сповіщень*)
|
||||
* проприєтарний відеодрайвер
|
||||
* hddtemp (переконайтесь, що може бути запущений з `sudo` без пароля. Просто добавте наступний рядок в `/etc/sudoers`: `$USERNAME ALL=NOPASSWD: /usr/bin/hddtemp`)
|
||||
* музичний плеєр (amarok, clementine, mpd или qmmp)
|
||||
|
||||
Залежності збирання
|
||||
-------------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Установка
|
||||
---------
|
||||
|
||||
* скачати вихідний архів
|
||||
* встановити
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
|
||||
make && make install
|
||||
|
||||
Для установки в `/`:
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
|
||||
make && sudo make install
|
||||
|
||||
Додаткова інформація
|
||||
====================
|
||||
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
Посилання
|
||||
---------
|
||||
|
||||
* [Домашня сторінка](http://arcanis.name/projects/pytextmonitor/)
|
||||
* Віджет на [kde-look](http://kde-look.org/content/show.php/Py+Text+Monitor?content=157124)
|
||||
* DataEngine на [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
|
||||
* Пакет для Archlinux в [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-pytextmonitor/)
|
56
packages/PKGBUILD
Normal file
@ -0,0 +1,56 @@
|
||||
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
|
||||
|
||||
pkgname=kdeplasma-applets-awesome-widgets-git
|
||||
_pkgname=awesome-widgets
|
||||
pkgver=2.2.1.r2.ga098c9d
|
||||
pkgrel=1
|
||||
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/awesome-widgets"
|
||||
license=('GPL3')
|
||||
depends=('kdebase-workspace' 'lm_sensors')
|
||||
optdepends=("amarok: for music player monitor"
|
||||
"clementine: for music player monitor"
|
||||
"catalyst: for GPU monitor"
|
||||
"hddtemp: for HDD temperature monitor"
|
||||
"smartmontools: for HDD temperature monitor"
|
||||
"mpd: for music player monitor"
|
||||
"nvidia-utils: for GPU monitor"
|
||||
"qmmp: for music player monitor")
|
||||
makedepends=('automoc4' 'cmake' 'git')
|
||||
source=(${_pkgname}::git+https://github.com/arcan1s/awesome-widgets.git#branch=release-2.2.1)
|
||||
install=${pkgname}.install
|
||||
md5sums=('SKIP')
|
||||
backup=('usr/share/config/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
|
||||
pkgver() {
|
||||
cd "${srcdir}/${_pkgname}"
|
||||
git describe --tags --long | sed 's/V\.//' | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
|
||||
}
|
||||
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/${_pkgname}/build"
|
||||
mkdir "${srcdir}/${_pkgname}/build"
|
||||
|
||||
# update submobules
|
||||
cd "${srcdir}/${_pkgname}"
|
||||
git submodule init
|
||||
git submodule update --recursive
|
||||
}
|
||||
|
||||
|
||||
build () {
|
||||
cd "${srcdir}/${_pkgname}/build"
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) \
|
||||
"../sources"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/${_pkgname}/build"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
4
packages/build-requirements.deb.txt
Normal file
@ -0,0 +1,4 @@
|
||||
cmake
|
||||
g++
|
||||
git
|
||||
kdelibs5-dev
|
11
packages/kdeplasma-applets-awesome-widgets-git.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
BIN
screenshots/config_01.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
screenshots/config_02.png
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
screenshots/config_03.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
screenshots/config_04.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
screenshots/config_05.png
Normal file
After Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 43 KiB |
23
sources/.kdev4/sources.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
||||
Build Type=Debug
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
218
sources/3rdparty/about/about.ui
vendored
Normal file
@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>About</class>
|
||||
<widget class="QWidget" name="About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_About">
|
||||
<attribute name="title">
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_about">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_about">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_version">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_links">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_about">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_ackn">
|
||||
<attribute name="title">
|
||||
<string>Acknowledgement</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_ackn">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_ackn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_translators">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_trdparty">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_ackn">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>229</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_license">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
1
sources/3rdparty/fontdialog
vendored
Submodule
1
sources/3rdparty/pdebug
vendored
Submodule
1
sources/3rdparty/task
vendored
Submodule
1
sources/3rdparty/tasks
vendored
Submodule
@ -5,24 +5,44 @@ cmake_policy (SET CMP0002 OLD)
|
||||
cmake_policy (SET CMP0011 NEW)
|
||||
cmake_policy (SET CMP0015 NEW)
|
||||
|
||||
project (pytextmonitor)
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 10)
|
||||
set (PROJECT_VERSION_PATCH 2)
|
||||
project (awesomewidgets)
|
||||
set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 2)
|
||||
set (PROJECT_VERSION_MINOR 2)
|
||||
set (PROJECT_VERSION_PATCH 1)
|
||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||
|
||||
message (STATUS "Project: ${PROJECT_NAME}")
|
||||
message (STATUS "Version: ${PROJECT_VERSION}")
|
||||
message (STATUS "Build date: ${CURRENT_DATE}")
|
||||
|
||||
option(BUILD_DEB_PACKAGE "Build deb package" OFF)
|
||||
option(BUILD_RPM_PACKAGE "Build rpm package" OFF)
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# avoid newer gcc warnings
|
||||
add_definitions (-D_DEFAULT_SOURCE)
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
|
||||
add_subdirectory (ext-sysmon)
|
||||
add_subdirectory (ptm)
|
||||
add_subdirectory (readme)
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||
|
||||
add_subdirectory (extsysmon)
|
||||
add_subdirectory (awesome-widget)
|
||||
add_subdirectory (desktop-panel)
|
||||
|
||||
# translations
|
||||
add_subdirectory (translations)
|
||||
|
||||
include(packages-recipe.cmake)
|
||||
|
45
sources/awesome-widget/CMakeLists.txt
Normal file
@ -0,0 +1,45 @@
|
||||
# set project name
|
||||
set (SUBPROJECT plasma_applet_awesome-widget)
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
|
||||
include (KDE4Defaults)
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
../extsysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../extsysmon)
|
||||
|
||||
# set sources
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
../extsysmon/extscript.cpp
|
||||
../extsysmon/extupgrade.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
set (SUBPROJECT_DESKTOPS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
||||
install (DIRECTORY ${SUBPROJECT_DESKTOPS} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<class>AdvancedWindow</class>
|
||||
<widget class="QWidget" name="AdvancedWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>594</height>
|
||||
<height>588</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -29,7 +29,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string notr="true">Advanced</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
@ -41,53 +41,88 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>666</width>
|
||||
<height>823</height>
|
||||
<y>-250</y>
|
||||
<width>675</width>
|
||||
<height>822</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_layout">
|
||||
<property name="text">
|
||||
<string>Vertical layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="layout_popup">
|
||||
<item>
|
||||
<spacer name="spacer_popup">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_popup">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable popup on mouse click</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_popup">
|
||||
<property name="text">
|
||||
<string>Enable popup on mouse click</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_leftStretch">
|
||||
<property name="text">
|
||||
<string>Add stretch to left/top of the layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_rightStretch">
|
||||
<property name="text">
|
||||
<string>Add stretch to right/bottom of the layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="layout_background">
|
||||
<item>
|
||||
<spacer name="spacer_background">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_background">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeFormat">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeFormat">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom time format</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -110,9 +145,6 @@ $m - minutes w\o zero
|
||||
$ss - seconds
|
||||
$s - seconds w\o zero</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -121,15 +153,18 @@ $s - seconds w\o zero</string>
|
||||
<layout class="QHBoxLayout" name="layout_uptimeFormat">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_uptimeFormat">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom uptime format</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -142,9 +177,6 @@ $h - uptime hours without zero
|
||||
$mm - uptime minutes
|
||||
$m - uptime minutes without zero</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -153,38 +185,16 @@ $m - uptime minutes without zero</string>
|
||||
<layout class="QHBoxLayout" name="layout_tempUnits">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_tempUnits">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Temperature units</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_tempUnits">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_tempUnits">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Celsius</string>
|
||||
@ -200,6 +210,26 @@ $m - uptime minutes without zero</string>
|
||||
<string notr="true">Kelvin</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Reaumur</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">cm^-1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">kJ/mol</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">kcal/mol</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -207,53 +237,46 @@ $m - uptime minutes without zero</string>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_tempDevice">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_tempDeviceSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_tempDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Temperature devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_tempDevice">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_tempDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_tempDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Temperature devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_tempDevice">
|
||||
<property name="toolTip">
|
||||
<string>Editable
|
||||
del - remove item</string>
|
||||
<string>Editable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_fanDevice">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fanDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fan devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_fanDevice">
|
||||
<property name="toolTip">
|
||||
<string>Editable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -262,53 +285,22 @@ del - remove item</string>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_mount">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mountSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mount">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mount points</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mount">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mount">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_mount">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mount points</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_mount">
|
||||
<property name="toolTip">
|
||||
<string>Editable
|
||||
del - remove item</string>
|
||||
<string>Editable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -317,50 +309,22 @@ del - remove item</string>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_hddSpeedDevice">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_hddSpeedDeviceSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_hddSpeedDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDD devices (speed)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_hddSpeedDevice">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_hddSpeedDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_hddSpeedDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDD devices (speed)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_hddSpeedDevice">
|
||||
<property name="toolTip">
|
||||
<string>Editable
|
||||
del - remove item</string>
|
||||
<string>Editable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -369,62 +333,7 @@ del - remove item</string>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_hddDevice">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_hddDeviceSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_hddDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDD devices (temp)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_hddDevice">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_hddDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_hddDevice">
|
||||
<property name="toolTip">
|
||||
<string>Editable
|
||||
del - remove item</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_netdir">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_netdir">
|
||||
<widget class="QLabel" name="label_hddDevice">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
@ -432,17 +341,14 @@ del - remove item</string>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Network directory</string>
|
||||
<string>HDD devices (temp)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_netdir">
|
||||
<widget class="QListWidget" name="listWidget_hddDevice">
|
||||
<property name="toolTip">
|
||||
<string>"/sys/class/net" by default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>Editable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -452,15 +358,12 @@ del - remove item</string>
|
||||
<layout class="QHBoxLayout" name="layout_netdev">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_netdev">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Disable auto select device and set specified device</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set network device</string>
|
||||
</property>
|
||||
@ -468,15 +371,6 @@ del - remove item</string>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_netdev">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -484,43 +378,22 @@ del - remove item</string>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_batdev">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_batdev">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Battery device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_batdev">
|
||||
<property name="toolTip">
|
||||
<string>"/sys/class/power_supply/BAT0/capacity" by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_acOnline">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_acOnline">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AC online tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -531,9 +404,6 @@ del - remove item</string>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -542,15 +412,18 @@ del - remove item</string>
|
||||
<layout class="QHBoxLayout" name="layout_acOffline">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_acOffline">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AC offline tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -561,32 +434,77 @@ del - remove item</string>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_bars">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_barsAdd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_bars">
|
||||
<property name="text">
|
||||
<string>Bars</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_bars">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bars">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_bars">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_acdev">
|
||||
<layout class="QHBoxLayout" name="layout_updates">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_acdev">
|
||||
<property name="minimumSize">
|
||||
<spacer name="spacer_updates">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AC device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_acdev">
|
||||
<property name="toolTip">
|
||||
<string>"/sys/class/power_supply/AC/online" by default</string>
|
||||
<widget class="QCheckBox" name="checkBox_updates">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check for updates</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -611,35 +529,6 @@ del - remove item</string>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>scrollArea_advanced</tabstop>
|
||||
<tabstop>checkBox_layout</tabstop>
|
||||
<tabstop>checkBox_popup</tabstop>
|
||||
<tabstop>checkBox_leftStretch</tabstop>
|
||||
<tabstop>checkBox_rightStretch</tabstop>
|
||||
<tabstop>lineEdit_timeFormat</tabstop>
|
||||
<tabstop>lineEdit_uptimeFormat</tabstop>
|
||||
<tabstop>comboBox_tempUnits</tabstop>
|
||||
<tabstop>comboBox_tempDevice</tabstop>
|
||||
<tabstop>pushButton_tempDevice</tabstop>
|
||||
<tabstop>listWidget_tempDevice</tabstop>
|
||||
<tabstop>comboBox_mount</tabstop>
|
||||
<tabstop>pushButton_mount</tabstop>
|
||||
<tabstop>listWidget_mount</tabstop>
|
||||
<tabstop>comboBox_hddSpeedDevice</tabstop>
|
||||
<tabstop>pushButton_hddSpeedDevice</tabstop>
|
||||
<tabstop>listWidget_hddSpeedDevice</tabstop>
|
||||
<tabstop>comboBox_hddDevice</tabstop>
|
||||
<tabstop>pushButton_hddDevice</tabstop>
|
||||
<tabstop>listWidget_hddDevice</tabstop>
|
||||
<tabstop>lineEdit_netdir</tabstop>
|
||||
<tabstop>checkBox_netdev</tabstop>
|
||||
<tabstop>comboBox_netdev</tabstop>
|
||||
<tabstop>lineEdit_batdev</tabstop>
|
||||
<tabstop>lineEdit_acOnline</tabstop>
|
||||
<tabstop>lineEdit_acOffline</tabstop>
|
||||
<tabstop>lineEdit_acdev</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<class>AppearanceWindow</class>
|
||||
<widget class="QWidget" name="AppearanceWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -29,7 +29,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string notr="true">Appearance</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
@ -51,41 +51,16 @@
|
||||
<layout class="QHBoxLayout" name="layout_interval">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interval">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Time interval</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_interval">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@ -106,30 +81,14 @@
|
||||
<layout class="QHBoxLayout" name="layout_font">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_font">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_font">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="fontComboBox">
|
||||
<property name="minimumSize">
|
||||
@ -143,44 +102,19 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontSize">
|
||||
<layout class="QHBoxLayout" name="layout_size">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontSize">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_size">
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_fontSize">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontSize">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_size">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@ -201,39 +135,16 @@
|
||||
<layout class="QHBoxLayout" name="layout_color">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_color">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_color">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KColorCombo" name="kcolorcombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -241,38 +152,16 @@
|
||||
<layout class="QHBoxLayout" name="layout_style">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_style">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font style</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_style">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_style">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">normal</string>
|
||||
@ -291,49 +180,24 @@
|
||||
<layout class="QHBoxLayout" name="layout_weight">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_weight">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_weight">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_weight">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_weight">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
<number>900</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>50</number>
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>400</number>
|
503
sources/awesome-widget/awesome-widget.cpp
Normal file
@ -0,0 +1,503 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "awesome-widget.h"
|
||||
|
||||
#include <KStandardDirs>
|
||||
#include <Plasma/ToolTipManager>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QGraphicsGridLayout>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTextCodec>
|
||||
#include <QTimer>
|
||||
|
||||
#include "customlabel.h"
|
||||
#include "graphicalitem.h"
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
#include "version.h"
|
||||
|
||||
|
||||
AwesomeWidget::AwesomeWidget(QObject *parent, const QVariantList &args)
|
||||
: Plasma::Applet(parent, args)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
debug = false;
|
||||
|
||||
setBackgroundHints(DefaultBackground);
|
||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
||||
setHasConfigurationInterface(true);
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
// text format init
|
||||
formatLine.append(QString(""));
|
||||
formatLine.append(QString(""));
|
||||
}
|
||||
|
||||
|
||||
AwesomeWidget::~AwesomeWidget()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::checkUpdates()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyRecieved(QNetworkReply *)));
|
||||
manager->get(QNetworkRequest(QUrl(VERSION_API)));
|
||||
}
|
||||
|
||||
|
||||
QList<QAction *> AwesomeWidget::contextualActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
contextMenu.clear();
|
||||
contextMenu.append(new QAction(QIcon::fromTheme(QString("utilities-system-monitor")),
|
||||
i18n("Run ksysguard"), this));
|
||||
connect(contextMenu[0], SIGNAL(triggered(bool)), this, SLOT(showKsysguard()));
|
||||
contextMenu.append(new QAction(QIcon::fromTheme(QString("text-x-readme")),
|
||||
i18n("Show README"), this));
|
||||
connect(contextMenu[1], SIGNAL(triggered(bool)), this, SLOT(showReadme()));
|
||||
contextMenu.append(new QAction(QIcon::fromTheme(QString("stock-refresh")),
|
||||
i18n("Update text"), this));
|
||||
connect(contextMenu[2], SIGNAL(triggered(bool)), this, SLOT(updateNetworkDevice()));
|
||||
connect(contextMenu[2], SIGNAL(triggered(bool)), extsysmonEngine, SLOT(updateAllSources()));
|
||||
connect(contextMenu[2], SIGNAL(triggered(bool)), sysmonEngine, SLOT(updateAllSources()));
|
||||
contextMenu.append(new QAction(QIcon::fromTheme(QString("system-software-update")),
|
||||
i18n("Check for updates"), this));
|
||||
connect(contextMenu[3], SIGNAL(triggered(bool)), this, SLOT(checkUpdates()));
|
||||
}
|
||||
|
||||
|
||||
QString AwesomeWidget::getNetworkDevice()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString device = QString("lo");
|
||||
if (configuration[QString("useCustomNetdev")].toInt() == 2)
|
||||
device = configuration[QString("customNetdev")];
|
||||
else {
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint)))
|
||||
device = rawInterfaceList[i].name();
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
int AwesomeWidget::getNumberCpus()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("grep -c ^processor /proc/cpuinfo");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
return QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed().toInt();
|
||||
}
|
||||
|
||||
|
||||
float AwesomeWidget::getTemp(const float temp)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
float convertedTemp = temp;
|
||||
if (configuration[QString("tempUnits")] == QString("Celsius"))
|
||||
;
|
||||
else if (configuration[QString("tempUnits")] == QString("Fahrenheit"))
|
||||
convertedTemp = temp * 9.0 / 5.0 + 32.0;
|
||||
else if (configuration[QString("tempUnits")] == QString("Kelvin"))
|
||||
convertedTemp = temp + 273.15;
|
||||
else if (configuration[QString("tempUnits")] == QString("Reaumur"))
|
||||
convertedTemp = temp * 0.8;
|
||||
else if (configuration[QString("tempUnits")] == QString("cm^-1"))
|
||||
convertedTemp = (temp + 273.15) * 0.695;
|
||||
else if (configuration[QString("tempUnits")] == QString("kJ/mol"))
|
||||
convertedTemp = (temp + 273.15) * 8.31;
|
||||
else if (configuration[QString("tempUnits")] == QString("kcal/mol"))
|
||||
convertedTemp = (temp + 273.15) * 1.98;
|
||||
|
||||
return convertedTemp;
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::getTimeKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList timeKeys;
|
||||
timeKeys.append(QString("dddd"));
|
||||
timeKeys.append(QString("ddd"));
|
||||
timeKeys.append(QString("dd"));
|
||||
timeKeys.append(QString("d"));
|
||||
timeKeys.append(QString("MMMM"));
|
||||
timeKeys.append(QString("MMM"));
|
||||
timeKeys.append(QString("MM"));
|
||||
timeKeys.append(QString("M"));
|
||||
timeKeys.append(QString("yyyy"));
|
||||
timeKeys.append(QString("yy"));
|
||||
timeKeys.append(QString("hh"));
|
||||
timeKeys.append(QString("h"));
|
||||
timeKeys.append(QString("mm"));
|
||||
timeKeys.append(QString("m"));
|
||||
timeKeys.append(QString("ss"));
|
||||
timeKeys.append(QString("s"));
|
||||
|
||||
return timeKeys;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::init()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// dataengines
|
||||
extsysmonEngine = dataEngine(QString("extsysmon"));
|
||||
sysmonEngine = dataEngine(QString("systemmonitor"));
|
||||
connect(sysmonEngine, SIGNAL(sourceAdded(QString)), this, SLOT(addDiskDevice(QString)));
|
||||
timeEngine = dataEngine(QString("time"));
|
||||
|
||||
// tooltip
|
||||
toolTip = Plasma::ToolTipContent();
|
||||
toolTip.setMainText(QString("Awesome Widget"));
|
||||
toolTip.setSubText(QString(""));
|
||||
toolTipScene = new QGraphicsScene();
|
||||
toolTipView = new QGraphicsView(toolTipScene);
|
||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||
toolTipView->setFrameShape(QFrame::NoFrame);
|
||||
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
Plasma::ToolTipManager::self()->setContent(this, toolTip);
|
||||
|
||||
// body
|
||||
createActions();
|
||||
mainLayout = new QGraphicsGridLayout();
|
||||
mainLayout->setContentsMargins(1, 1, 1, 1);
|
||||
setLayout(mainLayout);
|
||||
textLabel = new CustomLabel(this, debug);
|
||||
textLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
QGraphicsProxyWidget *pw = new QGraphicsProxyWidget(this);
|
||||
pw->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
textLabel->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
pw->setWidget(textLabel);
|
||||
mainLayout->addItem(pw, 0, 0);
|
||||
|
||||
// read variables
|
||||
configChanged();
|
||||
timer = new QTimer(this);
|
||||
timer->setSingleShot(false);
|
||||
timer->setInterval(configuration[QString("interval")].toInt());
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateText()));
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateTooltip()));
|
||||
timer->start();
|
||||
// check for updates
|
||||
connect(this, SIGNAL(thereIsUpdates(QString)), this, SLOT(showUpdates(QString)));
|
||||
if (configuration[QString("checkUpdates")].toInt() == 2)
|
||||
checkUpdates();
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::replyRecieved(QNetworkReply *reply)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString answer = reply->readAll();
|
||||
if (!answer.contains(QString("tag_name"))) return;
|
||||
QString version = QString(VERSION);
|
||||
if (debug) qDebug() << PDEBUG << answer;
|
||||
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
|
||||
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
|
||||
version.remove(QChar('"'));
|
||||
version.remove(QChar(':'));
|
||||
version.remove(QString("V."));
|
||||
break;
|
||||
}
|
||||
|
||||
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
|
||||
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
|
||||
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
|
||||
int new_major = QString(version).split(QChar('.'))[0].toInt();
|
||||
int new_minor = QString(version).split(QChar('.'))[1].toInt();
|
||||
int new_patch = QString(version).split(QChar('.'))[2].toInt();
|
||||
if ((old_major < new_major) ||
|
||||
((old_major == new_major) && (old_minor < new_minor)) ||
|
||||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||
emit(thereIsUpdates(version));
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::addDiskDevice(const QString source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
|
||||
if (diskRegexp.indexIn(source) > -1) {
|
||||
QStringList splitSource = source.split(QChar('/'));
|
||||
QString device = splitSource[0] + QString("/") + splitSource[1];
|
||||
diskDevices.append(device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::findKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList selectedKeys;
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
if (configuration[QString("text")].contains(QString("$") + keys[i])) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
|
||||
selectedKeys.append(keys[i]);
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::getKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList allKeys;
|
||||
// time
|
||||
allKeys.append(QString("time"));
|
||||
allKeys.append(QString("isotime"));
|
||||
allKeys.append(QString("shorttime"));
|
||||
allKeys.append(QString("longtime"));
|
||||
allKeys.append(QString("ctime"));
|
||||
// uptime
|
||||
allKeys.append(QString("uptime"));
|
||||
allKeys.append(QString("cuptime"));
|
||||
// cpuclock
|
||||
for (int i=counts[QString("cpu")]-1; i>=0; i--)
|
||||
allKeys.append(QString("cpucl") + QString::number(i));
|
||||
allKeys.append(QString("cpucl"));
|
||||
// cpu
|
||||
for (int i=counts[QString("cpu")]-1; i>=0; i--)
|
||||
allKeys.append(QString("cpu") + QString::number(i));
|
||||
allKeys.append(QString("cpu"));
|
||||
// temperature
|
||||
for (int i=counts[QString("temp")]-1; i>=0; i--)
|
||||
allKeys.append(QString("temp") + QString::number(i));
|
||||
for (int i=counts[QString("fan")]-1; i>=0; i--)
|
||||
allKeys.append(QString("fan") + QString::number(i));
|
||||
// gputemp
|
||||
allKeys.append(QString("gputemp"));
|
||||
// gpu
|
||||
allKeys.append(QString("gpu"));
|
||||
// memory
|
||||
allKeys.append(QString("memmb"));
|
||||
allKeys.append(QString("memgb"));
|
||||
allKeys.append(QString("memfreemb"));
|
||||
allKeys.append(QString("memfreegb"));
|
||||
allKeys.append(QString("memtotmb"));
|
||||
allKeys.append(QString("memtotgb"));
|
||||
allKeys.append(QString("memusedmb"));
|
||||
allKeys.append(QString("memusedgb"));
|
||||
allKeys.append(QString("mem"));
|
||||
// swap
|
||||
allKeys.append(QString("swapmb"));
|
||||
allKeys.append(QString("swapgb"));
|
||||
allKeys.append(QString("swapfreemb"));
|
||||
allKeys.append(QString("swapfreegb"));
|
||||
allKeys.append(QString("swaptotmb"));
|
||||
allKeys.append(QString("swaptotgb"));
|
||||
allKeys.append(QString("swap"));
|
||||
// hdd
|
||||
for (int i=counts[QString("mount")]-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddmb") + QString::number(i));
|
||||
allKeys.append(QString("hddgb") + QString::number(i));
|
||||
allKeys.append(QString("hddfreemb") + QString::number(i));
|
||||
allKeys.append(QString("hddfreegb") + QString::number(i));
|
||||
allKeys.append(QString("hddtotmb") + QString::number(i));
|
||||
allKeys.append(QString("hddtotgb") + QString::number(i));
|
||||
allKeys.append(QString("hdd") + QString::number(i));
|
||||
}
|
||||
// hdd speed
|
||||
for (int i=counts[QString("disk")]-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddr") + QString::number(i));
|
||||
allKeys.append(QString("hddw") + QString::number(i));
|
||||
}
|
||||
// hdd temp
|
||||
for (int i=counts[QString("hddtemp")]-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddtemp") + QString::number(i));
|
||||
allKeys.append(QString("hddtemp") + QString::number(i));
|
||||
}
|
||||
// network
|
||||
allKeys.append(QString("down"));
|
||||
allKeys.append(QString("up"));
|
||||
allKeys.append(QString("netdev"));
|
||||
// battery
|
||||
allKeys.append(QString("ac"));
|
||||
for (int i=counts[QString("bat")]-1; i>=0; i--)
|
||||
allKeys.append(QString("bat") + QString::number(i));
|
||||
allKeys.append(QString("bat"));
|
||||
// player
|
||||
allKeys.append(QString("album"));
|
||||
allKeys.append(QString("artist"));
|
||||
allKeys.append(QString("duration"));
|
||||
allKeys.append(QString("progress"));
|
||||
allKeys.append(QString("title"));
|
||||
// ps
|
||||
allKeys.append(QString("pscount"));
|
||||
allKeys.append(QString("pstotal"));
|
||||
allKeys.append(QString("ps"));
|
||||
// package manager
|
||||
for (int i=counts[QString("pkg")]-1; i>=0; i--)
|
||||
allKeys.append(QString("pkgcount") + QString::number(i));
|
||||
// custom
|
||||
for (int i=counts[QString("custom")]-1; i>=0; i--)
|
||||
allKeys.append(QString("custom") + QString::number(i));
|
||||
// desktop
|
||||
allKeys.append(QString("desktop"));
|
||||
allKeys.append(QString("ndesktop"));
|
||||
allKeys.append(QString("tdesktops"));
|
||||
|
||||
return allKeys;
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::findGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList orderedKeys;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||
orderedKeys.sort();
|
||||
QStringList selectedKeys;
|
||||
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||
if (configuration[QString("text")].contains(QString("$") + orderedKeys[i])) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys[i];
|
||||
selectedKeys.append(orderedKeys[i]);
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::getGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
graphicalItems.clear();
|
||||
// create directory at $HOME
|
||||
QString localDir = KStandardDirs::locateLocal("data", "plasma_applet_awesome-widget/desktops");
|
||||
if (KStandardDirs::makeDir(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
QStringList dirs = KGlobal::dirs()->findDirs("data", "plasma_applet_awesome-widget/desktops");
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||
for (int j=0; j<files.count(); j++) {
|
||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
graphicalItems.append(new GraphicalItem(0, files[j], dirs, debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem *AwesomeWidget::getItemByTag(const QString tag)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
GraphicalItem *item = nullptr;
|
||||
for (int i=0; i< graphicalItems.count(); i++) {
|
||||
if ((graphicalItems[i]->name() + graphicalItems[i]->bar()) != tag) continue;
|
||||
item = graphicalItems[i];
|
||||
break;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::showKsysguard()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("ksysguard");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::showReadme()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QDesktopServices::openUrl(QString("http://arcanis.name/projects/awesome-widgets/"));
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::showUpdates(QString version)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString text;
|
||||
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
||||
text += i18n("New version : %1", version) + QString("\n\n");
|
||||
text += i18n("Click \"Ok\" to download");
|
||||
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
||||
switch (select) {
|
||||
case QMessageBox::Ok:
|
||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(awesome-widget, AwesomeWidget)
|
154
sources/awesome-widget/awesome-widget.h
Normal file
@ -0,0 +1,154 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef AWESOME_WIDGET_H
|
||||
#define AWESOME_WIDGET_H
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/DataEngine>
|
||||
#include <Plasma/ToolTipContent>
|
||||
|
||||
#include <ui_about.h>
|
||||
#include <ui_advanced.h>
|
||||
#include <ui_appearance.h>
|
||||
#include <ui_deconfig.h>
|
||||
#include <ui_tooltipconfig.h>
|
||||
#include <ui_widget.h>
|
||||
|
||||
|
||||
class CustomLabel;
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
class GraphicalItem;
|
||||
class QGraphicsGridLayout;
|
||||
class QGraphicsScene;
|
||||
class QNetworkReply;
|
||||
|
||||
class AwesomeWidget : public Plasma::Applet
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AwesomeWidget(QObject *parent, const QVariantList &args);
|
||||
~AwesomeWidget();
|
||||
QString getNetworkDevice();
|
||||
int getNumberCpus();
|
||||
float getTemp(const float temp);
|
||||
QStringList getTimeKeys();
|
||||
void init();
|
||||
// de configuration
|
||||
QMap<QString, QString> readDataEngineConfiguration();
|
||||
void writeDataEngineConfiguration(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
// contextual actions
|
||||
void showKsysguard();
|
||||
void showReadme();
|
||||
void showUpdates(QString version);
|
||||
// dataengine
|
||||
void addDiskDevice(const QString source);
|
||||
void connectToEngine();
|
||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
||||
void disconnectFromEngine();
|
||||
// configuration interface
|
||||
void configAccepted();
|
||||
void configChanged();
|
||||
// update events
|
||||
void sendNotification(const QString eventId, const QString message);
|
||||
void updateNetworkDevice(const bool delay = true);
|
||||
void updateText(const bool clear = false);
|
||||
void updateTooltip();
|
||||
|
||||
private slots:
|
||||
void checkUpdates();
|
||||
void reinit();
|
||||
void replyRecieved(QNetworkReply *reply);
|
||||
// configuration interface
|
||||
void addBar();
|
||||
void addCustomScript();
|
||||
void addPkgCommand();
|
||||
void contextMenuBars(const QPoint pos);
|
||||
void contextMenuCustomCommand(const QPoint pos);
|
||||
void contextMenuPkgCommand(const QPoint pos);
|
||||
void copyBar(const QString original);
|
||||
void copyCustomCommand(const QString original);
|
||||
void copyPkgCommand(const QString original);
|
||||
void editBar(QListWidgetItem *item);
|
||||
void editCustomCommand(QListWidgetItem *item);
|
||||
void editPkgCommand(QListWidgetItem *item);
|
||||
void editFanItem(QListWidgetItem *item);
|
||||
void editHddItem(QListWidgetItem *item);
|
||||
void editHddSpeedItem(QListWidgetItem *item);
|
||||
void editMountItem(QListWidgetItem *item);
|
||||
void editTempItem(QListWidgetItem *item);
|
||||
void setFontFormating();
|
||||
void setFormating();
|
||||
|
||||
signals:
|
||||
void thereIsUpdates(QString version);
|
||||
|
||||
protected:
|
||||
QList<QAction *> contextualActions();
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
|
||||
private:
|
||||
// functions
|
||||
void createActions();
|
||||
QStringList findKeys();
|
||||
QStringList getKeys();
|
||||
QStringList findGraphicalItems();
|
||||
void getGraphicalItems();
|
||||
GraphicalItem *getItemByTag(const QString tag);
|
||||
QList<ExtScript *> initScripts();
|
||||
QList<ExtUpgrade *> initUpgrades();
|
||||
// ui
|
||||
QGraphicsGridLayout *mainLayout = nullptr;
|
||||
CustomLabel *textLabel = nullptr;
|
||||
QTimer *timer = nullptr;
|
||||
QList<QAction *> contextMenu;
|
||||
// tooltip
|
||||
Plasma::ToolTipContent toolTip;
|
||||
QGraphicsScene *toolTipScene = nullptr;
|
||||
QGraphicsView *toolTipView = nullptr;
|
||||
// values
|
||||
int networkDeviceUpdate = 0;
|
||||
QMap<QString, int> counts;
|
||||
QMap<QString, QList<float>> tooltipValues;
|
||||
QMap<QString, QString> values;
|
||||
// debug
|
||||
bool debug;
|
||||
// data engine
|
||||
Plasma::DataEngine *extsysmonEngine = nullptr;
|
||||
Plasma::DataEngine *sysmonEngine = nullptr;
|
||||
Plasma::DataEngine *timeEngine = nullptr;
|
||||
// configuration interface
|
||||
Ui::About uiAboutConfig;
|
||||
Ui::AdvancedWindow uiAdvancedConfig;
|
||||
Ui::AppearanceWindow uiAppConfig;
|
||||
Ui::ConfigWindow uiWidConfig;
|
||||
Ui::DEWindow uiDEConfig;
|
||||
Ui::TooltipWindow uiTooltipConfig;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QStringList diskDevices, keys, formatLine, foundKeys;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QStringList foundBars;
|
||||
};
|
||||
|
||||
|
||||
#endif /* AWESOME_WIDGET_H */
|
1172
sources/awesome-widget/configuration.cpp
Normal file
97
sources/awesome-widget/customlabel.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "customlabel.h"
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "awesome-widget.h"
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
|
||||
CustomLabel::CustomLabel(AwesomeWidget *wid, const bool debugCmd)
|
||||
: QLabel(0),
|
||||
widget(wid),
|
||||
debug(debugCmd)
|
||||
{
|
||||
setWordWrap(false);
|
||||
}
|
||||
|
||||
|
||||
CustomLabel::~CustomLabel()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
void CustomLabel::setPopupEnabled(const bool state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
enablePopup = state;
|
||||
}
|
||||
|
||||
|
||||
void CustomLabel::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Get signal" << event->button();
|
||||
|
||||
if ((enablePopup) && (event->button() == Qt::LeftButton)) {
|
||||
QString cmd, text;
|
||||
TaskResult process;
|
||||
|
||||
// kernel
|
||||
cmd = QString("uname -rsm");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
text += QString("Kernel: %1<br>").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
|
||||
// hostname
|
||||
cmd = QString("uname -n");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
text += QString("Hostname: %1<br>").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
|
||||
// whoami
|
||||
cmd = QString("whoami");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
text += QString("Whoami: %1<br>").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
|
||||
// uptime
|
||||
cmd = QString("uptime");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
text += QString("Uptime: %1").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
|
||||
|
||||
widget->sendNotification(QString("system"), text);
|
||||
}
|
||||
emit(QWidget::mousePressEvent(event));
|
||||
}
|
45
sources/awesome-widget/customlabel.h
Normal file
@ -0,0 +1,45 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CUSTOMLABEL_H
|
||||
#define CUSTOMLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
class AwesomeWidget;
|
||||
|
||||
class CustomLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomLabel(AwesomeWidget *wid, const bool debugCmd = false);
|
||||
~CustomLabel();
|
||||
void setPopupEnabled(const bool state);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
AwesomeWidget *widget;
|
||||
bool debug;
|
||||
bool enablePopup = true;
|
||||
};
|
||||
|
||||
|
||||
#endif /* CUSTOMLABEL_H */
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<class>DEWindow</class>
|
||||
<widget class="QWidget" name="DEWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>594</height>
|
||||
<height>582</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -29,7 +29,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string notr="true">DE</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
@ -43,91 +43,47 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>684</width>
|
||||
<height>578</height>
|
||||
<height>566</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_customCmd">
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_hddtempCmd">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_customCommand">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_customCommand">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_customCommand">
|
||||
<property name="toolTip">
|
||||
<string>Custom command to run</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_customCommand">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_customCommand">
|
||||
<property name="toolTip">
|
||||
<string>Editable
|
||||
del - remove item</string>
|
||||
<widget class="QLabel" name="label_hddtempCmd">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>hddtemp cmd</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_hddtempCmd"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_gpudev">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_gpudev">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>GPU device</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_gpudev">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">auto</string>
|
||||
@ -152,126 +108,77 @@ del - remove item</string>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_hdddev">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_hdddev">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>HDD</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_hdddev">
|
||||
<widget class="QComboBox" name="comboBox_hdddev"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_playerSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_playerSelect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Music player</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_playerSelect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">mpris</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">mpd</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_hddtempCmd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_hddtempCmd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>hddtemp cmd</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_hddtempCmd">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mpdaddress">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mpdaddress">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MPD address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mpdaddress">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mpdport">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mpdport">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MPD port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mpdport">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_mpdport">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_mpdport">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -288,25 +195,101 @@ del - remove item</string>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_pkgCommand">
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mpdaddress">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pkgCommandSelect">
|
||||
<widget class="QLabel" name="label_mpdaddress">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MPD address</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mpdaddress"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<spacer name="spacer_dataengine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_acpi">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_acpi">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ACPI path</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_acpi">
|
||||
<property name="toolTip">
|
||||
<string>"/sys/class/power_supply/" by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_mpris">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mprisInfo">
|
||||
<property name="text">
|
||||
<string><b>NOTE:</b> Player DBus interface should be an active</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mprisSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pkgCommand">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QLabel" name="label_mpris">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Package manager</string>
|
||||
<string>MPRIS player name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_pkgCommand">
|
||||
<widget class="QComboBox" name="comboBox_mpris">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -318,74 +301,118 @@ del - remove item</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">pacman -Qu</string>
|
||||
<string notr="true">auto</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">apt-show-versions -u -b</string>
|
||||
<string notr="true">amarok</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">aptitude search '~U'</string>
|
||||
<string notr="true">audacious</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">yum list updates</string>
|
||||
<string notr="true">clementine</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">pkg_version -I -l '<'</string>
|
||||
<string notr="true">deadbeef</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">urpmq --auto-select</string>
|
||||
<string notr="true">vlc</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">qmmp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">xmms2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_custom">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pkgCommandNum">
|
||||
<layout class="QHBoxLayout" name="layout_customAdd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pkgCommandNum">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_custom">
|
||||
<property name="text">
|
||||
<string>Number of null lines</string>
|
||||
<string>Custom scripts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_pkgCommandNum">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<spacer name="spacer_custom">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_custom">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_custom">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_pkgCommand">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pkgCommandAdd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pkgCommand">
|
||||
<property name="text">
|
||||
<string>Package manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_pkgCommand">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_pkgCommand">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
@ -395,80 +422,13 @@ del - remove item</string>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_pkgCommand">
|
||||
<property name="toolTip">
|
||||
<string>Editable
|
||||
del - remove item</string>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_playerSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_playerSelect">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Music player</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_playerSelect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">amarok</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">clementine</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">mpd</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">qmmp</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="spacer_dataengine">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>657</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
606
sources/awesome-widget/deinteraction.cpp
Normal file
@ -0,0 +1,606 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "awesome-widget.h"
|
||||
|
||||
#include <QRegExp>
|
||||
#include <math.h>
|
||||
|
||||
#include "graphicalitem.h"
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
void AwesomeWidget::connectToEngine()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
QRegExp regExp;
|
||||
|
||||
// battery
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)(ac|bat.*)"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("batteryTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
extsysmonEngine->connectSource(QString("battery"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// cpu
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)cpu(?!cl).*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("cpuTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->connectSource(QString("cpu/system/TotalLoad"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
for (int i=0; i<counts[QString("cpu")]; i++)
|
||||
sysmonEngine->connectSource(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// cpuclock
|
||||
regExp = QRegExp(QString("cpucl.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("cpuclTooltip")].toInt() == 2)) {
|
||||
sysmonEngine->connectSource(QString("cpu/system/AverageClock"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
for (int i=0; i<counts[QString("cpu")]; i++)
|
||||
sysmonEngine->connectSource(QString("cpu/cpu") + QString::number(i) + QString("/clock"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// custom command
|
||||
regExp = QRegExp(QString("custom.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("custom"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// desktop
|
||||
regExp = QRegExp(QString(".*desktop.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("desktop"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// disk speed
|
||||
regExp = QRegExp(QString("hdd[rw].*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("disk")].split(QString("@@")).count(); i++) {
|
||||
sysmonEngine->connectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/rblk"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/wblk"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// fan
|
||||
regExp = QRegExp(QString("fan.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("fanDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->connectSource(configuration[QString("fanDevice")].split(QString("@@"))[i],
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// gpu
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)gpu"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
extsysmonEngine->connectSource(QString("gpu"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// gputemp
|
||||
regExp = QRegExp(QString("gputemp"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("gputemp"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// mount
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb).*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
for (int i=0; i<configuration[QString("mount")].split(QString("@@")).count(); i++) {
|
||||
sysmonEngine->connectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/filllevel"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/freespace"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/usedspace"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// hddtemp
|
||||
regExp = QRegExp(QString("hddtemp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("hddtemp"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// memory
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)mem.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("memTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->connectSource(QString("mem/physical/free"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("mem/physical/used"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("mem/physical/application"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// network
|
||||
networkDeviceUpdate = 0;
|
||||
regExp = QRegExp(QString("(down|up|netdev)"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("downTooltip")].toInt() == 2)) {
|
||||
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// package manager
|
||||
regExp = QRegExp(QString("pkgcount.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("pkg"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// player
|
||||
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("player"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// ps
|
||||
regExp = QRegExp(QString("ps.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("ps"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// swap
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("swapTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->connectSource(QString("mem/swap/free"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("mem/swap/used"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// temp
|
||||
regExp = QRegExp(QString("temp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("tempDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->connectSource(configuration[QString("tempDevice")].split(QString("@@"))[i],
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// time
|
||||
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
timeEngine->connectSource(QString("Local"),
|
||||
this, 1000);
|
||||
// uptime
|
||||
regExp = QRegExp(QString("(^|c)uptime"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
sysmonEngine->connectSource(QString("system/uptime"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
|
||||
// regular expressions
|
||||
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
|
||||
QRegExp cpuclRegExp = QRegExp(QString("cpu/cpu.*/clock"));
|
||||
QRegExp hddrRegExp = QRegExp(QString("disk/.*/Rate/rblk"));
|
||||
QRegExp hddwRegExp = QRegExp(QString("disk/.*/Rate/wblk"));
|
||||
QRegExp mountFillRegExp = QRegExp(QString("partitions/.*/filllevel"));
|
||||
QRegExp mountFreeRegExp = QRegExp(QString("partitions/.*/freespace"));
|
||||
QRegExp mountUsedRegExp = QRegExp(QString("partitions/.*/usedspace"));
|
||||
QRegExp netRecRegExp = QRegExp(QString("network/interfaces/.*/receiver/data"));
|
||||
QRegExp netTransRegExp = QRegExp(QString("network/interfaces/.*/transmitter/data"));
|
||||
QRegExp tempRegExp = QRegExp(QString("lmsensors/.*"));
|
||||
|
||||
if (data.keys().isEmpty()) return;
|
||||
if (sourceName == QString("battery")) {
|
||||
for (int i=0; i<data.keys().count(); i++) {
|
||||
if (data.keys()[i] == QString("ac")) {
|
||||
if (data[QString("ac")].toBool())
|
||||
values[QString("ac")] = configuration[QString("acOnline")];
|
||||
else
|
||||
values[QString("ac")] = configuration[QString("acOffline")];
|
||||
} else {
|
||||
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*bat"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != data.keys()[i]) continue;
|
||||
values[foundBars[j]] = values[data.keys()[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((configuration[QString("batteryTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("bat")].toFloat()))) {
|
||||
if (tooltipValues[QString("bat")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("bat")].takeFirst();
|
||||
if (data[QString("ac")].toBool())
|
||||
tooltipValues[QString("bat")].append(data[QString("bat")].toFloat());
|
||||
else
|
||||
tooltipValues[QString("bat")].append(-data[QString("bat")].toFloat());
|
||||
}
|
||||
} else if (sourceName == QString("cpu/system/TotalLoad")) {
|
||||
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("cpu")) continue;
|
||||
values[foundBars[j]] = QString("%1").arg(data[QString("value")].toFloat());
|
||||
}
|
||||
}
|
||||
if ((configuration[QString("cpuTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("cpu")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("cpu")].takeFirst();
|
||||
tooltipValues[QString("cpu")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName.contains(cpuRegExp)) {
|
||||
QString number = sourceName;
|
||||
number.remove(QString("cpu/cpu"));
|
||||
number.remove(QString("/TotalLoad"));
|
||||
values[QString("cpu") + number] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != (QString("cpu") + number)) continue;
|
||||
values[foundBars[j]] = values[QString("cpu") + number];
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("cpu/system/AverageClock")) {
|
||||
values[QString("cpucl")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if ((configuration[QString("cpuclTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("cpucl")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("cpucl")].takeFirst();
|
||||
tooltipValues[QString("cpucl")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName.contains(cpuclRegExp)) {
|
||||
QString number = sourceName;
|
||||
number.remove(QString("cpu/cpu"));
|
||||
number.remove(QString("/clock"));
|
||||
values[QString("cpucl") + number] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
} else if (sourceName == QString("custom")) {
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
values[data.keys()[i]] = data[data.keys()[i]].toString();
|
||||
} else if (sourceName == QString("desktop")) {
|
||||
values[QString("desktop")] = data[QString("currentName")].toString();
|
||||
values[QString("ndesktop")] = QString("%1").arg(data[QString("currentNumber")].toInt());
|
||||
values[QString("tdesktops")] = QString("%1").arg(data[QString("number")].toInt());
|
||||
} else if (sourceName.contains(hddrRegExp)) {
|
||||
QString device = sourceName;
|
||||
device.remove(QString("/Rate/rblk"));
|
||||
for (int i=0; i<counts[QString("disk")]; i++)
|
||||
if (configuration[QString("disk")].split(QString("@@"))[i] == device) {
|
||||
values[QString("hddr") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName.contains(hddwRegExp)) {
|
||||
QString device = sourceName;
|
||||
device.remove(QString("/Rate/wblk"));
|
||||
for (int i=0; i<counts[QString("disk")]; i++)
|
||||
if (configuration[QString("disk")].split(QString("@@"))[i] == device) {
|
||||
values[QString("hddw") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName == QString("gpu")) {
|
||||
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*gpu"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("gpu")) continue;
|
||||
values[foundBars[j]] = values[QString("gpu")];
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("gputemp")) {
|
||||
values[QString("gputemp")] = QString("%1").arg(getTemp(data[QString("value")].toFloat()), 4, 'f', 1);
|
||||
} else if (sourceName.contains(mountFillRegExp)) {
|
||||
QString mount = sourceName;
|
||||
mount.remove(QString("partitions"));
|
||||
mount.remove(QString("/filllevel"));
|
||||
for (int i=0; i<counts[QString("mount")]; i++)
|
||||
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
|
||||
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*hdd([0-9].*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != (QString("hdd") + QString::number(i))) continue;
|
||||
values[foundBars[j]] = values[QString("hdd") + QString::number(i)];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(mountFreeRegExp)) {
|
||||
QString mount = sourceName;
|
||||
mount.remove(QString("partitions"));
|
||||
mount.remove(QString("/freespace"));
|
||||
for (int i=0; i<counts[QString("mount")]; i++)
|
||||
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
|
||||
values[QString("hddfreemb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("hddfreegb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName.contains(mountUsedRegExp)) {
|
||||
QString mount = sourceName;
|
||||
mount.remove(QString("partitions"));
|
||||
mount.remove(QString("/usedspace"));
|
||||
for (int i=0; i<counts[QString("mount")]; i++)
|
||||
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
|
||||
values[QString("hddmb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("hddgb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
// total
|
||||
values[QString("hddtotmb") + QString::number(i)] = QString("%1").arg(
|
||||
values[QString("hddfreemb") + QString::number(i)].toInt() +
|
||||
values[QString("hddmb") + QString::number(i)].toInt());
|
||||
values[QString("hddtotgb") + QString::number(i)] = QString("%1").arg(
|
||||
values[QString("hddfreegb") + QString::number(i)].toFloat() +
|
||||
values[QString("hddgb") + QString::number(i)].toFloat(),
|
||||
5, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName == QString("hddtemp")) {
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
for (int j=0; j<counts[QString("hddtemp")]; j++)
|
||||
if (data.keys()[i] == configuration[QString("hdd")].split(QString("@@"))[j]) {
|
||||
values[QString("hddtemp") + QString::number(j)] = QString("%1").arg(getTemp(data[data.keys()[i]].toFloat()), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName == QString("mem/physical/application")) {
|
||||
values[QString("memmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("memgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
} else if (sourceName == QString("mem/physical/free")) {
|
||||
values[QString("memfreemb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("memfreegb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
} else if (sourceName == QString("mem/physical/used")) {
|
||||
values[QString("memusedmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 0, 'f', 0);
|
||||
values[QString("memusedgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
// total
|
||||
values[QString("memtotmb")] = QString("%1").arg(
|
||||
values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
|
||||
values[QString("memtotgb")] = QString("%1").arg(
|
||||
values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(),
|
||||
4, 'f', 1);
|
||||
// percentage
|
||||
values[QString("mem")] = QString("%1").arg(100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
if ((configuration[QString("memTooltip")].toInt() == 2) &&
|
||||
(!isnan(values[QString("mem")].toFloat()))) {
|
||||
if (tooltipValues[QString("mem")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("mem")].takeFirst();
|
||||
tooltipValues[QString("mem")].append(values[QString("mem")].toFloat());
|
||||
}
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*mem"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("mem")) continue;
|
||||
values[foundBars[j]] = values[QString("mem")];
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(netRecRegExp)) {
|
||||
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if ((configuration[QString("downTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("down")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("down")].takeFirst();
|
||||
tooltipValues[QString("down")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
networkDeviceUpdate++;
|
||||
if (networkDeviceUpdate >= 30) {
|
||||
networkDeviceUpdate = 0;
|
||||
if (configuration[QString("useCustomNetdev")].toInt() == 0) {
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this);
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this);
|
||||
updateNetworkDevice(false);
|
||||
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(netTransRegExp)) {
|
||||
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if ((configuration[QString("downTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("up")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("up")].takeFirst();
|
||||
tooltipValues[QString("up")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName == QString("pkg")) {
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
values[data.keys()[i].toLower()] = QString("%1").arg(data[data.keys()[i]].toInt(), 2);
|
||||
} else if (sourceName == QString("player")) {
|
||||
values[QString("album")] = data[QString("album")].toString();
|
||||
values[QString("artist")] = data[QString("artist")].toString();
|
||||
values[QString("duration")] = data[QString("duration")].toString();
|
||||
values[QString("progress")] = data[QString("progress")].toString();
|
||||
values[QString("title")] = data[QString("title")].toString();
|
||||
} else if (sourceName == QString("ps")) {
|
||||
values[QString("ps")] = data[QString("ps")].toString();
|
||||
values[QString("pscount")] = QString("%1").arg(data[QString("psCount")].toInt(), 2);
|
||||
values[QString("pstotal")] = QString("%1").arg(data[QString("psTotal")].toInt(), 3);
|
||||
} else if (sourceName == QString("mem/swap/free")) {
|
||||
values[QString("swapfreemb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("swapfreegb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
} else if (sourceName == QString("mem/swap/used")) {
|
||||
values[QString("swapmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("swapgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
// total
|
||||
values[QString("swaptotmb")] = QString("%1").arg(
|
||||
values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
|
||||
values[QString("swaptotgb")] = QString("%1").arg(
|
||||
values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 4, 'f', 1);
|
||||
// percentage
|
||||
values[QString("swap")] = QString("%1").arg(100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
if ((configuration[QString("swapTooltip")].toInt() == 2) &&
|
||||
(!isnan(values[QString("swap")].toFloat()))) {
|
||||
if (tooltipValues[QString("swap")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("swap")].takeFirst();
|
||||
tooltipValues[QString("swap")].append(values[QString("swap")].toFloat());
|
||||
}
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*swap"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("swap")) continue;
|
||||
values[foundBars[j]] = values[QString("swap")];
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(tempRegExp)) {
|
||||
if (data[QString("units")].toString() == QString("rpm")) {
|
||||
for (int i=0; i<counts[QString("fan")]; i++)
|
||||
if (sourceName == configuration[QString("fanDevice")].split(QString("@@"))[i]) {
|
||||
values[QString("fan") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<counts[QString("temp")]; i++)
|
||||
if (sourceName == configuration[QString("tempDevice")].split(QString("@@"))[i]) {
|
||||
values[QString("temp") + QString::number(i)] = QString("%1").arg(getTemp(data[QString("value")].toFloat()), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("Local")) {
|
||||
values[QString("time")] = data[QString("DateTime")].toDateTime().toString(Qt::TextDate);
|
||||
values[QString("isotime")] = data[QString("DateTime")].toDateTime().toString(Qt::ISODate);
|
||||
values[QString("shorttime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleShortDate);
|
||||
values[QString("longtime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleLongDate);
|
||||
QStringList timeKeys = getTimeKeys();
|
||||
values[QString("ctime")] = configuration[QString("customTime")];
|
||||
for (int i=0; i<timeKeys.count(); i++)
|
||||
values[QString("ctime")].replace(QString("$") + timeKeys[i],
|
||||
data[QString("DateTime")].toDateTime().toString(timeKeys[i]));
|
||||
} else if (sourceName == QString("system/uptime")) {
|
||||
int uptime = data[QString("value")].toFloat();
|
||||
int seconds = uptime - uptime % 60;
|
||||
int minutes = seconds / 60 % 60;
|
||||
int hours = ((seconds / 60) - minutes) / 60 % 24;
|
||||
int days = (((seconds / 60) - minutes) / 60 - hours) / 24;
|
||||
values[QString("uptime")] = QString("%1d%2h%3m").arg(days, 3).arg(hours, 2).arg(minutes, 2);
|
||||
values[QString("cuptime")] = configuration[QString("customUptime")];
|
||||
values[QString("cuptime")].replace(QString("$dd"), QString("%1").arg(days, 3, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$d"), QString("%1").arg(days));
|
||||
values[QString("cuptime")].replace(QString("$hh"), QString("%1").arg(hours, 2, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$h"), QString("%1").arg(hours));
|
||||
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::disconnectFromEngine()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
QRegExp regExp;
|
||||
|
||||
// battery
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)(ac|bat.*)"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("batteryTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
extsysmonEngine->disconnectSource(QString("battery"), this);
|
||||
// cpu
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)cpu(?!cl).*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("cpuTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->disconnectSource(QString("cpu/system/TotalLoad"), this);
|
||||
for (int i=0; i<counts[QString("cpu")]; i++)
|
||||
sysmonEngine->disconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"), this);
|
||||
}
|
||||
// cpuclock
|
||||
regExp = QRegExp(QString("cpucl.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("cpuclTooltip")].toInt() == 2)) {
|
||||
sysmonEngine->disconnectSource(QString("cpu/system/AverageClock"), this);
|
||||
for (int i=0; i<counts[QString("cpu")]; i++)
|
||||
sysmonEngine->disconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/clock"), this);
|
||||
}
|
||||
// custom command
|
||||
regExp = QRegExp(QString("custom.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("custom"), this);
|
||||
// desktop
|
||||
regExp = QRegExp(QString(".*desktop.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("desktop"), this);
|
||||
// disk speed
|
||||
regExp = QRegExp(QString("hdd[rw].*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("disk")].split(QString("@@")).count(); i++) {
|
||||
sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/rblk"), this);
|
||||
sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/wblk"), this);
|
||||
}
|
||||
// fan
|
||||
regExp = QRegExp(QString("fan.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("fanDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->disconnectSource(configuration[QString("fanDevice")].split(QString("@@"))[i], this);
|
||||
// gpu
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)gpu"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
extsysmonEngine->disconnectSource(QString("gpu"), this);
|
||||
// gputemp
|
||||
regExp = QRegExp(QString("gputemp"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("gputemp"), this);
|
||||
// mount
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb).*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
for (int i=0; i<configuration[QString("mount")].split(QString("@@")).count(); i++) {
|
||||
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/filllevel"), this);
|
||||
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/freespace"), this);
|
||||
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/usedspace"), this);
|
||||
}
|
||||
// hddtemp
|
||||
regExp = QRegExp(QString("hddtemp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("hddtemp"), this);
|
||||
// memory
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)mem.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("memTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->disconnectSource(QString("mem/physical/free"), this);
|
||||
sysmonEngine->disconnectSource(QString("mem/physical/used"), this);
|
||||
sysmonEngine->disconnectSource(QString("mem/physical/application"), this);
|
||||
}
|
||||
// network
|
||||
regExp = QRegExp(QString("(down|up|netdev)"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("downTooltip")].toInt() == 2)) {
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this);
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this);
|
||||
}
|
||||
// package manager
|
||||
regExp = QRegExp(QString("pkgcount.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("pkg"), this);
|
||||
// player
|
||||
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("player"), this);
|
||||
// ps
|
||||
regExp = QRegExp(QString("ps.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("ps"), this);
|
||||
// swap
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("swapTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->disconnectSource(QString("mem/swap/free"), this);
|
||||
sysmonEngine->disconnectSource(QString("mem/swap/used"), this);
|
||||
}
|
||||
// temp
|
||||
regExp = QRegExp(QString("temp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("tempDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->disconnectSource(configuration[QString("tempDevice")].split(QString("@@"))[i], this);
|
||||
// time
|
||||
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
timeEngine->disconnectSource(QString("Local"), this);
|
||||
// uptime
|
||||
regExp = QRegExp(QString("(^|c)uptime"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
sysmonEngine->disconnectSource(QString("system/uptime"), this);
|
||||
}
|
12
sources/awesome-widget/desktops/aw-bat-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar3
|
||||
Comment=Simple bat bar
|
||||
X-AW-Value=bat
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
12
sources/awesome-widget/desktops/aw-cpu-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar0
|
||||
Comment=Simple cpu bar
|
||||
X-AW-Value=cpu
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
12
sources/awesome-widget/desktops/aw-mem-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar1
|
||||
Comment=Simple mem bar
|
||||
X-AW-Value=mem
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
12
sources/awesome-widget/desktops/aw-swap-bar.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar2
|
||||
Comment=Simple swap bar
|
||||
X-AW-Value=swap
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
25
sources/awesome-widget/desktops/bar-template.desktop
Normal file
@ -0,0 +1,25 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
# name should be barN and uniq
|
||||
Name=bar100500
|
||||
Comment=Template for the AW bars
|
||||
# value to show. Supported types are
|
||||
# cpu, cpu[0-9], mem, swap, bat
|
||||
X-AW-Value=cpu
|
||||
# active color, RGBA
|
||||
# you should use double quotes
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
# inactive color, RGBA
|
||||
# you should use double quotes
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
# bar type. Supported types are
|
||||
# Horizontal, Vertical, Circle
|
||||
X-AW-Type=Horizontal
|
||||
# direction. LeftToRight or RightToLeft
|
||||
X-AW-Direction=LeftToRight
|
||||
# height in pixels
|
||||
X-AW-Height=25
|
||||
# width in pixels
|
||||
X-AW-Width=100
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
523
sources/awesome-widget/graphicalitem.cpp
Normal file
@ -0,0 +1,523 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "graphicalitem.h"
|
||||
#include "ui_graphicalitem.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QColorDialog>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QGraphicsEllipseItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QSettings>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
m_fileName(desktopName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::GraphicalItem)
|
||||
{
|
||||
readConfiguration();
|
||||
|
||||
ui->setupUi(this);
|
||||
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::~GraphicalItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::image(const float value)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
|
||||
if (m_bar == QString("none")) return QString("");
|
||||
|
||||
QColor active = stringToColor(m_activeColor);
|
||||
QColor inactive = stringToColor(m_inactiveColor);
|
||||
float percent = value / 100.0;
|
||||
int scale[2] = {1, 1};
|
||||
QPen pen = QPen();
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
scene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
QGraphicsView *view = new QGraphicsView(scene);
|
||||
view->setStyleSheet(QString("background: transparent"));
|
||||
view->setContentsMargins(0, 0, 0, 0);
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->resize(m_width + 5.0, m_height + 5.0);
|
||||
|
||||
// paint
|
||||
switch(m_type) {
|
||||
case Vertical:
|
||||
pen.setWidth(m_width);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width,
|
||||
(1.0 - percent) * m_height - 0.5 * m_width, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(0.5 * m_width, (1.0 - percent) * m_height + 0.5 * m_width,
|
||||
0.5 * m_width, m_height + 0.5 * m_width, pen);
|
||||
// scale
|
||||
scale[1] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
case Circle:
|
||||
QGraphicsEllipseItem *circle;
|
||||
pen.setWidth(1.0);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(inactive, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- (1.0 - percent) * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0 - percent * 360.0 * 16.0);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(active, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- percent * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0);
|
||||
// scale
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
default:
|
||||
pen.setWidth(m_height);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(percent * m_width + 0.5 * m_height, 0.5 * m_height,
|
||||
m_width + 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(-0.5 * m_height, 0.5 * m_height,
|
||||
percent * m_width - 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// scale
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// convert
|
||||
QPixmap pixmap = QPixmap::grabWidget(view).transformed(QTransform().scale(scale[0], scale[1]));
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
pixmap.save(&buffer, "PNG");
|
||||
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
delete view;
|
||||
delete scene;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::bar()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_bar;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::activeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_activeColor;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::inactiveColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_inactiveColor;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Type GraphicalItem::type()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strType()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch(m_type) {
|
||||
case Vertical:
|
||||
value = QString("Vertical");
|
||||
break;
|
||||
case Circle:
|
||||
value = QString("Circle");
|
||||
break;
|
||||
default:
|
||||
value = QString("Horizontal");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Direction GraphicalItem::direction()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strDirection()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch (m_direction) {
|
||||
case RightToLeft:
|
||||
value = QString("RightToLeft");
|
||||
break;
|
||||
default:
|
||||
value = QString("LeftToRight");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::height()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_height;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::width()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setBar(const QString _bar)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
|
||||
|
||||
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("gpu")))) &&
|
||||
(!_bar.contains(QRegExp(QString("mem")))) &&
|
||||
(!_bar.contains(QRegExp(QString("swap")))) &&
|
||||
(!_bar.contains(QRegExp(QString("hdd[0-9].*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("bat.*")))))
|
||||
m_bar = QString("none");
|
||||
else
|
||||
m_bar = _bar;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setActiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_activeColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setInactiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_inactiveColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setType(const Type _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
m_type = _type;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrType(const QString _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
if (_type == QString("Vertical"))
|
||||
setType(Vertical);
|
||||
else if (_type == QString("Circle"))
|
||||
setType(Circle);
|
||||
else
|
||||
setType(Horizontal);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setDirection(const Direction _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
m_direction = _direction;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrDirection(const QString _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
if (_direction == QString("RightToLeft"))
|
||||
setDirection(RightToLeft);
|
||||
else
|
||||
setDirection(LeftToRight);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setHeight(const int _height)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
|
||||
if (_height <= 0) return;
|
||||
|
||||
m_height = _height;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setWidth(const int _width)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
|
||||
if (_width <= 0) return;
|
||||
|
||||
m_width = _width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWGIAPI).toInt());
|
||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||
setStrType(settings.value(QString("X-AW-Type"), strType()).toString());
|
||||
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
|
||||
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
||||
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::showConfiguration(const QStringList tags)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->label_nameValue->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->comboBox_value->addItems(tags);
|
||||
ui->comboBox_value->addItem(m_bar);
|
||||
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
|
||||
ui->pushButton_activeColor->setText(m_activeColor);
|
||||
ui->pushButton_inactiveColor->setText(m_inactiveColor);
|
||||
ui->comboBox_type->setCurrentIndex(static_cast<int>(m_type));
|
||||
ui->comboBox_direction->setCurrentIndex(static_cast<int>(m_direction));
|
||||
ui->spinBox_height->setValue(m_height);
|
||||
ui->spinBox_width->setValue(m_width);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
|
||||
setName(ui->label_nameValue->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWGIAPI);
|
||||
setBar(ui->comboBox_value->currentText());
|
||||
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
|
||||
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
|
||||
setStrType(ui->comboBox_type->currentText());
|
||||
setStrDirection(ui->comboBox_direction->currentText());
|
||||
setHeight(ui->spinBox_height->value());
|
||||
setWidth(ui->spinBox_width->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
|
||||
// check if exists
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||
settings.setValue(QString("X-AW-Type"), strType());
|
||||
settings.setValue(QString("X-AW-Direction"), strDirection());
|
||||
settings.setValue(QString("X-AW-Height"), m_height);
|
||||
settings.setValue(QString("X-AW-Width"), m_width);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::changeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QColor color = stringToColor(((QPushButton *)sender())->text());
|
||||
QColor newColor = QColorDialog::getColor(color, 0, i18n("Select color"),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
if (!newColor.isValid()) return;
|
||||
|
||||
QStringList colorText;
|
||||
colorText.append(QString("%1").arg(newColor.red()));
|
||||
colorText.append(QString("%1").arg(newColor.green()));
|
||||
colorText.append(QString("%1").arg(newColor.blue()));
|
||||
colorText.append(QString("%1").arg(newColor.alpha()));
|
||||
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
||||
}
|
||||
|
||||
|
||||
QColor GraphicalItem::stringToColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
QColor qcolor;
|
||||
QStringList listColor = _color.split(QChar(','));
|
||||
while (listColor.count() < 4)
|
||||
listColor.append(QString("0"));
|
||||
qcolor.setRed(listColor[0].toInt());
|
||||
qcolor.setGreen(listColor[1].toInt());
|
||||
qcolor.setBlue(listColor[2].toInt());
|
||||
qcolor.setAlpha(listColor[3].toInt());
|
||||
|
||||
return qcolor;
|
||||
}
|
115
sources/awesome-widget/graphicalitem.h
Normal file
@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GRAPHICALITEM_H
|
||||
#define GRAPHICALITEM_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GraphicalItem;
|
||||
}
|
||||
|
||||
class GraphicalItem : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||
Q_PROPERTY(Type type READ type WRITE setType)
|
||||
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
|
||||
Q_PROPERTY(int height READ height WRITE setHeight)
|
||||
Q_PROPERTY(int width READ width WRITE setWidth)
|
||||
|
||||
public:
|
||||
enum Direction {
|
||||
LeftToRight = 0,
|
||||
RightToLeft
|
||||
};
|
||||
enum Type {
|
||||
Horizontal = 0,
|
||||
Vertical,
|
||||
Circle
|
||||
};
|
||||
|
||||
explicit GraphicalItem(QWidget *parent = 0, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~GraphicalItem();
|
||||
QString fileName();
|
||||
QString image(const float value);
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString name();
|
||||
QString comment();
|
||||
QString bar();
|
||||
QString activeColor();
|
||||
QString inactiveColor();
|
||||
Type type();
|
||||
QString strType();
|
||||
Direction direction();
|
||||
QString strDirection();
|
||||
int height();
|
||||
int width();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setBar(const QString _bar = QString("cpu"));
|
||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
||||
void setType(const Type _type = Horizontal);
|
||||
void setStrType(const QString _type = QString("Horizontal"));
|
||||
void setDirection(const Direction _direction = LeftToRight);
|
||||
void setStrDirection(const QString _direction = QString("LeftToRight"));
|
||||
void setHeight(const int _height = 100);
|
||||
void setWidth(const int _width = 100);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
int showConfiguration(const QStringList tags = QStringList());
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private slots:
|
||||
void changeColor();
|
||||
|
||||
private:
|
||||
QColor stringToColor(const QString _color);
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::GraphicalItem *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
QString m_name = QString("none");
|
||||
QString m_comment = QString("empty");
|
||||
QString m_bar = QString("cpu");
|
||||
QString m_activeColor = QString("0,0,0,130");
|
||||
QString m_inactiveColor = QString("255,255,255,130");
|
||||
Type m_type = Horizontal;
|
||||
Direction m_direction = LeftToRight;
|
||||
int m_height = 100;
|
||||
int m_width = 100;
|
||||
};
|
||||
|
||||
|
||||
#endif /* GRAPHICALITEM_H */
|
293
sources/awesome-widget/graphicalitem.ui
Normal file
@ -0,0 +1,293 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GraphicalItem</class>
|
||||
<widget class="QDialog" name="GraphicalItem">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_name">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_nameValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_comment">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_comment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_comment"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_value">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_value">
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_value">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_activeColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_activeColor">
|
||||
<property name="text">
|
||||
<string>Active color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_activeColor">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_inactiveColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_inactiveColor">
|
||||
<property name="text">
|
||||
<string>Inactive color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_inactiveColor">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_type">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_type">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_type">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Circle</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_direction">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_direction">
|
||||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_direction">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">LeftToRight</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">RightToLeft</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_height">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_height">
|
||||
<property name="text">
|
||||
<string>Height</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_height">
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_width">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_width">
|
||||
<property name="text">
|
||||
<string>Width</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_width">
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>GraphicalItem</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>GraphicalItem</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
25
sources/awesome-widget/plasma-applet-awesomewidget.desktop
Normal file
@ -0,0 +1,25 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Awesome Widget
|
||||
Comment=A minimalistic Plasmoid
|
||||
Comment[en]=A minimalistic Plasmoid
|
||||
Comment[es]=Un plasmoide minimalista
|
||||
Comment[es]=Un script Plasmoïde minimaliste
|
||||
Comment[pt_BR]=Um script Plasmoid
|
||||
Comment[ru]=Минималистичный плазмоид
|
||||
Comment[uk]=Мінімалістичний плазмоїд
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-Library=plasma_applet_awesome-widget
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=awesome-widget
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
14
sources/awesome-widget/plasma_applet_awesome-widget.notifyrc
Normal file
@ -0,0 +1,14 @@
|
||||
[Global]
|
||||
IconName=system
|
||||
Name=Awesome Widget
|
||||
Comment=Awesome widget information
|
||||
|
||||
[Event/system]
|
||||
Name=System information
|
||||
Comment=System information
|
||||
Action=Popup
|
||||
|
||||
[Event/tag]
|
||||
Name=Tag information
|
||||
Comment=Tag information
|
||||
Action=Popup
|
166
sources/awesome-widget/reinit.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "awesome-widget.h"
|
||||
|
||||
#include <KNotification>
|
||||
#include <Plasma/ToolTipManager>
|
||||
#include <QGraphicsGridLayout>
|
||||
#include <QGraphicsView>
|
||||
#include <math.h>
|
||||
|
||||
#include "customlabel.h"
|
||||
#include "graphicalitem.h"
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
void AwesomeWidget::reinit()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (configuration[QString("background")].toInt() == 0)
|
||||
setBackgroundHints(NoBackground);
|
||||
if (configuration[QString("popup")].toInt() == 0)
|
||||
textLabel->setPopupEnabled(false);
|
||||
else
|
||||
textLabel->setPopupEnabled(true);
|
||||
updateText(true);
|
||||
|
||||
keys = getKeys();
|
||||
foundKeys = findKeys();
|
||||
getGraphicalItems();
|
||||
foundBars = findGraphicalItems();
|
||||
updateNetworkDevice(false);
|
||||
connectToEngine();
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::sendNotification(const QString eventId, const QString message)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||
|
||||
KNotification *notification = new KNotification(eventId);
|
||||
notification->setComponentData(KComponentData("plasma_applet_awesome-widget"));
|
||||
notification->setTitle(QString("Awesome Widget ::: ") + eventId);
|
||||
notification->setText(message);
|
||||
notification->sendEvent();
|
||||
delete notification;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::updateNetworkDevice(const bool delay)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (delay)
|
||||
networkDeviceUpdate = 30;
|
||||
else
|
||||
values[QString("netdev")] = getNetworkDevice();
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::updateText(const bool clear)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString text = configuration[QString("text")];
|
||||
if (!clear) {
|
||||
text.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
text.replace(QString("$") + foundKeys[i], values[foundKeys[i]]);
|
||||
for (int i=0; i<foundBars.count(); i++)
|
||||
text.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->image(values[foundBars[i]].toFloat()));
|
||||
text.replace(QString("$\\$\\"), QString("$$"));
|
||||
}
|
||||
textLabel->setText(formatLine[0] + text + formatLine[1]);
|
||||
mainLayout->itemAt(0, 0)->updateGeometry();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::updateTooltip()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
toolTipView->resize(100.0 * counts[QString("tooltip")], 105.0);
|
||||
// boundaries
|
||||
QMap<QString, float> boundaries;
|
||||
boundaries[QString("cpu")] = 100.0;
|
||||
boundaries[QString("cpucl")] = 4000.0;
|
||||
boundaries[QString("mem")] = 100.0;
|
||||
boundaries[QString("swap")] = 100.0;
|
||||
boundaries[QString("down")] = 1.0;
|
||||
if (configuration[QString("downTooltip")].toInt() == 2) {
|
||||
for (int i=0; i<tooltipValues[QString("down")].count(); i++)
|
||||
if (boundaries[QString("down")] < tooltipValues[QString("down")][i])
|
||||
boundaries[QString("down")] = tooltipValues[QString("down")][i];
|
||||
for (int i=0; i<tooltipValues[QString("up")].count(); i++)
|
||||
if (boundaries[QString("down")] < tooltipValues[QString("up")][i])
|
||||
boundaries[QString("down")] = tooltipValues[QString("up")][i];
|
||||
boundaries[QString("down")] *= 1.2;
|
||||
}
|
||||
boundaries[QString("up")] = boundaries[QString("down")];
|
||||
boundaries[QString("bat")] = 100.0;
|
||||
|
||||
// create image
|
||||
toolTipScene->clear();
|
||||
QPen pen = QPen();
|
||||
if (configuration[QString("useTooltipBackground")].toInt() == 2)
|
||||
toolTipScene->setBackgroundBrush(QColor(configuration[QString("tooltipBackground")]));
|
||||
else
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
bool down = false;
|
||||
bool isBattery = false;
|
||||
QStringList trueKeys;
|
||||
if (tooltipValues.contains(QString("cpu"))) trueKeys.append(QString("cpu"));
|
||||
if (tooltipValues.contains(QString("cpucl"))) trueKeys.append(QString("cpucl"));
|
||||
if (tooltipValues.contains(QString("mem"))) trueKeys.append(QString("mem"));
|
||||
if (tooltipValues.contains(QString("swap"))) trueKeys.append(QString("swap"));
|
||||
if (tooltipValues.contains(QString("down"))) trueKeys.append(QString("down"));
|
||||
if (tooltipValues.contains(QString("up"))) trueKeys.append(QString("up"));
|
||||
if (tooltipValues.contains(QString("bat"))) trueKeys.append(QString("bat"));
|
||||
for (int i=0; i<trueKeys.count(); i++) {
|
||||
float normX = 100.0 / (float)tooltipValues[trueKeys[i]].count();
|
||||
float normY = 100.0 / (1.5 * boundaries[trueKeys[i]]);
|
||||
if (trueKeys[i] == QString("bat"))
|
||||
isBattery = true;
|
||||
else
|
||||
isBattery = false;
|
||||
if (!isBattery) pen.setColor(QColor(configuration[trueKeys[i] + QString("Color")]));
|
||||
float shift = i * 100.0;
|
||||
if (down) shift -= 100.0;
|
||||
for (int j=0; j<tooltipValues[trueKeys[i]].count()-1; j++) {
|
||||
float x1 = j * normX + shift;
|
||||
float y1 = - fabs(tooltipValues[trueKeys[i]][j]) * normY + 5.0;
|
||||
float x2 = (j + 1) * normX + shift;
|
||||
float y2 = - fabs(tooltipValues[trueKeys[i]][j+1]) * normY + 5.0;
|
||||
if (isBattery) {
|
||||
if (tooltipValues[trueKeys[i]][j+1] > 0)
|
||||
pen.setColor(QColor(configuration[QString("batteryColor")]));
|
||||
else
|
||||
pen.setColor(QColor(configuration[QString("batteryInColor")]));
|
||||
}
|
||||
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
||||
}
|
||||
if (trueKeys[i] == QString("down")) down = true;
|
||||
}
|
||||
|
||||
toolTip.setImage(QPixmap::grabWidget(toolTipView));
|
||||
Plasma::ToolTipManager::self()->setContent(this, toolTip);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<class>TooltipWindow</class>
|
||||
<widget class="QWidget" name="TooltipWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -29,7 +29,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string notr="true">Tooltip</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
@ -64,41 +64,16 @@
|
||||
<layout class="QHBoxLayout" name="layout_tooltipNum">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_tooltipNum">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number of values for tooltips</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_tooltipNum">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>19</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_tooltipNum">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_tooltipNum">
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
@ -116,243 +91,177 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_cpuclockColor">
|
||||
<layout class="QHBoxLayout" name="layout_background">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_cpuclockColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QCheckBox" name="checkBox_background">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CPU clock color</string>
|
||||
<string>Background</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_cpuclockColor">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_cpuclock">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_swapColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_swapColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Swap color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_swapColor">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_swap">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KColorCombo" name="kcolorcombo_background"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_cpuColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_cpuColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QCheckBox" name="checkBox_cpu">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CPU color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_cpuColor">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_cpu">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KColorCombo" name="kcolorcombo_cpu"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_downColor">
|
||||
<layout class="QHBoxLayout" name="layout_cpuclockColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_downColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QCheckBox" name="checkBox_cpuclock">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Download speed color</string>
|
||||
<string>CPU clock color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_downColor">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_down">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KColorCombo" name="kcolorcombo_cpuclock"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_memColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_memColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QCheckBox" name="checkBox_mem">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Memory color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_memColor">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="KColorCombo" name="kcolorcombo_mem"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_swapColor">
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_mem">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QCheckBox" name="checkBox_swap">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Swap color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_swap"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_downColor">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_down">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Download speed color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_down"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_upColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_upColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_up">
|
||||
<property name="text">
|
||||
<string>Upload speed color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_upColor">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="KColorCombo" name="kcolorcombo_up"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_batteryColor">
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_up">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QCheckBox" name="checkBox_battery">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Battery active color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_battery"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_batteryInColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_batteryIn">
|
||||
<property name="text">
|
||||
<string>Battery inactive color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_batteryIn"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -381,15 +290,6 @@
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>spinBox_tooltipNum</tabstop>
|
||||
<tabstop>kcolorcombo_cpuclock</tabstop>
|
||||
<tabstop>kcolorcombo_swap</tabstop>
|
||||
<tabstop>kcolorcombo_cpu</tabstop>
|
||||
<tabstop>kcolorcombo_down</tabstop>
|
||||
<tabstop>kcolorcombo_mem</tabstop>
|
||||
<tabstop>kcolorcombo_up</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
228
sources/awesome-widget/widget.ui
Normal file
@ -0,0 +1,228 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>700</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Widget</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Detailed information may be found on <a href="http://arcanis.name/projects/awesome-widgets/">project homepage</a></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layput_mainFormating">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_font">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_br">
|
||||
<property name="icon">
|
||||
<iconset theme="stock_text_indent">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainFormatingCenter1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bold">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-bold">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_italic">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-italic">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_underline">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-underline">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+U</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_strike">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-strikethrough">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainFormatingCenter2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_left">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-left">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_center">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-center">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_right">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-right">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_fill">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-fill">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainFormatingCenter3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_tags">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_tags">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit_elements">
|
||||
<property name="lineWrapMode">
|
||||
<enum>QTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,27 +1,34 @@
|
||||
# set project name
|
||||
set (SUBPROJECT plasma_engine_extsysmon)
|
||||
set (SUBPROJECT plasma_applet_desktop-panel)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
|
||||
include (KDE4Defaults)
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
|
||||
# set sources
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
357
sources/desktop-panel/appearance.ui
Normal file
@ -0,0 +1,357 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AppearanceWidget</class>
|
||||
<widget class="QWidget" name="AppearanceWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>343</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>480</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Apearance</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_active">
|
||||
<attribute name="title">
|
||||
<string>Active desktop</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea_active">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_active">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>448</width>
|
||||
<height>289</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontActive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontActive">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="fontComboBox_fontActive"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontSizeActive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontSizeActive">
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontSizeActive">
|
||||
<property name="minimum">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>48</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontColorActive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontColorActive">
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_fontColorActive"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontWeightActive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontWeightActive">
|
||||
<property name="text">
|
||||
<string>Font weight</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontWeightActive">
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>900</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>400</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontStyleActive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontStyleActive">
|
||||
<property name="text">
|
||||
<string>Font style</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_fontStyleActive">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">normal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">italic</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_active">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>119</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_inactive">
|
||||
<attribute name="title">
|
||||
<string>Inactive desktop</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea_inactive">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_inactive">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>448</width>
|
||||
<height>289</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontInactive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontInactive">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFontComboBox" name="fontComboBox_fontInactive"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontSizeInactive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontSizeInactive">
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontSizeInactive">
|
||||
<property name="minimum">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>48</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontColorInactive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontColorInactive">
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_fontColorInactive"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontWeightInactive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontWeightInactive">
|
||||
<property name="text">
|
||||
<string>Font weight</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fontWeightInactive">
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>900</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>400</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontStyleInactive">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontStyleInactive">
|
||||
<property name="text">
|
||||
<string>Font style</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_fontStyleInactive">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">normal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">italic</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_inactive">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>119</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
634
sources/desktop-panel/desktop-panel.cpp
Normal file
@ -0,0 +1,634 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "desktop-panel.h"
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#include <KWindowSystem>
|
||||
#include <Plasma/Containment>
|
||||
#include <Plasma/Corona>
|
||||
#include <Plasma/Theme>
|
||||
#include <Plasma/ToolTipManager>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFile>
|
||||
#include <QGraphicsGridLayout>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QMouseEvent>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTextCodec>
|
||||
#include <QTimer>
|
||||
|
||||
#include <fontdialog/fontdialog.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
CustomPlasmaLabel::CustomPlasmaLabel(DesktopPanel *wid, const int num, const bool debugCmd)
|
||||
: QLabel(0),
|
||||
debug(debugCmd),
|
||||
number(num),
|
||||
widget(wid)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Init label" << number;
|
||||
}
|
||||
|
||||
|
||||
CustomPlasmaLabel::~CustomPlasmaLabel()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
int CustomPlasmaLabel::getNumber()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
void CustomPlasmaLabel::enterEvent(QEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Event" << event->type();
|
||||
|
||||
if (event->type() == QEvent::Enter)
|
||||
widget->paintTooltip(number);
|
||||
|
||||
emit(QLabel::enterEvent(event));
|
||||
}
|
||||
|
||||
|
||||
void CustomPlasmaLabel::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Get signal" << event->button();
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
widget->setCurrentDesktop(number);
|
||||
emit(QLabel::mousePressEvent(event));
|
||||
}
|
||||
|
||||
|
||||
|
||||
DesktopPanel::DesktopPanel(QObject *parent, const QVariantList &args)
|
||||
: Plasma::Applet(parent, args)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
debug = false;
|
||||
|
||||
setBackgroundHints(DefaultBackground);
|
||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
||||
setHasConfigurationInterface(true);
|
||||
// text format init
|
||||
currentFormatLine.append(QString(""));
|
||||
currentFormatLine.append(QString(""));
|
||||
formatLine.append(QString(""));
|
||||
formatLine.append(QString(""));
|
||||
}
|
||||
|
||||
|
||||
DesktopPanel::~DesktopPanel()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::init()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
layout = new QGraphicsGridLayout();
|
||||
layout->setContentsMargins(1, 1, 1, 1);
|
||||
setLayout(layout);
|
||||
|
||||
// tooltip
|
||||
toolTip = Plasma::ToolTipContent();
|
||||
toolTipScene = new QGraphicsScene();
|
||||
toolTipView = new QGraphicsView(toolTipScene);
|
||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||
toolTipView->setFrameShape(QFrame::NoFrame);
|
||||
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
Plasma::ToolTipManager::self()->setContent(this, toolTip);
|
||||
|
||||
// read variables
|
||||
configChanged();
|
||||
connect(this, SIGNAL(activate()), this, SLOT(changePanelsState()));
|
||||
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SLOT(updateText(int)));
|
||||
}
|
||||
|
||||
|
||||
DesktopPanel::DesktopWindowsInfo DesktopPanel::getInfoByDesktop(const int num)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number" << num;
|
||||
|
||||
|
||||
DesktopWindowsInfo info;
|
||||
info.desktop = KWindowSystem::workArea(num);
|
||||
|
||||
QList<WId> windows = KWindowSystem::windows();
|
||||
for (int i=0; i<windows.count(); i++) {
|
||||
KWindowInfo winInfo = KWindowSystem::windowInfo(windows[i],
|
||||
NET::Property::WMDesktop | NET::Property::WMGeometry |
|
||||
NET::Property::WMState | NET::Property::WMWindowType);
|
||||
if (!winInfo.isOnDesktop(num)) continue;
|
||||
if (winInfo.windowType(NET::WindowTypeMask::NormalMask) == NET::WindowType::Normal) {
|
||||
if (winInfo.isMinimized()) continue;
|
||||
info.windows.append(winInfo.geometry());
|
||||
info.winId.append(windows[i]);
|
||||
} else if (winInfo.windowType(NET::WindowTypeMask::DesktopMask) == NET::WindowType::Desktop) {
|
||||
info.desktopId.append(windows[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QList<Plasma::Containment *> DesktopPanel::getPanels()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<Plasma::Containment *> panels;
|
||||
for (int i=0; i<containment()->corona()->containments().count(); i++)
|
||||
if (containment()->corona()->containments()[i]->containmentType() == Plasma::Containment::PanelContainment)
|
||||
panels.append(containment()->corona()->containments()[i]);
|
||||
|
||||
return panels;
|
||||
}
|
||||
|
||||
|
||||
QString DesktopPanel::panelLocationToStr(Plasma::Location loc)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Location" << loc;
|
||||
|
||||
switch (loc) {
|
||||
case Plasma::TopEdge:
|
||||
return i18n("Top Edge");
|
||||
case Plasma::BottomEdge:
|
||||
return i18n("Bottom Edge");
|
||||
case Plasma::LeftEdge:
|
||||
return i18n("Left Edge");
|
||||
case Plasma::RightEdge:
|
||||
return i18n("Right Edge");
|
||||
default:
|
||||
return i18n("Unknown Position (%1)", loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString DesktopPanel::parsePattern(const QString rawLine, const int num)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Raw line" << rawLine;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number" << num;
|
||||
|
||||
QString line, fullMark, mark;
|
||||
line = rawLine;
|
||||
if (KWindowSystem::currentDesktop() == num + 1)
|
||||
mark = configuration[QString("mark")];
|
||||
else
|
||||
mark = QString("");
|
||||
fullMark = QString("%1").arg(mark, configuration[QString("mark")].count(), QLatin1Char(' '));
|
||||
if (line.contains(QString("$fullmark")))
|
||||
line.replace(QString("$fullmark"), fullMark);
|
||||
if (line.contains(QString("$mark")))
|
||||
line.replace(QString("$mark"), mark);
|
||||
if (line.contains(QString("$name")))
|
||||
line.replace(QString("$name"), desktopNames[num]);
|
||||
if (line.contains(QString("$number")))
|
||||
line.replace(QString("$number"), QString::number(num + 1));
|
||||
if (line.contains(QString("$total")))
|
||||
line.replace(QString("$total"), QString::number(desktopNames.count()));
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::reinit()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// clear
|
||||
// labels
|
||||
for (int i=0; i<proxyWidgets.count(); i++) {
|
||||
layout->removeItem(proxyWidgets[i]);
|
||||
proxyWidgets[i]->setWidget(0);
|
||||
delete labels[i];
|
||||
delete proxyWidgets[i];
|
||||
}
|
||||
labels.clear();
|
||||
proxyWidgets.clear();
|
||||
desktopNames.clear();
|
||||
|
||||
// add
|
||||
int total = KWindowSystem::numberOfDesktops();
|
||||
for (int i=1; i<total+1; i++)
|
||||
desktopNames.append(KWindowSystem::desktopName(i));
|
||||
// layout
|
||||
if (configuration[QString("background")].toInt() == 0)
|
||||
setBackgroundHints(NoBackground);
|
||||
// labels
|
||||
for (int i=0; i<desktopNames.count(); i++) {
|
||||
proxyWidgets.append(new QGraphicsProxyWidget(this));
|
||||
labels.append(new CustomPlasmaLabel(this, i, debug));
|
||||
labels[i]->setWordWrap(false);
|
||||
labels[i]->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
proxyWidgets[i]->setWidget(labels[i]);
|
||||
if (configuration[QString("layout")].toInt() == 0)
|
||||
layout->addItem(proxyWidgets[i], 0, i);
|
||||
else
|
||||
layout->addItem(proxyWidgets[i], i, 0);
|
||||
}
|
||||
|
||||
updateText(KWindowSystem::currentDesktop());
|
||||
for (int i=0; i<proxyWidgets.count(); i++) {
|
||||
labels[i]->adjustSize();
|
||||
proxyWidgets[i]->setGeometry(labels[i]->geometry());
|
||||
}
|
||||
emit(KWindowSystem::setCurrentDesktop(KWindowSystem::currentDesktop()));
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::changePanelsState()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<Plasma::Containment *> panels = getPanels();
|
||||
for (int i=0; i<panels.count(); i++) {
|
||||
if ((!configuration[QString("panels")].split(QChar(','))
|
||||
.contains(QString::number(i))) &&
|
||||
(configuration[QString("panels")] != QString("-1")))
|
||||
continue;
|
||||
bool wasVisible = panels[i]->view()->isVisible();
|
||||
int winId = panels[i]->view()->winId();
|
||||
if (wasVisible) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Hide panel";
|
||||
KWindowInfo oldInfo = KWindowSystem::windowInfo(winId, NET::WMState);
|
||||
oldState = oldInfo.state();
|
||||
panels[i]->view()->setVisible(false);
|
||||
} else {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Show panel";
|
||||
panels[i]->view()->setVisible(true);
|
||||
KWindowSystem::clearState(winId, NET::KeepAbove);
|
||||
KWindowSystem::setState(winId, oldState | NET::StaysOnTop);
|
||||
KWindowSystem::setOnAllDesktops(winId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::paintTooltip(const int active)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (active == activeTooltip) return;
|
||||
|
||||
// prepare
|
||||
// clear
|
||||
toolTip.setImage(0);
|
||||
toolTip.setWindowsToPreview(QList<WId>());
|
||||
activeTooltip = active;
|
||||
DesktopWindowsInfo info = getInfoByDesktop(active + 1);
|
||||
float margin = 5.0 * info.desktop.width() / 400.0;
|
||||
toolTipView->resize(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin);
|
||||
toolTipScene->clear();
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
// borders
|
||||
toolTipScene->addLine(0, 0, 0, info.desktop.height() + 2.0 * margin);
|
||||
toolTipScene->addLine(0, info.desktop.height() + 2.0 * margin,
|
||||
info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin);
|
||||
toolTipScene->addLine(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin,
|
||||
info.desktop.width() + 2.0 * margin, 0);
|
||||
toolTipScene->addLine(info.desktop.width() + 2.0 * margin, 0, 0, 0);
|
||||
|
||||
if (configuration[QString("tooltipType")].toInt() == 1) {
|
||||
// only contours
|
||||
QPen pen = QPen();
|
||||
pen.setWidthF(2.0 * info.desktop.width() / 400.0);
|
||||
pen.setColor(QColor(configuration[QString("tooltipColor")]));
|
||||
for (int i=0; i<info.windows.count(); i++) {
|
||||
toolTipScene->addLine(info.windows[i].left() + margin, info.windows[i].bottom() + margin,
|
||||
info.windows[i].left() + margin, info.windows[i].top() + margin, pen);
|
||||
toolTipScene->addLine(info.windows[i].left() + margin, info.windows[i].top() + margin,
|
||||
info.windows[i].right() + margin, info.windows[i].top() + margin, pen);
|
||||
toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].top() + margin,
|
||||
info.windows[i].right() + margin, info.windows[i].bottom() + margin, pen);
|
||||
toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].bottom() + margin,
|
||||
info.windows[i].left() + margin, info.windows[i].bottom() + margin, pen);
|
||||
}
|
||||
toolTip.setImage(QPixmap::grabWidget(toolTipView).scaledToWidth(configuration[QString("tooltipWidth")].toInt()));
|
||||
} else if (configuration[QString("tooltipType")].toInt() == 2) {
|
||||
// clean desktop
|
||||
toolTip.setWindowsToPreview(info.desktopId);
|
||||
} else {
|
||||
// desktop preview
|
||||
toolTip.setWindowsToPreview(info.winId);
|
||||
}
|
||||
|
||||
Plasma::ToolTipManager::self()->setContent(this, toolTip);
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::setCurrentDesktop(const int number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Set desktop" << number + 1;
|
||||
|
||||
KWindowSystem::setCurrentDesktop(number + 1);
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::updateText(const int active)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString line, text;
|
||||
for (int i=0; i<labels.count(); i++) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Label" << i;
|
||||
line = parsePattern(configuration[QString("pattern")], i);
|
||||
if (active == i + 1)
|
||||
text = currentFormatLine[0] + line + currentFormatLine[1];
|
||||
else
|
||||
text = formatLine[0] + line + formatLine[1];
|
||||
labels[i]->setText(text);
|
||||
}
|
||||
int height = 0;
|
||||
int width = 0;
|
||||
for (int i=0; i<proxyWidgets.count(); i++) {
|
||||
labels[i]->adjustSize();
|
||||
proxyWidgets[i]->setGeometry(labels[i]->geometry());
|
||||
if (configuration[QString("layout")].toInt() == 0) {
|
||||
width += proxyWidgets[i]->geometry().width();
|
||||
if (height < proxyWidgets[i]->geometry().height())
|
||||
height = proxyWidgets[i]->geometry().height();
|
||||
} else {
|
||||
height += proxyWidgets[i]->geometry().height();
|
||||
if (width < proxyWidgets[i]->geometry().width())
|
||||
width = proxyWidgets[i]->geometry().width();
|
||||
}
|
||||
}
|
||||
layout->setMinimumSize(width, height);
|
||||
}
|
||||
|
||||
|
||||
// configuration interface
|
||||
void DesktopPanel::createConfigurationInterface(KConfigDialog *parent)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QWidget *appWidget = new QWidget;
|
||||
uiAppConfig.setupUi(appWidget);
|
||||
QWidget *configWidget = new QWidget;
|
||||
uiWidConfig.setupUi(configWidget);
|
||||
QWidget *toggleWidget = new QWidget;
|
||||
uiToggleConfig.setupUi(toggleWidget);
|
||||
|
||||
uiWidConfig.textEdit_elements->setPlainText(configuration[QString("pattern")]);
|
||||
if (configuration[QString("tooltip")].toInt() == 0)
|
||||
uiWidConfig.checkBox_tooltip->setCheckState(Qt::Unchecked);
|
||||
else
|
||||
uiWidConfig.checkBox_tooltip->setCheckState(Qt::Checked);
|
||||
uiWidConfig.comboBox_tooltipType->setCurrentIndex(configuration[QString("tooltipType")].toInt());
|
||||
uiWidConfig.spinBox_tooltip->setValue(configuration[QString("tooltipWidth")].toInt());
|
||||
uiWidConfig.kcolorcombo_tooltipColor->setColor(QColor(configuration[QString("tooltipColor")]));
|
||||
if (configuration[QString("background")].toInt() == 0)
|
||||
uiWidConfig.checkBox_background->setCheckState(Qt::Unchecked);
|
||||
else
|
||||
uiWidConfig.checkBox_background->setCheckState(Qt::Checked);
|
||||
if (configuration[QString("layout")].toInt() == 0)
|
||||
uiWidConfig.checkBox_layout->setCheckState(Qt::Unchecked);
|
||||
else
|
||||
uiWidConfig.checkBox_layout->setCheckState(Qt::Checked);
|
||||
uiWidConfig.comboBox_mark->setItemText(uiWidConfig.comboBox_mark->count()-1, configuration[QString("mark")]);
|
||||
uiWidConfig.comboBox_mark->setCurrentIndex(uiWidConfig.comboBox_mark->count()-1);
|
||||
|
||||
KConfigGroup cg = config();
|
||||
CFont font(cg.readEntry("currentFontFamily", "Terminus"));
|
||||
font.setPointSize(cg.readEntry("currentFontSize", 10));
|
||||
font.setCurrentColor(QColor(cg.readEntry("currentFontColor", "#ff0000")));
|
||||
font.setHtmlWeight(cg.readEntry("currentFontWeight", 400));
|
||||
font.setItalic(cg.readEntry("currentFontStyle", "normal") == QString("italic"));
|
||||
uiAppConfig.fontComboBox_fontActive->setCurrentFont(font.toQFont());
|
||||
uiAppConfig.spinBox_fontSizeActive->setValue(font.pointSize());
|
||||
uiAppConfig.kcolorcombo_fontColorActive->setColor(font.color());
|
||||
if (font.italic())
|
||||
uiAppConfig.comboBox_fontStyleActive->setCurrentIndex(1);
|
||||
else
|
||||
uiAppConfig.comboBox_fontStyleActive->setCurrentIndex(0);
|
||||
uiAppConfig.spinBox_fontWeightActive->setValue(font.htmlWeight());
|
||||
|
||||
font = CFont(cg.readEntry("fontFamily", "Terminus"));
|
||||
font.setPointSize(cg.readEntry("fontSize", 10));
|
||||
font.setCurrentColor(QColor(cg.readEntry("fontColor", "#000000")));
|
||||
font.setHtmlWeight(cg.readEntry("fontWeight", 400));
|
||||
font.setItalic(cg.readEntry("fontStyle", "normal") == QString("italic"));
|
||||
uiAppConfig.fontComboBox_fontInactive->setCurrentFont(font.toQFont());
|
||||
uiAppConfig.spinBox_fontSizeInactive->setValue(font.pointSize());
|
||||
uiAppConfig.kcolorcombo_fontColorInactive->setColor(font.color());
|
||||
if (font.italic())
|
||||
uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(1);
|
||||
else
|
||||
uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(0);
|
||||
uiAppConfig.spinBox_fontWeightInactive->setValue(font.htmlWeight());
|
||||
|
||||
uiToggleConfig.listWidget_list->clear();
|
||||
QList<Plasma::Containment *> panels = getPanels();
|
||||
for (int i=0; i<panels.count(); i++) {
|
||||
QListWidgetItem *item = new QListWidgetItem(panelLocationToStr(panels[i]->location()), uiToggleConfig.listWidget_list);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
if ((configuration[QString("panels")].split(QChar(','))
|
||||
.contains(QString::number(i))) ||
|
||||
(configuration[QString("panels")] == QString("-1")))
|
||||
item->setCheckState(Qt::Checked);
|
||||
else
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
parent->addPage(configWidget, i18n("Widget"), Applet::icon());
|
||||
parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme"));
|
||||
parent->addPage(toggleWidget, i18n("Toggle panels"), QString("plasma"));
|
||||
|
||||
connect(uiWidConfig.pushButton_tags, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_br, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_font, SIGNAL(clicked(bool)), this, SLOT(setFontFormating()));
|
||||
connect(uiWidConfig.pushButton_bold, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_italic, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_underline, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_strike, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_left, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_center, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_right, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
connect(uiWidConfig.pushButton_fill, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
|
||||
|
||||
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
||||
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::configAccepted()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
KConfigGroup cg = config();
|
||||
|
||||
cg.writeEntry("pattern", uiWidConfig.textEdit_elements->toPlainText());
|
||||
cg.writeEntry("tooltip", QString::number(uiWidConfig.checkBox_tooltip->checkState()));
|
||||
cg.writeEntry("tooltipType", QString::number(uiWidConfig.comboBox_tooltipType->currentIndex()));
|
||||
cg.writeEntry("tooltipWidth", QString::number(uiWidConfig.spinBox_tooltip->value()));
|
||||
cg.writeEntry("tooltipColor", uiWidConfig.kcolorcombo_tooltipColor->color().name());
|
||||
cg.writeEntry("background", QString::number(uiWidConfig.checkBox_background->checkState()));
|
||||
cg.writeEntry("layout", QString::number(uiWidConfig.checkBox_layout->checkState()));
|
||||
cg.writeEntry("mark", uiWidConfig.comboBox_mark->currentText());
|
||||
|
||||
cg.writeEntry("currentFontFamily", uiAppConfig.fontComboBox_fontActive->currentFont().family());
|
||||
cg.writeEntry("currentFontSize", uiAppConfig.spinBox_fontSizeActive->value());
|
||||
cg.writeEntry("currentFontColor", uiAppConfig.kcolorcombo_fontColorActive->color().name());
|
||||
cg.writeEntry("currentFontWeight", uiAppConfig.spinBox_fontWeightActive->value());
|
||||
cg.writeEntry("currentFontStyle", uiAppConfig.comboBox_fontStyleActive->currentText());
|
||||
|
||||
cg.writeEntry("fontFamily", uiAppConfig.fontComboBox_fontInactive->currentFont().family());
|
||||
cg.writeEntry("fontSize", uiAppConfig.spinBox_fontSizeInactive->value());
|
||||
cg.writeEntry("fontColor", uiAppConfig.kcolorcombo_fontColorInactive->color().name());
|
||||
cg.writeEntry("fontWeight", uiAppConfig.spinBox_fontWeightInactive->value());
|
||||
cg.writeEntry("fontStyle", uiAppConfig.comboBox_fontStyleInactive->currentText());
|
||||
|
||||
QStringList indexes;
|
||||
for (int i=0; i<uiToggleConfig.listWidget_list->count(); i++)
|
||||
if (uiToggleConfig.listWidget_list->item(i)->checkState() == Qt::Checked)
|
||||
indexes.append(QString::number(i));
|
||||
if (indexes.count() == uiToggleConfig.listWidget_list->count())
|
||||
cg.writeEntry("panels", QString("-1"));
|
||||
else
|
||||
cg.writeEntry("panels", indexes.join(QChar(',')));
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::configChanged()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
KConfigGroup cg = config();
|
||||
|
||||
configuration[QString("pattern")] = cg.readEntry("pattern", "[$fullmark$number/$total: $name]");
|
||||
configuration[QString("tooltip")] = cg.readEntry("tooltip", "2");
|
||||
configuration[QString("tooltipType")] = cg.readEntry("tooltipType", "0");
|
||||
configuration[QString("tooltipWidth")] = cg.readEntry("tooltipWidth", "200");
|
||||
configuration[QString("tooltipColor")] = cg.readEntry("tooltipColor", "#ffffff");
|
||||
configuration[QString("background")] = cg.readEntry("background", "2");
|
||||
configuration[QString("layout")] = cg.readEntry("layout", "0");
|
||||
configuration[QString("mark")] = cg.readEntry("mark", "¤");
|
||||
configuration[QString("panels")] = cg.readEntry("panels", "-1");
|
||||
|
||||
CFont font = CFont(cg.readEntry("currentFontFamily", "Terminus"));
|
||||
font.setPointSize(cg.readEntry("currentFontSize", 10));
|
||||
font.setCurrentColor(QColor(cg.readEntry("currentFontColor", "#ff0000")));
|
||||
font.setHtmlWeight(cg.readEntry("currentFontWeight", 400));
|
||||
font.setItalic(cg.readEntry("currentFontStyle", "normal") == QString("italic"));
|
||||
QString fontStyle;
|
||||
if (font.italic())
|
||||
fontStyle = QString("italic");
|
||||
else
|
||||
fontStyle = QString("normal");
|
||||
currentFormatLine[0] = QString("<html><head><style type=\"text/css\">p, li { white-space: pre-wrap; }</style>\
|
||||
</head><body style=\"font-family:'%1'; font-size:%2pt; font-weight:%3; font-style:%4; color:%5;\">")
|
||||
.arg(font.family())
|
||||
.arg(font.pointSize())
|
||||
.arg(font.htmlWeight())
|
||||
.arg(fontStyle)
|
||||
.arg(font.color().name());
|
||||
currentFormatLine[1] = QString("</body></html>");
|
||||
|
||||
font = CFont(cg.readEntry("fontFamily", "Terminus"));
|
||||
font.setPointSize(cg.readEntry("fontSize", 10));
|
||||
font.setCurrentColor(QColor(cg.readEntry("fontColor", "#000000")));
|
||||
font.setHtmlWeight(cg.readEntry("fontWeight", 400));
|
||||
font.setItalic(cg.readEntry("fontStyle", "normal") == QString("italic"));
|
||||
if (font.italic())
|
||||
fontStyle = QString("italic");
|
||||
else
|
||||
fontStyle = QString("normal");
|
||||
formatLine[0] = QString("<html><head><style type=\"text/css\">p, li { white-space: pre-wrap; }</style>\
|
||||
</head><body style=\"font-family:'%1'; font-size:%2pt; font-weight:%3; font-style:%4; color:%5;\">")
|
||||
.arg(font.family())
|
||||
.arg(font.pointSize())
|
||||
.arg(font.htmlWeight())
|
||||
.arg(fontStyle)
|
||||
.arg(font.color().name());
|
||||
formatLine[1] = QString("</body></html>");
|
||||
|
||||
reinit();
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::setFontFormating()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
CFont defaultFont = CFont(uiAppConfig.fontComboBox_fontInactive->currentFont().family(),
|
||||
uiAppConfig.spinBox_fontSizeInactive->value(),
|
||||
400, false, uiAppConfig.kcolorcombo_fontColorInactive->color());
|
||||
CFont font = CFontDialog::getFont(i18n("Select font"), defaultFont,
|
||||
false, false);
|
||||
QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText();
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<span style=\"color:%1; font-family:'%2'; font-size:%3pt;\">")
|
||||
.arg(font.color().name()).arg(font.family()).arg(font.pointSize()) +
|
||||
selectedText + QString("</span>"));
|
||||
}
|
||||
|
||||
|
||||
void DesktopPanel::setFormating()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender();
|
||||
|
||||
QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText();
|
||||
if (sender() == uiWidConfig.pushButton_tags)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("$") + uiWidConfig.comboBox_tags->currentText());
|
||||
else if (sender() == uiWidConfig.pushButton_br)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<br>\n"));
|
||||
else if (sender() == uiWidConfig.pushButton_bold)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<b>") + selectedText + QString("</b>"));
|
||||
else if (sender() == uiWidConfig.pushButton_italic)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<i>") + selectedText + QString("</i>"));
|
||||
else if (sender() == uiWidConfig.pushButton_underline)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<u>") + selectedText + QString("</u>"));
|
||||
else if (sender() == uiWidConfig.pushButton_strike)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<s>") + selectedText + QString("</s>"));
|
||||
else if (sender() == uiWidConfig.pushButton_left)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"left\">") + selectedText + QString("</p>"));
|
||||
else if (sender() == uiWidConfig.pushButton_center)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"center\">") + selectedText + QString("</p>"));
|
||||
else if (sender() == uiWidConfig.pushButton_right)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"right\">") + selectedText + QString("</p>"));
|
||||
else if (sender() == uiWidConfig.pushButton_fill)
|
||||
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"justify\">") + selectedText + QString("</p>"));
|
||||
}
|
||||
|
||||
|
||||
#include "desktop-panel.moc"
|
125
sources/desktop-panel/desktop-panel.h
Normal file
@ -0,0 +1,125 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef DESKTOP_PANEL_H
|
||||
#define DESKTOP_PANEL_H
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/ToolTipContent>
|
||||
#include <QLabel>
|
||||
|
||||
#include <ui_appearance.h>
|
||||
#include <ui_toggle.h>
|
||||
#include <ui_widget.h>
|
||||
|
||||
|
||||
class QGraphicsGridLayout;
|
||||
class QGraphicsProxyWidget;
|
||||
class QGraphicsScene;
|
||||
class DesktopPanel;
|
||||
|
||||
|
||||
class CustomPlasmaLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomPlasmaLabel(DesktopPanel *wid,
|
||||
const int num,
|
||||
const bool debugCmd = false);
|
||||
~CustomPlasmaLabel();
|
||||
int getNumber();
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
// debug
|
||||
bool debug;
|
||||
// variables
|
||||
int number;
|
||||
DesktopPanel *widget;
|
||||
};
|
||||
|
||||
|
||||
class DesktopPanel : public Plasma::Applet
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
typedef struct {
|
||||
QRect desktop;
|
||||
QList<WId> desktopId;
|
||||
QList<QRect> windows;
|
||||
QList<WId> winId;
|
||||
} DesktopWindowsInfo;
|
||||
|
||||
public:
|
||||
DesktopPanel(QObject *parent, const QVariantList &args);
|
||||
~DesktopPanel();
|
||||
void init();
|
||||
DesktopWindowsInfo getInfoByDesktop(const int num);
|
||||
QString parsePattern(const QString rawLine, const int num);
|
||||
|
||||
public slots:
|
||||
// configuration interface
|
||||
void configAccepted();
|
||||
void configChanged();
|
||||
// events
|
||||
void changePanelsState();
|
||||
void paintTooltip(const int active);
|
||||
void setCurrentDesktop(const int number);
|
||||
|
||||
private slots:
|
||||
void reinit();
|
||||
void setFontFormating();
|
||||
void setFormating();
|
||||
void updateText(const int active);
|
||||
|
||||
protected:
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
|
||||
private:
|
||||
// functions
|
||||
QList<Plasma::Containment *> getPanels();
|
||||
QString panelLocationToStr(Plasma::Location loc);
|
||||
// ui
|
||||
QGraphicsGridLayout *layout = nullptr;
|
||||
QList<QGraphicsProxyWidget *> proxyWidgets;
|
||||
QList<CustomPlasmaLabel *> labels;
|
||||
// tooltip
|
||||
Plasma::ToolTipContent toolTip;
|
||||
QGraphicsScene *toolTipScene = nullptr;
|
||||
QGraphicsView *toolTipView = nullptr;
|
||||
// debug
|
||||
bool debug;
|
||||
int activeTooltip = -1;
|
||||
int oldState = 0;
|
||||
// configuration interface
|
||||
Ui::AppearanceWidget uiAppConfig;
|
||||
Ui::ConfigWindow uiWidConfig;
|
||||
Ui::ToggleWindow uiToggleConfig;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QStringList desktopNames, currentFormatLine, formatLine;
|
||||
};
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(desktop-panel, DesktopPanel)
|
||||
|
||||
|
||||
#endif /* DESKTOP_PANEL_H */
|
25
sources/desktop-panel/plasma-applet-desktoppanel.desktop
Normal file
@ -0,0 +1,25 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Desktop Panel
|
||||
Comment=A minimalistic Plasmoid
|
||||
Comment[en]=A minimalistic Plasmoid
|
||||
Comment[es]=Un plasmoide minimalista
|
||||
Comment[es]=Un script Plasmoïde minimaliste
|
||||
Comment[pt_BR]=Um script Plasmoid
|
||||
Comment[ru]=Минималистичный плазмоид
|
||||
Comment[uk]=Мінімалістичний плазмоїд
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-Library=plasma_applet_desktop-panel
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=desktop-panel
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
56
sources/desktop-panel/toggle.ui
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ToggleWindow</class>
|
||||
<widget class="QWidget" name="ToggleWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>343</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>480</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Toggle</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>464</width>
|
||||
<height>327</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string>To control panels please set widget shortcut.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
472
sources/desktop-panel/widget.ui
Normal file
@ -0,0 +1,472 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>721</width>
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>700</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Widget</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="9" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mark">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mark">
|
||||
<property name="text">
|
||||
<string>Mark</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mark">
|
||||
<property name="toolTip">
|
||||
<string>A mark which will be shown if this desktop is active</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">#</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">$</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">%</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">&</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">@</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">¤</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">¶</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">·</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">º</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">×</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">†</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">•</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">(current)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="layput_mainFormating">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_font">
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_br">
|
||||
<property name="icon">
|
||||
<iconset theme="stock_text_indent">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainFormatingCenter1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bold">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-bold">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_italic">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-italic">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_underline">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-underline">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+U</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_strike">
|
||||
<property name="icon">
|
||||
<iconset theme="format-text-strikethrough">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainFormatingCenter2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_left">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-left">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_center">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-center">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_right">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-right">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_fill">
|
||||
<property name="icon">
|
||||
<iconset theme="format-justify-fill">
|
||||
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainFormatingCenter3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_tags">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">fullmark</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">mark</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">name</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">number</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">total</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_tags">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextEdit" name="textEdit_elements">
|
||||
<property name="lineWrapMode">
|
||||
<enum>QTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_tooltip">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_tooltip">
|
||||
<property name="text">
|
||||
<string>Tooltip width</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_tooltip">
|
||||
<property name="suffix">
|
||||
<string>px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_tooltipColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_tooltipColor">
|
||||
<property name="text">
|
||||
<string>Window border color on tooltip</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KColorCombo" name="kcolorcombo_tooltipColor"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_background">
|
||||
<item>
|
||||
<spacer name="spacer_background">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_background">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_layout">
|
||||
<item>
|
||||
<spacer name="spacer_layout">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_layout">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Vertical layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_tooltip_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_tooltip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable tooltip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_tooltipType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Windows</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Contours</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Clean desktop</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,32 +0,0 @@
|
||||
# Configuration file for Extended Systemmonitor DataEngine
|
||||
# $kdehome/share/config/extsysmon.conf
|
||||
|
||||
# Custom command, separator is '@@'
|
||||
#CUSTOM=wget -qO- http://ifconfig.me/ip
|
||||
|
||||
# Set GPU device
|
||||
# May be 'nvidia' (for nvidia), 'ati' (for ATI RADEON), 'disable' or 'auto'
|
||||
#GPUDEV=auto
|
||||
|
||||
# Set block device for hddtemp comma separated or use 'all' or 'disable'
|
||||
#HDDDEV=all
|
||||
|
||||
# Set MPD settings
|
||||
#MPDADDRESS=localhost
|
||||
#MPDPORT=6600
|
||||
|
||||
# Package upgrade info
|
||||
## from vicious
|
||||
## Arch: PKGCMD=pacman -Qu PKGNULL=0
|
||||
## Debian: PKGCMD=apt-show-versions -u -b PKGNULL=0
|
||||
## Ubuntu: PKGCMD=aptitude search '~U' PKGNULL=0
|
||||
## Fedora: PKGCMD=yum list updates PKGNULL=3
|
||||
## FreeBSD: PKGCMD=pkg_version -I -l '<' PKGNULL=0
|
||||
## Mandriva: PKGCMD=urpmq --auto-select PKGNULL=0
|
||||
# Commands to run, comma separated
|
||||
#PKGCMD=pacman -Qu
|
||||
# Number of null lines for commands, comma separated
|
||||
#PKGNULL=0
|
||||
|
||||
# Player name. Supported players are amarok, clementine, mpd, qmmp
|
||||
#PLAYER=amarok
|
@ -1,778 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of pytextmonitor *
|
||||
* *
|
||||
* pytextmonitor is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* pytextmonitor is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with pytextmonitor. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "extsysmon.h"
|
||||
|
||||
#include <Plasma/DataContainer>
|
||||
#include <KDE/KGlobal>
|
||||
#include <KDE/KStandardDirs>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegExp>
|
||||
#include <QTextCodec>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
||||
: Plasma::DataEngine(parent, args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
debug = false;
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
setProcesses();
|
||||
setKeys();
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAllHdd()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]";
|
||||
QProcess command;
|
||||
QStringList devices;
|
||||
QString cmd = QString("find /dev -name [hms]d[a-z]");
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Cmd returns" << command.exitCode();
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
|
||||
devices.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
||||
if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Device list" << devices;
|
||||
return devices.join(QChar(','));
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAutoGpu()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]";
|
||||
QProcess command;
|
||||
QString gpu = QString("disable");
|
||||
QString cmd = QString("lspci");
|
||||
QString qoutput = QString("");
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Run cmd" << cmd;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Cmd returns" << command.exitCode();
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
if (qoutput.toLower().contains("nvidia"))
|
||||
gpu = QString("nvidia");
|
||||
else if (qoutput.toLower().contains("radeon"))
|
||||
gpu = QString("ati");
|
||||
if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Device" << gpu;
|
||||
return gpu;
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtendedSysMon::sources() const
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[sources]";
|
||||
QStringList source;
|
||||
source.append(QString("custom"));
|
||||
source.append(QString("gpu"));
|
||||
source.append(QString("gputemp"));
|
||||
source.append(QString("hddtemp"));
|
||||
source.append(QString("pkg"));
|
||||
source.append(QString("player"));
|
||||
source.append(QString("ps"));
|
||||
if (debug) qDebug() << "[DE]" << "[sources]" << ":" << "Sources" << source;
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::initValues()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[initValues]";
|
||||
QStringList sourceList = sources();
|
||||
for (int i=0; i<sourceList.count(); i++)
|
||||
sourceRequestEvent(sourceList[i]);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[readConfiguration]";
|
||||
// pre-setup
|
||||
QMap<QString, QString> rawConfig;
|
||||
rawConfig[QString("CUSTOM")] = QString("wget -qO- http://ifconfig.me/ip");
|
||||
rawConfig[QString("GPUDEV")] = QString("auto");
|
||||
rawConfig[QString("HDDDEV")] = QString("all");
|
||||
rawConfig[QString("HDDTEMPCMD")] = QString("sudo hddtemp");
|
||||
rawConfig[QString("MPDADDRESS")] = QString("localhost");
|
||||
rawConfig[QString("MPDPORT")] = QString("6600");
|
||||
rawConfig[QString("PKGCMD")] = QString("pacman -Qu");
|
||||
rawConfig[QString("PKGNULL")] = QString("0");
|
||||
rawConfig[QString("PLAYER")] = QString("amarok");
|
||||
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "extsysmon.conf");
|
||||
if (debug) qDebug() << "[DE]" << "[readConfiguration]" << ":" << "Configuration file" << fileName;
|
||||
QFile confFile(fileName);
|
||||
bool ok = confFile.open(QIODevice::ReadOnly);
|
||||
if (!ok) {
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
return;
|
||||
}
|
||||
QString fileStr;
|
||||
QStringList value;
|
||||
while (true) {
|
||||
fileStr = QString(confFile.readLine()).trimmed();
|
||||
if (fileStr[0] == QChar('#')) continue;
|
||||
if (fileStr[0] == QChar(';')) continue;
|
||||
if (fileStr.contains(QChar('='))) {
|
||||
value.clear();
|
||||
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
||||
value.append(fileStr.split(QChar('='))[i]);
|
||||
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
||||
}
|
||||
if (confFile.atEnd())
|
||||
break;
|
||||
}
|
||||
confFile.close();
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setKeys()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[setKeys]";
|
||||
QString key, source;
|
||||
// custom
|
||||
source = QString("custom");
|
||||
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++) {
|
||||
key = QString("custom") + QString::number(i);
|
||||
setData(source, key, QString(""));
|
||||
}
|
||||
// gpu
|
||||
source = QString("gpu");
|
||||
key = QString("GPU");
|
||||
setData(source, key, float(0.0));
|
||||
// gputemp
|
||||
source = QString("gputemp");
|
||||
key = QString("GPUTemp");
|
||||
setData(source, key, float(0.0));
|
||||
// hddtemp
|
||||
source = QString("hddtemp");
|
||||
for (int i=0; i<configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts).count(); i++) {
|
||||
key = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts)[i];
|
||||
setData(source, key, float(0.0));
|
||||
}
|
||||
// pkg
|
||||
source = QString("pkg");
|
||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++) {
|
||||
key = QString("pkgCount") + QString::number(i);
|
||||
setData(source, key, 0);
|
||||
}
|
||||
// player
|
||||
source = QString("player");
|
||||
key = QString("album");
|
||||
setData(source, key, QString("unknown"));
|
||||
key = QString("artist");
|
||||
setData(source, key, QString("unknown"));
|
||||
key = QString("duration");
|
||||
setData(source, key, QString("0"));
|
||||
key = QString("progress");
|
||||
setData(source, key, QString("0"));
|
||||
key = QString("title");
|
||||
setData(source, key, QString("unknown"));
|
||||
// ps
|
||||
source = QString("ps");
|
||||
key = QString("psCount");
|
||||
setData(source, key, QString("0"));
|
||||
key = QString("ps");
|
||||
setData(source, key, QString(""));
|
||||
key = QString("psTotal");
|
||||
setData(source, key, QString("0"));
|
||||
// initialization of values
|
||||
initValues();
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setProcesses()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[setProcesses]";
|
||||
// custom
|
||||
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++) {
|
||||
processes[QString("custom")].append(new QProcess);
|
||||
connect(processes[QString("custom")][i], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setCustomCmd(int, QProcess::ExitStatus)));
|
||||
}
|
||||
// gpu
|
||||
processes[QString("gpu")].append(new QProcess);
|
||||
connect(processes[QString("gpu")][0], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setGpu(int, QProcess::ExitStatus)));
|
||||
// gputemp
|
||||
processes[QString("gputemp")].append(new QProcess);
|
||||
connect(processes[QString("gputemp")][0], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setGpuTemp(int, QProcess::ExitStatus)));
|
||||
// hddtemp
|
||||
for (int i=0; i<configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts).count(); i++) {
|
||||
processes[QString("hddtemp")].append(new QProcess);
|
||||
connect(processes[QString("hddtemp")][i], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setHddTemp(int, QProcess::ExitStatus)));
|
||||
}
|
||||
// pkg
|
||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++) {
|
||||
processes[QString("pkg")].append(new QProcess);
|
||||
connect(processes[QString("pkg")][i], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setUpgradeInfo(int, QProcess::ExitStatus)));
|
||||
}
|
||||
// player
|
||||
processes[QString("player")].append(new QProcess);
|
||||
connect(processes[QString("player")][0], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setPlayer(int, QProcess::ExitStatus)));
|
||||
// ps
|
||||
// pscount && ps
|
||||
processes[QString("ps")].append(new QProcess);
|
||||
// pstotal
|
||||
processes[QString("ps")].append(new QProcess);
|
||||
connect(processes[QString("ps")][1], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
this, SLOT(setPs(int, QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> ExtendedSysMon::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[updateConfiguration]";
|
||||
QMap<QString, QString> config;
|
||||
QString key, value;
|
||||
// remove spaces and copy source map
|
||||
for (int i=0; i<rawConfig.keys().count(); i++) {
|
||||
key = rawConfig.keys()[i];
|
||||
value = rawConfig[key];
|
||||
key.remove(QChar(' '));
|
||||
if ((key != QString("CUSTOM")) &&
|
||||
(key != QString("HDDTEMPCMD")) &&
|
||||
(key != QString("PKGCMD")))
|
||||
value.remove(QChar(' '));
|
||||
config[key] = value;
|
||||
}
|
||||
// update values
|
||||
// gpudev
|
||||
if (config[QString("GPUDEV")] == QString("disable"))
|
||||
config[QString("GPUDEV")] = QString("disable");
|
||||
else if (config[QString("GPUDEV")] == QString("auto"))
|
||||
config[QString("GPUDEV")] = getAutoGpu();
|
||||
else if ((config[QString("GPUDEV")] != QString("ati")) &&
|
||||
(config[QString("GPUDEV")] != QString("nvidia")))
|
||||
config[QString("GPUDEV")] = getAutoGpu();
|
||||
// hdddev
|
||||
if (config[QString("HDDDEV")] == QString("all"))
|
||||
config[QString("HDDDEV")] = getAllHdd();
|
||||
else if (config[QString("HDDDEV")] == QString("disable"))
|
||||
config[QString("HDDDEV")] = QString("");
|
||||
else {
|
||||
QStringList deviceList = config[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||
QStringList devices;
|
||||
QRegExp diskRegexp = QRegExp("/dev/[hms]d[a-z]$");
|
||||
for (int i=0; i<deviceList.count(); i++)
|
||||
if ((QFile::exists(deviceList[i])) &&
|
||||
(diskRegexp.indexIn(deviceList[i]) > -1))
|
||||
devices.append(deviceList[i]);
|
||||
if (devices.isEmpty())
|
||||
config[QString("HDDDEV")] = getAllHdd();
|
||||
else
|
||||
config[QString("HDDDEV")] = devices.join(QChar(','));
|
||||
}
|
||||
// pkgcmd
|
||||
for (int i=config[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts).count();
|
||||
i<config[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count()+1;
|
||||
i++)
|
||||
config[QString("PKGNULL")] += QString(",0");
|
||||
// player
|
||||
if ((config[QString("PLAYER")] != QString("amarok")) &&
|
||||
(config[QString("PLAYER")] != QString("clementine")) &&
|
||||
(config[QString("PLAYER")] != QString("mpd")) &&
|
||||
(config[QString("PLAYER")] != QString("qmmp")))
|
||||
config[QString("PLAYER")] = QString("amarok");
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << "[DE]" << "[updateConfiguration]" << ":" <<
|
||||
config.keys()[i] + QString("=") + config[config.keys()[i]];
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getCustomCmd(const QString cmd, const int number)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]";
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with number" << number;
|
||||
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
||||
if ((processes[QString("custom")][number]->state() != QProcess::Running) &&
|
||||
(processes[QString("custom")][number]->state() != QProcess::Starting))
|
||||
processes[QString("custom")][number]->start(QString("bash -c \"") + cmd + QString("\""));
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setCustomCmd(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]";
|
||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Cmd returns" << exitCode;
|
||||
for (int i=0; i<processes[QString("custom")].count(); i++) {
|
||||
QString value = QString("");
|
||||
value = QTextCodec::codecForMib(106)->toUnicode(processes[QString("custom")][i]->readAllStandardOutput()).trimmed();
|
||||
if (!value.isEmpty()) {
|
||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Found data for cmd" << i;
|
||||
if (debug) qDebug() << "[DE]" << "[setCustomCmd]" << ":" << "Return" << value;
|
||||
QString source = QString("custom");
|
||||
QString key = QString("custom") + QString::number(i);
|
||||
setData(source, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getGpu(const QString device)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]";
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run function with device" << device;
|
||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||
return;
|
||||
QString cmd = QString("");
|
||||
if (device == QString("nvidia"))
|
||||
cmd = QString("nvidia-smi -q -d UTILIZATION");
|
||||
else if (device == QString("ati"))
|
||||
cmd = QString("aticonfig --od-getclocks");
|
||||
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
||||
if ((processes[QString("gpu")][0]->state() != QProcess::Running) &&
|
||||
(processes[QString("gpu")][0]->state() != QProcess::Starting))
|
||||
processes[QString("gpu")][0]->start(cmd);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setGpu(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setGpu]";
|
||||
if (debug) qDebug() << "[DE]" << "[setGpu]" << ":" << "Cmd returns" << exitCode;
|
||||
float value = 0.0;
|
||||
QString qoutput;
|
||||
if (configuration[QString("GPUDEV")] == QString("nvidia")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gpu")][0]->readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.split(QChar(' '), QString::SkipEmptyParts)[2]
|
||||
.remove(QChar('%'));
|
||||
value = load.toFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (configuration[QString("GPUDEV")] == QString("ati")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gpu")][0]->readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("load"))) {
|
||||
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.split(QChar(' '), QString::SkipEmptyParts)[3]
|
||||
.remove(QChar('%'));
|
||||
value = load.toFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug) qDebug() << "[DE]" << "[setGpu]" << ":" << "Return" << value;
|
||||
QString source = QString("gpu");
|
||||
QString key = QString("GPU");
|
||||
setData(source, key, value);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getGpuTemp(const QString device)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]";
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run function with device" << device;
|
||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||
return;
|
||||
QString cmd = QString("");
|
||||
if (device == QString("nvidia"))
|
||||
cmd = QString("nvidia-smi -q -d TEMPERATURE");
|
||||
else if (device == QString("ati"))
|
||||
cmd = QString("aticonfig --od-gettemperature");
|
||||
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
||||
if ((processes[QString("gputemp")][0]->state() != QProcess::Running) &&
|
||||
(processes[QString("gputemp")][0]->state() != QProcess::Running))
|
||||
processes[QString("gputemp")][0]->start(cmd);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setGpuTemp(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setGpuTemp]";
|
||||
if (debug) qDebug() << "[DE]" << "[setGpuTemp]" << ":" << "Cmd returns" << exitCode;
|
||||
float value = 0.0;
|
||||
QString qoutput;
|
||||
if (configuration[QString("GPUDEV")] == QString("nvidia")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gputemp")][0]->readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Gpu"))) {
|
||||
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.split(QChar(' '), QString::SkipEmptyParts)[2];
|
||||
value = temp.toFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (configuration[QString("GPUDEV")] == QString("ati")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("gputemp")][0]->readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Temperature"))) {
|
||||
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.split(QChar(' '), QString::SkipEmptyParts)[4];
|
||||
value = temp.toFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug) qDebug() << "[DE]" << "[setGpuTemp]" << ":" << "Return" << value;
|
||||
QString source = QString("gputemp");
|
||||
QString key = QString("GPUTemp");
|
||||
setData(source, key, value);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getHddTemp(const QString cmd, const QString device, const int number)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]";
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with cmd" << cmd;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with device" << device;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with number" << number;
|
||||
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
||||
if ((processes[QString("hddtemp")][number]->state() != QProcess::Running) &&
|
||||
(processes[QString("hddtemp")][number]->state() != QProcess::Starting))
|
||||
processes[QString("hddtemp")][number]->start(cmd + QString(" ") + device);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setHddTemp(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setHddTemp]";
|
||||
if (debug) qDebug() << "[DE]" << "[setHddTemp]" << ":" << "Cmd returns" << exitCode;
|
||||
for (int i=0; i<processes[QString("hddtemp")].count(); i++) {
|
||||
float value = 0.0;
|
||||
QString qoutput = QString("");
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("hddtemp")][i]->readAllStandardOutput()).trimmed();
|
||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
||||
if (debug) qDebug() << "[DE]" << "[setHddTemp]" << ":" << "Found data for cmd" << i;
|
||||
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
||||
temp.remove(QChar(0260)).remove(QChar('C'));
|
||||
value = temp.toFloat();
|
||||
if (debug) qDebug() << "[DE]" << "[setHddTemp]" << ":" << "Return" << value;
|
||||
QString source = QString("hddtemp");
|
||||
QString key = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts)[i];
|
||||
setData(source, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress,
|
||||
const QString mpdPort)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]";
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with player" << playerName;
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with MPD parameters" <<
|
||||
mpdAddress + QString(":") + mpdPort;
|
||||
QString cmd;
|
||||
if (playerName == QString("amarok"))
|
||||
// amarok
|
||||
cmd = QString("bash -c \"qdbus org.kde.amarok /Player GetMetadata && qdbus org.kde.amarok /Player PositionGet\"");
|
||||
else if (playerName == QString("clementine"))
|
||||
// clementine
|
||||
cmd = QString("bash -c \"qdbus org.mpris.clementine /Player GetMetadata && qdbus org.mpris.clementine /Player PositionGet\"");
|
||||
else if (playerName == QString("mpd"))
|
||||
// mpd
|
||||
cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://") +
|
||||
mpdAddress + QString(":") + mpdPort + QString("\"");
|
||||
else if (playerName == QString("qmmp"))
|
||||
// qmmp
|
||||
cmd = QString("bash -c \"pgrep qmmp && qmmp --status || echo 'null'\"");
|
||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||
if ((processes[QString("player")][0]->state() != QProcess::Running) &&
|
||||
(processes[QString("player")][0]->state() != QProcess::Starting))
|
||||
processes[QString("player")][0]->start(cmd);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setPlayer(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setPlayer]";
|
||||
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Cmd returns" << exitCode;
|
||||
QString playerName = configuration[QString("PLAYER")];
|
||||
QString qoutput = QString("");
|
||||
QString qstr = QString("");
|
||||
QStringList info;
|
||||
// album
|
||||
info.append(QString("unknown"));
|
||||
// artist
|
||||
info.append(QString("unknown"));
|
||||
// progress
|
||||
info.append(QString("0"));
|
||||
// duration
|
||||
info.append(QString("0"));
|
||||
// title
|
||||
info.append(QString("unknown"));
|
||||
if (playerName == QString("amarok")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||
if (!qoutput.isEmpty()) {
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
||||
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
||||
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
||||
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
else {
|
||||
int time = qstr.toInt() / 1000;
|
||||
info[2] = QString::number(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (playerName == QString("clementine")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||
if (!qoutput.isEmpty()) {
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
||||
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
||||
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
||||
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
else {
|
||||
int time = qstr.toInt() / 1000;
|
||||
info[2] = QString::number(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (playerName == QString("mpd")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Album"))
|
||||
info[0] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
|
||||
info[1] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time")) {
|
||||
info[3] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[0];
|
||||
info[2] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[1];
|
||||
}
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
|
||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (playerName == QString("qmmp")) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
if ((qstr.split(QString(" = "), QString::SkipEmptyParts).count() > 1) || (qstr.at(0) == QChar('['))) {
|
||||
if (qstr.split(QString(" = "), QString::SkipEmptyParts)[0] == QString("ALBUM"))
|
||||
info[0] = qstr.split(QString(" = "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(" = "), QString::SkipEmptyParts)[0] == QString("ARTIST"))
|
||||
info[1] = qstr.split(QString(" = "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if ((qstr.at(0) == QChar('[')) && (!qstr.contains("[stopped]"))) {
|
||||
QString time = qstr.split(QString(" "), QString::SkipEmptyParts)[2].trimmed();
|
||||
info[2] = QString::number(time.split(QString("/"), QString::SkipEmptyParts)[0].split(QString(":"), QString::SkipEmptyParts)[0].toInt() * 60 +
|
||||
time.split(QString("/"), QString::SkipEmptyParts)[0].split(QString(":"), QString::SkipEmptyParts)[1].toInt());
|
||||
info[3] = QString::number(time.split(QString("/"), QString::SkipEmptyParts)[1].split(QString(":"), QString::SkipEmptyParts)[0].toInt() * 60 +
|
||||
time.split(QString("/"), QString::SkipEmptyParts)[1].split(QString(":"), QString::SkipEmptyParts)[1].toInt());
|
||||
}
|
||||
else if (qstr.split(QString(" = "), QString::SkipEmptyParts)[0] == QString("TITLE"))
|
||||
info[4] = qstr.split(QString(" = "), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
}
|
||||
}
|
||||
QString source = QString("player");
|
||||
QString key;
|
||||
key = QString("album");
|
||||
setData(source, key, info[0]);
|
||||
key = QString("artist");
|
||||
setData(source, key, info[1]);
|
||||
key = QString("progress");
|
||||
setData(source, key, info[2]);
|
||||
key = QString("duration");
|
||||
setData(source, key, info[3]);
|
||||
key = QString("title");
|
||||
setData(source, key, info[4]);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getPsStats()
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]";
|
||||
QString cmd;
|
||||
cmd = QString("ps --no-headers -o command");
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||
if ((processes[QString("ps")][0]->state() != QProcess::Running) &&
|
||||
(processes[QString("ps")][0]->state() != QProcess::Starting))
|
||||
processes[QString("ps")][0]->start(cmd);
|
||||
cmd = QString("ps -e --no-headers -o command");
|
||||
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
||||
if ((processes[QString("ps")][1]->state() != QProcess::Running) &&
|
||||
(processes[QString("ps")][1]->state() != QProcess::Starting))
|
||||
processes[QString("ps")][1]->start(cmd);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setPs(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setPs]";
|
||||
if (debug) qDebug() << "[DE]" << "[setPs]" << ":" << "Cmd returns" << exitCode;
|
||||
QString qoutput = QString("");
|
||||
for (int i=0; i<processes[QString("ps")].count(); i++) {
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("ps")][i]->readAllStandardOutput()).trimmed();
|
||||
if (!qoutput.isEmpty()) {
|
||||
if (debug) qDebug() << "[DE]" << "[setPs]" << ":" << "Found data for cmd" << i;
|
||||
if (i == 0) {
|
||||
// pscount && ps
|
||||
QStringList psList;
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
|
||||
if (!qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].
|
||||
contains(QString("ps ")))
|
||||
psList.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
||||
QString source = QString("ps");
|
||||
QString key = QString("psCount");
|
||||
setData(source, key, psList.count());
|
||||
key = QString("ps");
|
||||
setData(source, key, psList.join(QString(",")));
|
||||
}
|
||||
else if (i == 1) {
|
||||
// pstotal
|
||||
QString source = QString("ps");
|
||||
QString key = QString("psTotal");
|
||||
setData(source, key, qoutput.split(QChar('\n'), QString::SkipEmptyParts).count());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int number)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]";
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with cmd" << pkgCommand;
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with number" << number;
|
||||
QString cmd = QString("bash -c \"") + pkgCommand + QString(" | wc -l\"");
|
||||
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
||||
if ((processes[QString("pkg")][number]->state() != QProcess::Running) &&
|
||||
(processes[QString("pkg")][number]->state() != QProcess::Starting))
|
||||
processes[QString("pkg")][number]->start(cmd);
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::setUpgradeInfo(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
Q_UNUSED(exitStatus)
|
||||
|
||||
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]";
|
||||
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]" << ":" << "Cmd returns" << exitCode;
|
||||
for (int i=0; i<processes[QString("pkg")].count(); i++) {
|
||||
int pkgNull = 0;
|
||||
int value = 0;
|
||||
QString qoutput = QString("");
|
||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("pkg")][i]->readAllStandardOutput()).trimmed();
|
||||
if (!qoutput.isEmpty()) {
|
||||
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]" << ":" << "Found data for cmd" << i;
|
||||
pkgNull = configuration[QString("PKGNULL")].split(QString(","), QString::SkipEmptyParts)[i].toInt();
|
||||
value = qoutput.toInt();
|
||||
if (debug) qDebug() << "[DE]" << "[setUpgradeInfo]" << ":" << "Return" << value;
|
||||
QString source = QString("pkg");
|
||||
QString key = QString("pkgCount") + QString::number(i);
|
||||
setData(source, key, value - pkgNull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[sourceRequestEvent]";
|
||||
if (debug) qDebug() << "[DE]" << "[sourceRequestEvent]" << ":" << "Run function with source name" << name;
|
||||
return updateSourceEvent(name);
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
{
|
||||
if (debug) qDebug() << "[DE]" << "[updateSourceEvent]";
|
||||
if (debug) qDebug() << "[DE]" << "[updateSourceEvent]" << ":" << "Run function with source name" << source;
|
||||
if (source == QString("custom")) {
|
||||
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++)
|
||||
getCustomCmd(configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts)[i], i);
|
||||
}
|
||||
else if (source == QString("gpu")) {
|
||||
getGpu(configuration[QString("GPUDEV")]);
|
||||
}
|
||||
else if (source == QString("gputemp")) {
|
||||
getGpuTemp(configuration[QString("GPUDEV")]);
|
||||
}
|
||||
else if (source == QString("hddtemp")) {
|
||||
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||
for (int i=0; i<deviceList.count(); i++)
|
||||
getHddTemp(configuration[QString("HDDTEMPCMD")], deviceList[i], i);
|
||||
}
|
||||
else if (source == QString("pkg")) {
|
||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++)
|
||||
getUpgradeInfo(configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts)[i], i);
|
||||
}
|
||||
else if (source == QString("player")) {
|
||||
getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
configuration[QString("MPDPORT")]);
|
||||
}
|
||||
else if (source == QString("ps")) {
|
||||
getPsStats();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
|
||||
|
||||
#include "extsysmon.moc"
|
@ -1,74 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of pytextmonitor *
|
||||
* *
|
||||
* pytextmonitor is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* pytextmonitor is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with pytextmonitor. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EXTSYSMON_H
|
||||
#define EXTSYSMON_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QProcess>
|
||||
|
||||
class ExtendedSysMon : public Plasma::DataEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
// update functions
|
||||
void getCustomCmd(const QString cmd,
|
||||
const int number = 0);
|
||||
void getGpu(const QString device);
|
||||
void getGpuTemp(const QString device);
|
||||
void getHddTemp(const QString cmd, const QString device,
|
||||
const int number = 0);
|
||||
void getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress = 0,
|
||||
const QString mpdPort = 0);
|
||||
void getPsStats();
|
||||
void getUpgradeInfo(const QString pkgCommand,
|
||||
const int number = 0);
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &name);
|
||||
bool updateSourceEvent(const QString &source);
|
||||
QStringList sources() const;
|
||||
|
||||
private slots:
|
||||
void setCustomCmd(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void setGpu(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void setGpuTemp(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void setHddTemp(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void setUpgradeInfo(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void setPlayer(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void setPs(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
||||
private:
|
||||
// processes
|
||||
QMap<QString, QList<QProcess*> > processes;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
bool debug;
|
||||
// reread configuration
|
||||
QString getAllHdd();
|
||||
QString getAutoGpu();
|
||||
void initValues();
|
||||
void readConfiguration();
|
||||
void setKeys();
|
||||
void setProcesses();
|
||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||
};
|
||||
|
||||
#endif /* EXTSYSMON_H */
|
44
sources/extsysmon/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
||||
# set project name
|
||||
set (SUBPROJECT plasma_dataengine_extsysmon)
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
set (KDE_INCLUDE ${KDE4_INCLUDES})
|
||||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
${Qt_INCLUDE}
|
||||
${KDE_INCLUDE})
|
||||
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
set (SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
|
||||
set (SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
||||
install (DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
||||
install (DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
390
sources/extsysmon/extscript.cpp
Normal file
@ -0,0 +1,390 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "extscript.h"
|
||||
#include "ui_extscript.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
m_fileName(scriptName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtScript)
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
ExtScript::~ExtScript()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::executable()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::interval()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_interval;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::prefix()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_prefix;
|
||||
}
|
||||
|
||||
|
||||
ExtScript::Redirect ExtScript::redirect()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_redirect;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::strRedirect()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch (m_redirect) {
|
||||
case stdout2stderr:
|
||||
value = QString("stdout2stderr");
|
||||
break;
|
||||
case stderr2stdout:
|
||||
value = QString("stderr2stdout");
|
||||
break;
|
||||
default:
|
||||
value = QString("nothing");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_output;
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setActive(const bool state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
m_active = state;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setExecutable(const QString _executable)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||
|
||||
m_executable = _executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setHasOutput(const bool state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
m_output = state;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setInterval(const int _interval)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
|
||||
if (_interval <= 0) return;
|
||||
|
||||
m_interval = _interval;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setPrefix(const QString _prefix)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Prefix" << _prefix;
|
||||
|
||||
m_prefix = _prefix;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setRedirect(const Redirect _redirect)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
|
||||
|
||||
m_redirect = _redirect;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setStrRedirect(const QString _redirect)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
|
||||
|
||||
if (_redirect == QString("stdout2sdterr"))
|
||||
m_redirect = stdout2stderr;
|
||||
else if (_redirect == QString("stderr2sdtout"))
|
||||
m_redirect = stderr2stdout;
|
||||
else
|
||||
m_redirect = nothing;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
|
||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
|
||||
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
if (!m_output)
|
||||
setRedirect(stdout2stderr);
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!m_active) return value;
|
||||
|
||||
if (times == 1) {
|
||||
QStringList cmdList;
|
||||
if (!m_prefix.isEmpty())
|
||||
cmdList.append(m_prefix);
|
||||
cmdList.append(m_executable);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
|
||||
TaskResult process = runTask(cmdList.join(QChar(' ')));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString info = QString::number(process.exitCode) + QString(":") +
|
||||
QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed();
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
switch (m_redirect) {
|
||||
case stdout2stderr:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
||||
break;
|
||||
case stderr2stdout:
|
||||
value = info + QString("\t") + qoutput;
|
||||
break;
|
||||
default:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
|
||||
value = qoutput;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// update value
|
||||
if (times >= m_interval) times = 0;
|
||||
times++;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::showConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->lineEdit_command->setText(m_executable);
|
||||
ui->lineEdit_prefix->setText(m_prefix);
|
||||
if (m_active)
|
||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_active->setCheckState(Qt::Unchecked);
|
||||
if (m_output)
|
||||
ui->checkBox_output->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_output->setCheckState(Qt::Unchecked);
|
||||
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
||||
ui->spinBox_interval->setValue(m_interval);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWESAPI);
|
||||
setExecutable(ui->lineEdit_command->text());
|
||||
setPrefix(ui->lineEdit_prefix->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setHasOutput(ui->checkBox_output->checkState() == Qt::Checked);
|
||||
setStrRedirect(ui->comboBox_redirect->currentText());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ExtScript::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
|
||||
// check if exists
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("Exec"), m_executable);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Prefix"), m_prefix);
|
||||
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Output"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Redirect"), strRedirect());
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
102
sources/extsysmon/extscript.h
Normal file
@ -0,0 +1,102 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EXTSCRIPT_H
|
||||
#define EXTSCRIPT_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ExtScript;
|
||||
}
|
||||
|
||||
class ExtScript : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
|
||||
|
||||
public:
|
||||
enum Redirect {
|
||||
stdout2stderr = 0,
|
||||
nothing,
|
||||
stderr2stdout
|
||||
};
|
||||
|
||||
explicit ExtScript(QWidget *parent = 0, const QString scriptName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtScript();
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
int interval();
|
||||
QString name();
|
||||
QString prefix();
|
||||
Redirect redirect();
|
||||
QString strRedirect();
|
||||
bool hasOutput();
|
||||
bool isActive();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setHasOutput(const bool _state = true);
|
||||
void setInterval(const int _interval = 1);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setPrefix(const QString _prefix = QString(""));
|
||||
void setRedirect(const Redirect _redirect = nothing);
|
||||
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QString run();
|
||||
int showConfiguration();
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::ExtScript *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
int m_interval = 1;
|
||||
QString m_name = QString("none");
|
||||
bool m_output = true;
|
||||
QString m_prefix = QString("");
|
||||
Redirect m_redirect = nothing;
|
||||
int times = 0;
|
||||
QString value = QString();
|
||||
};
|
||||
|
||||
|
||||
#endif /* EXTSCRIPT_H */
|
283
sources/extsysmon/extscript.ui
Normal file
@ -0,0 +1,283 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExtScript</class>
|
||||
<widget class="QDialog" name="ExtScript">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_name">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_comment">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_comment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_comment"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_command">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_command">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_command"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_prefix">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_prefix">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prefix</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_prefix"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_active">
|
||||
<item>
|
||||
<spacer name="spacer_active">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_active">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_output">
|
||||
<item>
|
||||
<spacer name="spacer_output">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_output">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Has output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_redirect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_redirect">
|
||||
<property name="text">
|
||||
<string>Redirect</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_redirect">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">stdout2stderr</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">nothing</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">stderr2stdout</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_interval">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interval">
|
||||
<property name="text">
|
||||
<string>Interval</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ExtScript</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ExtScript</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
678
sources/extsysmon/extsysmon.cpp
Normal file
@ -0,0 +1,678 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "extsysmon.h"
|
||||
|
||||
#include <KWindowSystem>
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
#include <QDBusArgument>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusConnectionInterface>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegExp>
|
||||
#include <QTextCodec>
|
||||
#include <QSettings>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "extscript.h"
|
||||
#include "extupgrade.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
|
||||
|
||||
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
|
||||
: Plasma::DataEngine(parent, args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
initScripts();
|
||||
initUpgrade();
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAllHdd()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
|
||||
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||
for (int i=0; i<devices.count(); i++)
|
||||
devices[i] = QString("/dev/") + devices[i];
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device list" << devices;
|
||||
return devices.join(QChar(','));
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAutoGpu()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString gpu = QString("disable");
|
||||
QFile moduleFile(QString("/proc/modules"));
|
||||
if (!moduleFile.open(QIODevice::ReadOnly)) return gpu;
|
||||
|
||||
QString output = moduleFile.readAll();
|
||||
if (output.contains(QString("fglrx")))
|
||||
gpu = QString("ati");
|
||||
else if (output.contains(QString("nvidia")))
|
||||
gpu = QString("nvidia");
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device" << gpu;
|
||||
return gpu;
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getAutoMpris()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, QString("ListNames"));
|
||||
if (listServices.arguments().count() == 0) return QString();
|
||||
QStringList arguments = listServices.arguments()[0].toStringList();
|
||||
|
||||
for (int i=0; i<arguments.count(); i++) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Service found" << arguments[i];
|
||||
if (!arguments[i].startsWith(QString("org.mpris.MediaPlayer2."))) continue;
|
||||
QString service = arguments[i];
|
||||
service.remove(QString("org.mpris.MediaPlayer2."));
|
||||
return service;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::initScripts()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// create directory at $HOME and create dirs list
|
||||
QString localDir;
|
||||
QStringList dirs;
|
||||
localDir = KStandardDirs::locateLocal("data", "awesomewidgets/scripts");
|
||||
if (KStandardDirs::makeDir(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = KGlobal::dirs()->findDirs("data", "awesomewidgets/scripts");
|
||||
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||
for (int j=0; j<files.count(); j++) {
|
||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
externalScripts.append(new ExtScript(0, files[j], dirs, debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::initUpgrade()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// create directory at $HOME and create dirs list
|
||||
QString localDir;
|
||||
QStringList dirs;
|
||||
localDir = KStandardDirs::locateLocal("data", "awesomewidgets/upgrade");
|
||||
if (KStandardDirs::makeDir(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = KGlobal::dirs()->findDirs("data", "awesomewidgets/upgrade");
|
||||
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||
for (int j=0; j<files.count(); j++) {
|
||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
externalUpgrade.append(new ExtUpgrade(0, files[j], dirs, debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtendedSysMon::sources() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList source;
|
||||
source.append(QString("battery"));
|
||||
source.append(QString("custom"));
|
||||
source.append(QString("desktop"));
|
||||
source.append(QString("netdev"));
|
||||
source.append(QString("gpu"));
|
||||
source.append(QString("gputemp"));
|
||||
source.append(QString("hddtemp"));
|
||||
source.append(QString("pkg"));
|
||||
source.append(QString("player"));
|
||||
source.append(QString("ps"));
|
||||
source.append(QString("update"));
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Sources" << source;
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
void ExtendedSysMon::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName;
|
||||
fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-extsysmon.conf");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
QMap<QString, QString> rawConfig;
|
||||
|
||||
settings.beginGroup(QString("Configuration"));
|
||||
rawConfig[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/")).toString();
|
||||
rawConfig[QString("GPUDEV")] = settings.value(QString("GPUDEV"), QString("auto")).toString();
|
||||
rawConfig[QString("HDDDEV")] = settings.value(QString("HDDDEV"), QString("all")).toString();
|
||||
rawConfig[QString("HDDTEMPCMD")] = settings.value(QString("HDDTEMPCMD"), QString("sudo hddtemp")).toString();
|
||||
rawConfig[QString("MPDADDRESS")] = settings.value(QString("MPDADDRESS"), QString("localhost")).toString();
|
||||
rawConfig[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600")).toString();
|
||||
rawConfig[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto")).toString();
|
||||
rawConfig[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris")).toString();
|
||||
settings.endGroup();
|
||||
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString> rawConfig)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// gpudev
|
||||
if (rawConfig[QString("GPUDEV")] == QString("disable"))
|
||||
rawConfig[QString("GPUDEV")] = QString("disable");
|
||||
else if (rawConfig[QString("GPUDEV")] == QString("auto"))
|
||||
rawConfig[QString("GPUDEV")] = getAutoGpu();
|
||||
else if ((rawConfig[QString("GPUDEV")] != QString("ati")) &&
|
||||
(rawConfig[QString("GPUDEV")] != QString("nvidia")))
|
||||
rawConfig[QString("GPUDEV")] = getAutoGpu();
|
||||
// hdddev
|
||||
allHddDevices = getAllHdd().split(QChar(','), QString::SkipEmptyParts);
|
||||
if (rawConfig[QString("HDDDEV")] == QString("all"))
|
||||
rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
|
||||
else if (rawConfig[QString("HDDDEV")] == QString("disable"))
|
||||
rawConfig[QString("HDDDEV")] = QString("");
|
||||
else {
|
||||
QStringList deviceList = rawConfig[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||
QStringList devices;
|
||||
QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$");
|
||||
for (int i=0; i<deviceList.count(); i++)
|
||||
if ((QFile::exists(deviceList[i])) &&
|
||||
(diskRegexp.indexIn(deviceList[i]) > -1))
|
||||
devices.append(deviceList[i]);
|
||||
if (devices.isEmpty())
|
||||
rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
|
||||
else
|
||||
rawConfig[QString("HDDDEV")] = devices.join(QChar(','));
|
||||
}
|
||||
// player
|
||||
if ((rawConfig[QString("PLAYER")] != QString("mpd")) &&
|
||||
(rawConfig[QString("PLAYER")] != QString("mpris")))
|
||||
rawConfig[QString("PLAYER")] = QString("mpris");
|
||||
|
||||
for (int i=0; i<rawConfig.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" <<
|
||||
rawConfig.keys()[i] + QString("=") + rawConfig[rawConfig.keys()[i]];
|
||||
return rawConfig;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getBattery(const QString acpiPath)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ACPI path" << acpiPath;
|
||||
|
||||
QMap<QString, QVariant> battery;
|
||||
battery[QString("ac")] = false;
|
||||
battery[QString("bat")] = 0;
|
||||
QFile acFile(acpiPath + QString("/AC/online"));
|
||||
if (acFile.open(QIODevice::ReadOnly)) {
|
||||
if (QString(acFile.readLine()).trimmed().toInt() == 1)
|
||||
battery[QString("ac")] = true;
|
||||
}
|
||||
acFile.close();
|
||||
// batterites
|
||||
QStringList allDevices = QDir(acpiPath).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
QStringList batDevices;
|
||||
QRegExp batRegexp = QRegExp(QString("BAT.*"));
|
||||
for (int i=0; i<allDevices.count(); i++)
|
||||
if (allDevices[i].contains(batRegexp))
|
||||
batDevices.append(allDevices[i]);
|
||||
for (int i=0; i<batDevices.count(); i++) {
|
||||
QFile batFile(acpiPath + QString("/") + batDevices[i] + QString("/capacity"));
|
||||
if (batFile.open(QIODevice::ReadOnly))
|
||||
battery[QString("bat") + QString::number(i)] = QString(batFile.readLine()).trimmed().toInt();
|
||||
batFile.close();
|
||||
}
|
||||
float number = 0.0;
|
||||
float average = 0.0;
|
||||
for (int i=0; i<battery.keys().count(); i++) {
|
||||
if (battery.keys()[i] == QString("ac")) continue;
|
||||
if (battery.keys()[i] == QString("bat")) continue;
|
||||
average += battery[battery.keys()[i]].toInt();
|
||||
number++;
|
||||
}
|
||||
battery[QString("bat")] = int(average / number);
|
||||
|
||||
return battery;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getCurrentDesktop()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
int number = KWindowSystem::currentDesktop();
|
||||
int total = KWindowSystem::numberOfDesktops();
|
||||
QMap<QString, QVariant> currentDesktop;
|
||||
currentDesktop[QString("currentName")] = KWindowSystem::desktopName(number);
|
||||
currentDesktop[QString("currentNumber")] = number;
|
||||
QStringList list;
|
||||
for (int i=1; i<total+1; i++)
|
||||
list.append(KWindowSystem::desktopName(i));
|
||||
currentDesktop[QString("list")] = list.join(QString(";;"));
|
||||
currentDesktop[QString("number")] = total;
|
||||
|
||||
return currentDesktop;
|
||||
}
|
||||
|
||||
|
||||
float ExtendedSysMon::getGpu(const QString device)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
|
||||
|
||||
float value = 0.0;
|
||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||
return value;
|
||||
QString cmd = QString("");
|
||||
if (device == QString("nvidia"))
|
||||
cmd = QString("nvidia-smi -q -x");
|
||||
else if (device == QString("ati"))
|
||||
cmd = QString("aticonfig --od-getclocks");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("<gpu_util>"))) {
|
||||
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.remove(QString("<gpu_util>"))
|
||||
.remove(QString("</gpu_util>"))
|
||||
.remove(QChar('%'));
|
||||
value = load.toFloat();
|
||||
}
|
||||
}
|
||||
else if (configuration[QString("GPUDEV")] == QString("ati"))
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("load"))) {
|
||||
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.split(QChar(' '), QString::SkipEmptyParts)[3]
|
||||
.remove(QChar('%'));
|
||||
value = load.toFloat();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
float ExtendedSysMon::getGpuTemp(const QString device)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
|
||||
|
||||
float value = 0.0;
|
||||
if ((device != QString("nvidia")) && (device != QString("ati")))
|
||||
return value;
|
||||
QString cmd = QString("");
|
||||
if (device == QString("nvidia"))
|
||||
cmd = QString("nvidia-smi -q -x");
|
||||
else if (device == QString("ati"))
|
||||
cmd = QString("aticonfig --od-gettemperature");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("<gpu_temp>"))) {
|
||||
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.remove(QString("<gpu_temp>"))
|
||||
.remove(QString("C</gpu_temp>"));
|
||||
value = temp.toFloat();
|
||||
}
|
||||
}
|
||||
else if (configuration[QString("GPUDEV")] == QString("ati"))
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Temperature"))) {
|
||||
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
|
||||
.split(QChar(' '), QString::SkipEmptyParts)[4];
|
||||
value = temp.toFloat();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
|
||||
|
||||
float value = 0.0;
|
||||
TaskResult process = runTask(cmd + QString(" ") + device);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
bool smartctl = cmd.contains(QString("smartctl"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Define smartctl" << smartctl;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
if (smartctl) {
|
||||
for (int i=0; i<qoutput.split(QChar(':'), QString::SkipEmptyParts).count(); i++) {
|
||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '))[0] != QString("194")) continue;
|
||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '), QString::SkipEmptyParts).count() < 9) break;
|
||||
value = qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '), QString::SkipEmptyParts)[9].toFloat();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
|
||||
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
|
||||
temp.remove(QChar(0260)).remove(QChar('C'));
|
||||
value = temp.toFloat();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
QString ExtendedSysMon::getNetworkDevice()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString device = QString("lo");
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint))) {
|
||||
device = rawInterfaceList[i].name();
|
||||
break;
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress,
|
||||
const QString mpdPort,
|
||||
QString mpris)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "player" << playerName;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPRIS" << mpris;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = QString("0");
|
||||
info[QString("progress")] = QString("0");
|
||||
info[QString("title")] = QString("unknown");
|
||||
|
||||
if (playerName == QString("mpd"))
|
||||
// mpd
|
||||
return getPlayerMpdInfo(mpdAddress, mpdPort);
|
||||
else if (playerName == QString("mpris")) {
|
||||
// players which supports mpris
|
||||
if (mpris == QString("auto")) mpris = getAutoMpris();
|
||||
if (mpris.isEmpty()) return info;
|
||||
return getPlayerMprisInfo(mpris);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress,
|
||||
const QString mpdPort)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = QString("0");
|
||||
info[QString("progress")] = QString("0");
|
||||
info[QString("title")] = QString("unknown");
|
||||
|
||||
QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1:%2\"")
|
||||
.arg(mpdAddress)
|
||||
.arg(mpdPort);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
QString qstr = QString("");
|
||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Album"))
|
||||
info[QString("album")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
|
||||
info[QString("artist")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time")) {
|
||||
info[QString("duration")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[0];
|
||||
info[QString("progress")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[1];
|
||||
} else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
|
||||
info[QString("title")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << "MPRIS" << mpris;
|
||||
|
||||
QMap<QString, QVariant> info;
|
||||
info[QString("album")] = QString("unknown");
|
||||
info[QString("artist")] = QString("unknown");
|
||||
info[QString("duration")] = 0;
|
||||
info[QString("progress")] = 0;
|
||||
info[QString("title")] = QString("unknown");
|
||||
|
||||
// init
|
||||
QDBusArgument arg;
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage response, request;
|
||||
QVariantMap map;
|
||||
|
||||
// general information
|
||||
request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
|
||||
QString("/Player"),
|
||||
QString(""),
|
||||
QString("GetMetadata"));
|
||||
response = bus.call(request, QDBus::BlockWithGui);
|
||||
if (response.arguments().size() == 0) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
} else {
|
||||
arg = response.arguments()[0].value<QDBusArgument>();
|
||||
arg >> map;
|
||||
info[QString("album")] = map[QString("album")];
|
||||
info[QString("artist")] = map[QString("artist")];
|
||||
info[QString("duration")] = map[QString("time")];
|
||||
info[QString("title")] = map[QString("title")];
|
||||
}
|
||||
|
||||
// position
|
||||
request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
|
||||
QString("/Player"),
|
||||
QString(""),
|
||||
QString("PositionGet"));
|
||||
response = bus.call(request, QDBus::BlockWithGui);
|
||||
if (response.arguments().size() == 0) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
} else
|
||||
info[QString("progress")] = response.arguments()[0].toInt() / 1000;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
QStringList directories = allDirectories.filter(QRegExp(QString("(\\d+)")));
|
||||
QStringList running;
|
||||
|
||||
for (int i=0; i<directories.count(); i++) {
|
||||
QFile statusFile(QString("/proc/%1/status").arg(directories[i]));
|
||||
if (!statusFile.open(QIODevice::ReadOnly)) continue;
|
||||
QFile cmdFile(QString("/proc/%1/cmdline").arg(directories[i]));
|
||||
if (!cmdFile.open(QIODevice::ReadOnly)) continue;
|
||||
|
||||
QString output = statusFile.readAll();
|
||||
if (output.contains(QString("running"))) running.append(cmdFile.readAll());
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> psStats;
|
||||
psStats[QString("pscount")] = running.count();
|
||||
psStats[QString("ps")] = running.join(QString(","));
|
||||
psStats[QString("pstotal")] = directories.count();
|
||||
|
||||
return psStats;
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::sourceRequestEvent(const QString &source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
|
||||
return updateSourceEvent(source);
|
||||
}
|
||||
|
||||
|
||||
bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
|
||||
if (source == QString("battery")) {
|
||||
QMap<QString, QVariant> battery = getBattery(configuration[QString("ACPIPATH")]);
|
||||
setData(source, QString("ac"), battery[QString("ac")].toBool());
|
||||
for (int i=0; i<battery.keys().count(); i++) {
|
||||
if (battery.keys()[i] == QString("ac")) continue;
|
||||
setData(source, battery.keys()[i], battery[battery.keys()[i]].toInt());
|
||||
}
|
||||
} else if (source == QString("custom")) {
|
||||
for (int i=0; i<externalScripts.count(); i++)
|
||||
setData(source, QString("custom") + QString::number(i), externalScripts[i]->run());
|
||||
} else if (source == QString("desktop")) {
|
||||
QMap<QString, QVariant> desktop = getCurrentDesktop();
|
||||
for (int i=0; i<desktop.keys().count(); i++)
|
||||
setData(source, desktop.keys()[i], desktop[desktop.keys()[i]]);
|
||||
} else if (source == QString("gpu")) {
|
||||
setData(source, QString("value"), getGpu(configuration[QString("GPUDEV")]));
|
||||
} else if (source == QString("gputemp")) {
|
||||
setData(source, QString("value"), getGpuTemp(configuration[QString("GPUDEV")]));
|
||||
} else if (source == QString("hddtemp")) {
|
||||
// fill empty list
|
||||
for (int i=0; i<allHddDevices.count(); i++)
|
||||
setData(source, allHddDevices[i], 0.0);
|
||||
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||
for (int i=0; i<deviceList.count(); i++)
|
||||
setData(source, deviceList[i],
|
||||
getHddTemp(configuration[QString("HDDTEMPCMD")], deviceList[i]));
|
||||
} else if (source == QString("netdev")) {
|
||||
setData(source, QString("value"), getNetworkDevice());
|
||||
} else if (source == QString("pkg")) {
|
||||
for (int i=0; i<externalUpgrade.count(); i++)
|
||||
setData(source, QString("pkgcount") + QString::number(i), externalUpgrade[i]->run());
|
||||
} else if (source == QString("player")) {
|
||||
QMap<QString, QVariant> player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
||||
configuration[QString("MPDPORT")],
|
||||
configuration[QString("MPRIS")]);
|
||||
for (int i=0; i<player.keys().count(); i++)
|
||||
setData(source, player.keys()[i], player[player.keys()[i]]);
|
||||
} else if (source == QString("ps")) {
|
||||
QMap<QString, QVariant> ps = getPsStats();
|
||||
for (int i=0; i<ps.keys().count(); i++)
|
||||
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
||||
} else if (source == QString("update")) {
|
||||
setData(source, QString("value"), true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
|
||||
|
||||
#include "extsysmon.moc"
|
73
sources/extsysmon/extsysmon.h
Normal file
@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EXTSYSMON_H
|
||||
#define EXTSYSMON_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
|
||||
class ExtendedSysMon : public Plasma::DataEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||
// update functions
|
||||
QMap<QString, QVariant> getBattery(const QString acpiPath);
|
||||
QMap<QString, QVariant> getCurrentDesktop();
|
||||
float getGpu(const QString device);
|
||||
float getGpuTemp(const QString device);
|
||||
float getHddTemp(const QString cmd, const QString device);
|
||||
QString getNetworkDevice();
|
||||
QMap<QString, QVariant> getPlayerInfo(const QString playerName,
|
||||
const QString mpdAddress = 0,
|
||||
const QString mpdPort = 0,
|
||||
const QString mpris = 0);
|
||||
QMap<QString, QVariant> getPlayerMpdInfo(const QString mpdAddress = 0,
|
||||
const QString mpdPort = 0);
|
||||
QMap<QString, QVariant> getPlayerMprisInfo(const QString mpris = 0);
|
||||
QMap<QString, QVariant> getPsStats();
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &source);
|
||||
bool updateSourceEvent(const QString &source);
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QList<ExtScript *> externalScripts;
|
||||
QList<ExtUpgrade *> externalUpgrade;
|
||||
bool debug;
|
||||
// reread configuration
|
||||
QStringList allHddDevices;
|
||||
QString getAllHdd();
|
||||
QString getAutoGpu();
|
||||
QString getAutoMpris();
|
||||
void initScripts();
|
||||
void initUpgrade();
|
||||
void readConfiguration();
|
||||
QMap<QString, QString> updateConfiguration(QMap<QString, QString> rawConfig);
|
||||
};
|
||||
|
||||
|
||||
#endif /* EXTSYSMON_H */
|
288
sources/extsysmon/extupgrade.cpp
Normal file
@ -0,0 +1,288 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "extupgrade.h"
|
||||
#include "ui_extupgrade.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName, const QStringList directories, const bool debugCmd) :
|
||||
QDialog(parent),
|
||||
m_fileName(upgradeName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtUpgrade)
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
ExtUpgrade::~ExtUpgrade()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::executable()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::interval()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_interval;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::null()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_null;
|
||||
}
|
||||
|
||||
|
||||
bool ExtUpgrade::isActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_active;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setActive(const bool state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
m_active = state;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setExecutable(const QString _executable)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||
|
||||
m_executable = _executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setInterval(const int _interval)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
|
||||
|
||||
m_interval = _interval;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setNull(const int _null)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Null lines" << _null;
|
||||
if (_null < 0) return;
|
||||
|
||||
m_null = _null;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
|
||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!m_active) return value;
|
||||
|
||||
if (times == 1) {
|
||||
TaskResult process = runTask(QString("bash -c \"") + m_executable + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
value = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null;
|
||||
}
|
||||
|
||||
// update value
|
||||
if (times >= m_interval) times = 0;
|
||||
times++;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::showConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->lineEdit_command->setText(m_executable);
|
||||
if (m_active)
|
||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_active->setCheckState(Qt::Unchecked);
|
||||
ui->spinBox_null->setValue(m_null);
|
||||
ui->spinBox_interval->setValue(m_interval);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWEUAPI);
|
||||
setExecutable(ui->lineEdit_command->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setNull(ui->spinBox_null->value());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
|
||||
// check if exists
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("Exec"), m_executable);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Null"), m_null);
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
86
sources/extsysmon/extupgrade.h
Normal file
@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EXTUPGRADE_H
|
||||
#define EXTUPGRADE_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ExtUpgrade;
|
||||
}
|
||||
|
||||
class ExtUpgrade : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(int null READ null WRITE setNull)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
|
||||
public:
|
||||
explicit ExtUpgrade(QWidget *parent = 0, const QString upgradeName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~ExtUpgrade();
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
int interval();
|
||||
QString name();
|
||||
int null();
|
||||
bool isActive();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNull(const int _null = 0);
|
||||
void setInterval(const int _interval = 0);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
int run();
|
||||
int showConfiguration();
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::ExtUpgrade *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
QString m_name = QString("none");
|
||||
int m_null = 0;
|
||||
int m_interval = 3600;
|
||||
int times = 0;
|
||||
int value = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* EXTUPGRADE_H */
|
230
sources/extsysmon/extupgrade.ui
Normal file
@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExtUpgrade</class>
|
||||
<widget class="QDialog" name="ExtUpgrade">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_name">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_comment">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_comment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_comment"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_command">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_command">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_command"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_active">
|
||||
<item>
|
||||
<spacer name="spacer_active">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_active">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_null">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_null">
|
||||
<property name="text">
|
||||
<string>Null</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_null">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_interval">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interval">
|
||||
<property name="text">
|
||||
<string>Interval</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3600</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ExtUpgrade</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ExtUpgrade</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
18
sources/extsysmon/plasma-dataengine-extsysmon.conf
Normal file
@ -0,0 +1,18 @@
|
||||
[Configuration]
|
||||
# ACPI devices
|
||||
ACPIPATH=/sys/class/power_supply/
|
||||
# May be 'nvidia' (for nvidia), 'ati' (for ATI RADEON), 'disable' or 'auto'
|
||||
GPUDEV=auto
|
||||
# HDD temperature
|
||||
## Set block device for hddtemp comma separated or use 'all' or 'disable'
|
||||
HDDDEV=all
|
||||
# cmd
|
||||
HDDTEMPCMD=sudo hddtemp
|
||||
# mpd server settings
|
||||
MPDADDRESS=localhost
|
||||
MPDPORT=6600
|
||||
# MPRIS player name or 'auto'. In the most cases it should be a player name
|
||||
## DBus path is org.mpris.MediaPlayer2.amarok
|
||||
MPRIS=auto
|
||||
# Player name. Supported players are 'mpd', 'mpris'
|
||||
PLAYER=mpris
|
@ -7,14 +7,14 @@ Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_extsysmon
|
||||
X-Plasma-EngineName=ext-sysmon
|
||||
X-KDE-Library=plasma_dataengine_extsysmon
|
||||
X-Plasma-EngineName=extsysmon
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=ext-sysmon
|
||||
X-KDE-PluginInfo-Name=extsysmon
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-License=GPL3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
11
sources/extsysmon/scripts/get-external-ip.desktop
Normal file
@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=aw-get-external-ip
|
||||
Comment=Custom command to get external IP
|
||||
Exec=curl ip4.telize.com
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=true
|
||||
X-AW-Output=true
|
||||
X-AW-Redirect=nothing
|
||||
X-AW-Interval=1
|
||||
X-AW-ApiVersion=1
|
20
sources/extsysmon/scripts/script-template.desktop
Normal file
@ -0,0 +1,20 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=aw-script-template
|
||||
Comment=Template for external script
|
||||
# path to command
|
||||
Exec=/path/to/some/command
|
||||
# usually you need to leave this field blank
|
||||
# use this field to setup script language for example
|
||||
X-AW-Prefix=/prefix/to/command/if/required
|
||||
# is the script active. true or false
|
||||
X-AW-Active=false
|
||||
# is the script has output. true or false
|
||||
X-AW-Output=false
|
||||
# use redirect for the script
|
||||
# stderr2stdout, nothing, stdout2stderr
|
||||
X-AW-Redirect=nothing
|
||||
# update interval in default AW intervals
|
||||
X-AW-Interval=1
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
10
sources/extsysmon/upgrade/default-arch.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-arch
|
||||
Comment=Archlinux upgrade info
|
||||
Exec=pacman -Qu
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
10
sources/extsysmon/upgrade/default-debian.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-debian
|
||||
Comment=Debian upgrade info
|
||||
Exec=apt-show-versions -u -b
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
10
sources/extsysmon/upgrade/default-fedora.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-fedora
|
||||
Comment=Fedora upgrade info
|
||||
Exec=yum list updates
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=3
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
10
sources/extsysmon/upgrade/default-mandriva.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-mandriva
|
||||
Comment=Mandriva upgrade info
|
||||
Exec=urpmq --auto-select
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
10
sources/extsysmon/upgrade/default-ubuntu.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=default-ubuntu
|
||||
Comment=Ubuntu upgrade info
|
||||
Exec=aptitude search '~U'
|
||||
X-AW-Prefix=
|
||||
X-AW-Active=false
|
||||
X-AW-Null=0
|
||||
X-AW-Interval=3600
|
||||
X-AW-ApiVersion=1
|
37
sources/packages-recipe.cmake
Normal file
@ -0,0 +1,37 @@
|
||||
# generators
|
||||
if(BUILD_DEB_PACKAGE)
|
||||
set(CPACK_GENERATOR ${CPACK_GENERATOR} "DEB")
|
||||
endif()
|
||||
if(BUILD_RPM_PACKAGE)
|
||||
set(CPACK_GENERATOR ${CPACK_GENERATOR} "RPM")
|
||||
endif()
|
||||
|
||||
# build properties
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# general metadata
|
||||
set(CPACK_PACKAGE_NAME "plasma-widget-awesome-widgets")
|
||||
set(CPACK_PACKAGE_CONTACT "${PROJECT_AUTHOR}")
|
||||
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
|
||||
set(CPACK_PACKAGE_RELEASE "1")
|
||||
# doesn't match to official arch :/
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
# deb specific
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "kdebase-workspace, lm-sensors")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)")
|
||||
set(CPACK_DEBIAN_PACKAGE_ENHANCES "mpd, smartmontools")
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://arcanis.name/projects/awesome-widgets")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "KDE")
|
||||
|
||||
# rpm specific
|
||||
set(CPACK_RPM_PACKAGE_DESCRIPTION "Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)")
|
||||
set(CPACK_RPM_PACKAGE_GROUP "User Interface/Desktops")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "${PROJECT_LICENSE}")
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "kdebase4-workspace, sensors")
|
||||
set(CPACK_RPM_PACKAGE_SUGGESTS "mpd, smartmontools")
|
||||
set(CPACK_RPM_PACKAGE_URL "https://arcanis.name/projects/awesome-widgets")
|
||||
|
||||
if(BUILD_DEB_PACKAGE OR BUILD_RPM_PACKAGE)
|
||||
include(CPack)
|
||||
endif()
|
@ -1,31 +0,0 @@
|
||||
# set project name
|
||||
set (SUBPROJECT pytextmonitor)
|
||||
# for notifications
|
||||
set (PLUGIN_NAME plasma_applet_pytextmonitor)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
add_definitions (${KDE4_DEFINITIONS})
|
||||
|
||||
add_subdirectory (po)
|
||||
|
||||
# set sources
|
||||
set (SUBPROJECT_CODE_DIR "contents/code")
|
||||
set (SUBPROJECT_MISC_DIR "contents/misc")
|
||||
set (SUBPROJECT_UI_DIR "contents/ui")
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB SUBPROJECT_NOTIFY ${SUBPROJECT_MISC_DIR}/*.notifyrc)
|
||||
file (GLOB SUBPROJECT_SOURCE ${SUBPROJECT_CODE_DIR}/*.py)
|
||||
file (GLOB SUBPROJECT_UI ${SUBPROJECT_UI_DIR}/*.ui)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# install
|
||||
install (FILES ${SUBPROJECT_SOURCE} DESTINATION "share/apps/plasma/plasmoids/${SUBPROJECT}/${SUBPROJECT_CODE_DIR}")
|
||||
install (FILES ${SUBPROJECT_UI} DESTINATION "share/apps/plasma/plasmoids/${SUBPROJECT}/${SUBPROJECT_UI_DIR}")
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR} RENAME "plasma-applet-${SUBPROJECT}.desktop")
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION "share/apps/plasma/plasmoids/${SUBPROJECT}")
|
||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
@ -1,111 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import *
|
||||
from PyQt4 import uic
|
||||
|
||||
|
||||
|
||||
class AdvancedWindow(QWidget):
|
||||
def __init__(self, parent):
|
||||
"""settings window definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'advanced.ui'), self)
|
||||
self.parent = parent
|
||||
|
||||
QObject.connect(self.ui.checkBox_netdev, SIGNAL("stateChanged(int)"), self.setNetdevEnabled)
|
||||
QObject.connect(self.ui.pushButton_hddDevice, SIGNAL("clicked()"), self.addHddDevice)
|
||||
QObject.connect(self.ui.pushButton_hddSpeedDevice, SIGNAL("clicked()"), self.addHddSpeedDevice)
|
||||
QObject.connect(self.ui.pushButton_mount, SIGNAL("clicked()"), self.addMount)
|
||||
QObject.connect(self.ui.pushButton_tempDevice, SIGNAL("clicked()"), self.addTempDevice)
|
||||
QObject.connect(self.ui.listWidget_hddDevice, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_hddDevice.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_hddSpeedDevice, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_hddSpeedDevice.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_mount, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_mount.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_tempDevice, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_tempDevice.openPersistentEditor)
|
||||
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""delete events"""
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [keyPressEvent]")
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [keyPressEvent] : Run function with event '%s'" %(event.key()))
|
||||
if (event.key() == Qt.Key_Delete):
|
||||
if (self.ui.listWidget_hddDevice.hasFocus() and
|
||||
(self.ui.listWidget_hddDevice.currentRow() > -1)):
|
||||
self.ui.listWidget_hddDevice.takeItem(self.ui.listWidget_hddDevice.currentRow())
|
||||
elif (self.ui.listWidget_hddSpeedDevice.hasFocus() and
|
||||
(self.ui.listWidget_hddSpeedDevice.currentRow() > -1)):
|
||||
self.ui.listWidget_hddSpeedDevice.takeItem(self.ui.listWidget_hddSpeedDevice.currentRow())
|
||||
elif (self.ui.listWidget_mount.hasFocus() and
|
||||
(self.ui.listWidget_mount.currentRow() > -1)):
|
||||
self.ui.listWidget_mount.takeItem(self.ui.listWidget_mount.currentRow())
|
||||
elif (self.ui.listWidget_tempDevice.hasFocus() and
|
||||
(self.ui.listWidget_tempDevice.currentRow() > -1)):
|
||||
self.ui.listWidget_tempDevice.takeItem(self.ui.listWidget_tempDevice.currentRow())
|
||||
|
||||
|
||||
def addHddDevice(self):
|
||||
"""function to add mount points"""
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addHddDevice]")
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addHddDevice] : Device '%s'" %(self.ui.comboBox_hddDevice.currentText()))
|
||||
self.ui.listWidget_hddDevice.clearSelection()
|
||||
self.ui.listWidget_hddDevice.addItem(self.ui.comboBox_hddDevice.currentText())
|
||||
|
||||
|
||||
def addHddSpeedDevice(self):
|
||||
"""function to add disk device"""
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addHddSpeedDevice]")
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addHddSpeedDevice] : Device '%s'" %(self.ui.comboBox_hddSpeedDevice.currentText()))
|
||||
self.ui.listWidget_hddSpeedDevice.clearSelection()
|
||||
self.ui.listWidget_hddSpeedDevice.addItem(self.ui.comboBox_hddSpeedDevice.currentText())
|
||||
|
||||
|
||||
def addMount(self):
|
||||
"""function to add mount points"""
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addMount]")
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addMount] : Device '%s'" %(self.ui.comboBox_mount.currentText()))
|
||||
self.ui.listWidget_mount.clearSelection()
|
||||
self.ui.listWidget_mount.addItem(self.ui.comboBox_mount.currentText())
|
||||
|
||||
|
||||
def addTempDevice(self):
|
||||
"""function to add temperature device"""
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addTempDevice]")
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [addTempDevice] : Device '%s'" %(self.ui.comboBox_tempDevice.currentText()))
|
||||
self.ui.listWidget_tempDevice.clearSelection()
|
||||
self.ui.listWidget_tempDevice.addItem(self.ui.comboBox_tempDevice.currentText())
|
||||
|
||||
|
||||
def setNetdevEnabled(self):
|
||||
"""function to set enabled netdev"""
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [setNetdevEnabled]")
|
||||
if self.debug: qDebug("[PTM] [advanced.py] [setNetdevEnabled] : State '%s'" %(self.ui.checkBox_netdev.checkState()))
|
||||
if (self.ui.checkBox_netdev.checkState() == 0):
|
||||
self.ui.comboBox_netdev.setDisabled(True)
|
||||
else:
|
||||
self.ui.comboBox_netdev.setEnabled(True)
|
@ -1,40 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import *
|
||||
from PyQt4 import uic
|
||||
|
||||
|
||||
|
||||
class AppearanceWindow(QWidget):
|
||||
def __init__(self, parent):
|
||||
"""settings window definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'appearance.ui'), self)
|
||||
self.parent = parent
|
@ -1,34 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# Copyright 2012 Alex Oleshkevich <alex.oleshkevich@gmail.com> #
|
||||
# #
|
||||
# This program is free software; you can redistribute it and/or modify #
|
||||
# it under the terms of the GNU General Public License as published by #
|
||||
# the Free Software Foundation; either version 2 of the License, or #
|
||||
# (at your option) any later version. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., #
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #
|
||||
############################################################################
|
||||
|
||||
|
||||
|
||||
class Config():
|
||||
def __init__(self, applet):
|
||||
self.applet = applet
|
||||
self.config = self.applet.config()
|
||||
|
||||
|
||||
def get(self, key, default = ''):
|
||||
return self.config.readEntry(key, default).toString()
|
||||
|
||||
|
||||
def set(self, key, value):
|
||||
self.config.writeEntry(key, value)
|
@ -1,284 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
import commands
|
||||
import config
|
||||
|
||||
|
||||
|
||||
class ConfigDefinition:
|
||||
def __init__(self, parent, configpage, defaults):
|
||||
"""class definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
self.parent = parent
|
||||
self.configpage = configpage
|
||||
self.defaults = defaults
|
||||
|
||||
|
||||
def configAccepted(self):
|
||||
"""function to accept settings"""
|
||||
if self.debug: qDebug("[PTM] [configdef.py] [configAccepted]")
|
||||
settings = config.Config(self.parent)
|
||||
|
||||
# update local variables
|
||||
settings.set('interval', self.configpage['appearance'].ui.spinBox_interval.value())
|
||||
settings.set('font_family', str(self.configpage['appearance'].ui.fontComboBox.currentFont().family()))
|
||||
settings.set('font_size', self.configpage['appearance'].ui.spinBox_fontSize.value())
|
||||
settings.set('font_color', str(self.configpage['appearance'].ui.kcolorcombo.color().name()))
|
||||
settings.set('font_style', str(self.configpage['appearance'].ui.comboBox_style.currentText()))
|
||||
settings.set('font_weight', self.configpage['appearance'].ui.spinBox_weight.value())
|
||||
|
||||
settings.set('layout', self.configpage['advanced'].ui.checkBox_layout.checkState())
|
||||
settings.set('popup', self.configpage['advanced'].ui.checkBox_popup.checkState())
|
||||
settings.set('left_stretch', self.configpage['advanced'].ui.checkBox_leftStretch.checkState())
|
||||
settings.set('right_stretch', self.configpage['advanced'].ui.checkBox_rightStretch.checkState())
|
||||
settings.set('custom_time', str(self.configpage['advanced'].ui.lineEdit_timeFormat.text()))
|
||||
settings.set('custom_uptime', str(self.configpage['advanced'].ui.lineEdit_uptimeFormat.text()))
|
||||
settings.set('temp_units', str(self.configpage['advanced'].ui.comboBox_tempUnits.currentText()))
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['advanced'].ui.listWidget_tempDevice.count()):
|
||||
item.append(self.configpage['advanced'].ui.listWidget_tempDevice.item(i).text())
|
||||
settings.set('temp_device', str(item.join(QString('@@'))))
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['advanced'].ui.listWidget_mount.count()):
|
||||
item.append(self.configpage['advanced'].ui.listWidget_mount.item(i).text())
|
||||
settings.set('mount', str(item.join(QString('@@'))))
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['advanced'].ui.listWidget_hddDevice.count()):
|
||||
item.append(self.configpage['advanced'].ui.listWidget_hddDevice.item(i).text())
|
||||
settings.set('hdd', str(item.join(QString('@@'))))
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['advanced'].ui.listWidget_hddSpeedDevice.count()):
|
||||
item.append(self.configpage['advanced'].ui.listWidget_hddSpeedDevice.item(i).text())
|
||||
settings.set('disk', str(item.join(QString('@@'))))
|
||||
settings.set('netdir', str(self.configpage['advanced'].ui.lineEdit_netdir.text()))
|
||||
settings.set('netdevBool', self.configpage['advanced'].ui.checkBox_netdev.checkState())
|
||||
settings.set('custom_netdev', str(self.configpage['advanced'].ui.comboBox_netdev.currentText()))
|
||||
settings.set('battery_device', str(self.configpage['advanced'].ui.lineEdit_batdev.text()))
|
||||
settings.set('ac_device', str(self.configpage['advanced'].ui.lineEdit_acdev.text()))
|
||||
settings.set('ac_online', str(self.configpage['advanced'].ui.lineEdit_acOnline.text()))
|
||||
settings.set('ac_offline', str(self.configpage['advanced'].ui.lineEdit_acOffline.text()))
|
||||
|
||||
settings.set('tooltip_num', self.configpage['tooltip'].ui.spinBox_tooltipNum.value())
|
||||
for label in ['cpu', 'cpuclock', 'mem', 'swap', 'down', 'up']:
|
||||
settings.set(self.defaults['confColor'][label], str(self.configpage['tooltip'].kcolorcombos[label].color().name()))
|
||||
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
with open(dataengineConfig, 'w') as deConfigFile:
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['dataengine'].ui.listWidget_customCommand.count()):
|
||||
item.append(self.configpage['dataengine'].ui.listWidget_customCommand.item(i).text())
|
||||
deConfigFile.write("CUSTOM=" + str(item.join(QString('@@'))) + "\n")
|
||||
deConfigFile.write("GPUDEV=" + str(self.configpage['dataengine'].ui.comboBox_gpudev.currentText()) + "\n")
|
||||
deConfigFile.write("HDDDEV=" + str(self.configpage['dataengine'].ui.comboBox_hdddev.currentText()) + "\n")
|
||||
deConfigFile.write("HDDTEMPCMD=" + str(self.configpage['dataengine'].ui.lineEdit_hddtempCmd.text()) + "\n")
|
||||
deConfigFile.write("MPDADDRESS=" + str(self.configpage['dataengine'].ui.lineEdit_mpdaddress.text()) + "\n")
|
||||
deConfigFile.write("MPDPORT=" + str(self.configpage['dataengine'].ui.spinBox_mpdport.value()) + "\n")
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['dataengine'].ui.listWidget_pkgCommand.count()):
|
||||
item.append(self.configpage['dataengine'].ui.listWidget_pkgCommand.item(i).text())
|
||||
pkgCmd = []
|
||||
pkgNull = []
|
||||
for command in item:
|
||||
try:
|
||||
pkgCmd.append(str(command.split(QString(":"))[0]))
|
||||
pkgNull.append(str(command.split(QString(":"))[1]))
|
||||
except:
|
||||
pkgCmd.append(str(command))
|
||||
pkgNull.append("0")
|
||||
deConfigFile.write("PKGCMD=" + ','.join(pkgCmd) + "\n")
|
||||
deConfigFile.write("PKGNULL=" + ','.join(pkgNull) + "\n")
|
||||
deConfigFile.write("PLAYER=" + str(self.configpage['dataengine'].ui.comboBox_playerSelect.currentText()) + "\n")
|
||||
except:
|
||||
pass
|
||||
|
||||
# disconnecting from source and clear layout
|
||||
self.parent.disconnectFromSource()
|
||||
|
||||
labelOrder = "---------------"
|
||||
for label in self.defaults['order'].keys():
|
||||
if (self.configpage['widget'].checkboxes[self.defaults['order'][label]].checkState() > 0):
|
||||
pos = self.configpage['widget'].sliders[self.defaults['order'][label]].value() - 1
|
||||
labelOrder = labelOrder[:pos] + label + labelOrder[pos+1:]
|
||||
settings.set(self.defaults['confFormat'][self.defaults['order'][label]], str(self.configpage['widget'].lineedits[self.defaults['order'][label]].text()))
|
||||
settings.set(self.defaults['confBool'][self.defaults['order'][label]], self.configpage['widget'].checkboxes[self.defaults['order'][label]].checkState())
|
||||
labelOrder = ''.join(labelOrder.split('-'))
|
||||
settings.set('label_order', labelOrder)
|
||||
|
||||
# reinitializate
|
||||
self.parent.reInit()
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
if self.debug: qDebug("[PTM] [configdef.py] [createConfigurationInterface]")
|
||||
settings = config.Config(self.parent)
|
||||
|
||||
font = QFont(str(settings.get('font_family', 'Terminus')), settings.get('font_size', 12).toInt()[0], 400, False)
|
||||
self.configpage['appearance'].ui.spinBox_interval.setValue(settings.get('interval', 2000).toInt()[0])
|
||||
self.configpage['appearance'].ui.fontComboBox.setCurrentFont(font)
|
||||
self.configpage['appearance'].ui.spinBox_fontSize.setValue(settings.get('font_size', 12).toInt()[0])
|
||||
self.configpage['appearance'].ui.kcolorcombo.setColor(QColor(str(settings.get('font_color', '#000000'))))
|
||||
font = str(settings.get('font_style', 'normal'))
|
||||
if (font == 'normal'):
|
||||
self.configpage['appearance'].ui.comboBox_style.setCurrentIndex(0)
|
||||
else:
|
||||
self.configpage['appearance'].ui.comboBox_style.setCurrentIndex(1)
|
||||
self.configpage['appearance'].ui.spinBox_weight.setValue(settings.get('font_weight', 400).toInt()[0])
|
||||
|
||||
self.configpage['advanced'].ui.checkBox_layout.setCheckState(settings.get('layout', 0).toInt()[0])
|
||||
self.configpage['advanced'].ui.checkBox_popup.setCheckState(settings.get('popup', 2).toInt()[0])
|
||||
self.configpage['advanced'].ui.checkBox_leftStretch.setCheckState(settings.get('left_stretch', 2).toInt()[0])
|
||||
self.configpage['advanced'].ui.checkBox_rightStretch.setCheckState(settings.get('right_stretch', 2).toInt()[0])
|
||||
self.configpage['advanced'].ui.lineEdit_timeFormat.setText(str(settings.get('custom_time', '$hh:$mm')))
|
||||
self.configpage['advanced'].ui.lineEdit_uptimeFormat.setText(str(settings.get('custom_uptime', '$ds,$hs,$ms')))
|
||||
index = self.configpage['advanced'].ui.comboBox_tempUnits.findText(str(settings.get('temp_units', "Celsius")))
|
||||
self.configpage['advanced'].ui.comboBox_tempUnits.setCurrentIndex(index)
|
||||
commandOut = commands.getoutput("sensors")
|
||||
for item in commandOut.split("\n\n"):
|
||||
for device in item.split("\n"):
|
||||
if (device.find('\xc2\xb0C') > -1):
|
||||
try:
|
||||
tempdev = 'lmsensors/' + item.split("\n")[0] + '/' + '_'.join(device.split(":")[0].split())
|
||||
self.configpage['advanced'].ui.comboBox_tempDevice.addItem(tempdev)
|
||||
except:
|
||||
pass
|
||||
self.configpage['advanced'].ui.listWidget_tempDevice.clear()
|
||||
for item in str(settings.get('temp_device', '')).split('@@'):
|
||||
if (len(item) > 0):
|
||||
self.configpage['advanced'].ui.listWidget_tempDevice.addItem(item)
|
||||
commandOut = commands.getoutput("mount")
|
||||
for item in commandOut.split("\n"):
|
||||
try:
|
||||
mount = item.split(' on ')[1].split(' type ')[0]
|
||||
self.configpage['advanced'].ui.comboBox_mount.addItem(mount)
|
||||
except:
|
||||
pass
|
||||
self.configpage['advanced'].ui.listWidget_mount.clear()
|
||||
for item in str(settings.get('mount', '/')).split('@@'):
|
||||
self.configpage['advanced'].ui.listWidget_mount.addItem(item)
|
||||
commandOut = commands.getoutput("find /dev -name '[hms]d[a-z]'")
|
||||
for item in commandOut.split("\n"):
|
||||
try:
|
||||
self.configpage['advanced'].ui.comboBox_hddDevice.addItem(item)
|
||||
except:
|
||||
pass
|
||||
self.configpage['advanced'].ui.listWidget_hddDevice.clear()
|
||||
for item in str(settings.get('hdd', '/dev/sda')).split('@@'):
|
||||
self.configpage['advanced'].ui.listWidget_hddDevice.addItem(item)
|
||||
self.configpage['advanced'].ui.comboBox_hddSpeedDevice.clear()
|
||||
for item in self.defaults['disk']:
|
||||
self.configpage['advanced'].ui.comboBox_hddSpeedDevice.addItem(item)
|
||||
self.configpage['advanced'].ui.listWidget_hddSpeedDevice.clear()
|
||||
for item in str(settings.get('disk', 'disk/sda_(8:0)')).split('@@'):
|
||||
self.configpage['advanced'].ui.listWidget_hddSpeedDevice.addItem(item)
|
||||
self.configpage['advanced'].ui.lineEdit_netdir.setText(str(settings.get('netdir', '/sys/class/net')))
|
||||
self.configpage['advanced'].ui.checkBox_netdev.setCheckState(settings.get('netdevBool', 0).toInt()[0])
|
||||
for item in QDir.entryList(QDir(str(settings.get('netdir', '/sys/class/net'))), QDir.Dirs | QDir.NoDotAndDotDot):
|
||||
self.configpage['advanced'].ui.comboBox_netdev.addItem(item)
|
||||
index = self.configpage['advanced'].ui.comboBox_netdev.findText(str(settings.get('custom_netdev', 'lo')))
|
||||
self.configpage['advanced'].ui.comboBox_netdev.setCurrentIndex(index)
|
||||
self.configpage['advanced'].ui.lineEdit_batdev.setText(str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')))
|
||||
self.configpage['advanced'].ui.lineEdit_acdev.setText(str(settings.get('ac_device', '/sys/class/power_supply/AC/online')))
|
||||
self.configpage['advanced'].ui.lineEdit_acOnline.setText(str(settings.get('ac_online', '(*)')))
|
||||
self.configpage['advanced'].ui.lineEdit_acOffline.setText(str(settings.get('ac_offline', '( )')))
|
||||
|
||||
self.configpage['tooltip'].ui.spinBox_tooltipNum.setValue(settings.get('tooltip_num', 100).toInt()[0])
|
||||
self.configpage['tooltip'].ui.kcolorcombo_cpu.setColor(QColor(str(settings.get('cpu_color', '#ff0000'))))
|
||||
self.configpage['tooltip'].ui.kcolorcombo_cpuclock.setColor(QColor(str(settings.get('cpuclock_color', '#00ff00'))))
|
||||
self.configpage['tooltip'].ui.kcolorcombo_mem.setColor(QColor(str(settings.get('mem_color', '#0000ff'))))
|
||||
self.configpage['tooltip'].ui.kcolorcombo_swap.setColor(QColor(str(settings.get('swap_color', '#ffff00'))))
|
||||
self.configpage['tooltip'].ui.kcolorcombo_down.setColor(QColor(str(settings.get('down_color', '#00ffff'))))
|
||||
self.configpage['tooltip'].ui.kcolorcombo_up.setColor(QColor(str(settings.get('up_color', '#ff00ff'))))
|
||||
|
||||
deSettings = {'CUSTOM':'wget -qO- http://ifconfig.me/ip', 'GPUDEV':'auto', 'HDDDEV':'all',
|
||||
'HDDTEMPCMD':'sudo hddtemp', 'MPDADDRESS':'localhost', 'MPDPORT':'6600', 'PKGCMD':'pacman -Qu',
|
||||
'PKGNULL':'0', 'PLAYER':'amarok'}
|
||||
dataengineConfig = unicode(KGlobal.dirs().localkdedir()) + "/share/config/extsysmon.conf"
|
||||
try:
|
||||
with open(dataengineConfig, 'r') as deConfigFile:
|
||||
for line in deConfigFile:
|
||||
if ((line[0] != '#') and (line.split('=')[0] != line)):
|
||||
deSettings[line.split('=')[0]] = line.split('=')[1][:-1]
|
||||
except:
|
||||
pass
|
||||
for item in deSettings['CUSTOM'].split('@@'):
|
||||
self.configpage['dataengine'].ui.listWidget_customCommand.addItem(item)
|
||||
index = self.configpage['dataengine'].ui.comboBox_gpudev.findText(deSettings['GPUDEV'])
|
||||
self.configpage['dataengine'].ui.comboBox_gpudev.setCurrentIndex(index)
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.addItem("all")
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.addItem("disable")
|
||||
commandOut = commands.getoutput("find /dev -name '[hms]d[a-z]'")
|
||||
for item in commandOut.split("\n"):
|
||||
try:
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.addItem(item)
|
||||
except:
|
||||
pass
|
||||
index = self.configpage['dataengine'].ui.comboBox_hdddev.findText(deSettings['HDDDEV'])
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.setCurrentIndex(index)
|
||||
self.configpage['dataengine'].ui.lineEdit_hddtempCmd.setText(deSettings['HDDTEMPCMD'])
|
||||
self.configpage['dataengine'].ui.lineEdit_mpdaddress.setText(deSettings['MPDADDRESS'])
|
||||
self.configpage['dataengine'].ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT']))
|
||||
self.configpage['dataengine'].ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT']))
|
||||
self.configpage['dataengine'].ui.listWidget_pkgCommand.clear()
|
||||
for i in range(len(deSettings['PKGCMD'].split(','))):
|
||||
try:
|
||||
num = deSettings['PKGNULL'].split(',')[i]
|
||||
except:
|
||||
num = "0"
|
||||
self.configpage['dataengine'].ui.listWidget_pkgCommand.addItem(deSettings['PKGCMD'].split(',')[i] + ':' + num)
|
||||
index = self.configpage['dataengine'].ui.comboBox_playerSelect.findText(deSettings['PLAYER'])
|
||||
self.configpage['dataengine'].ui.comboBox_playerSelect.setCurrentIndex(index)
|
||||
|
||||
labelOrder = str(settings.get('label_order', '1345'))
|
||||
for label in self.defaults['order'].keys():
|
||||
bool = settings.get(self.defaults['confBool'][self.defaults['order'][label]],
|
||||
self.defaults['bool'][self.defaults['order'][label]]).toInt()[0]
|
||||
self.configpage['widget'].checkboxes[self.defaults['order'][label]].setCheckState(bool)
|
||||
if (bool > 0):
|
||||
self.configpage['widget'].sliders[self.defaults['order'][label]].setValue(labelOrder.find(label) + 1)
|
||||
self.configpage['widget'].lineedits[self.defaults['order'][label]].setText(str(settings.get(self.defaults['confFormat'][self.defaults['order'][label]],
|
||||
self.defaults['format'][self.defaults['order'][label]])))
|
||||
|
||||
# add config page
|
||||
page = {}
|
||||
page['widget'] = parent.addPage(self.configpage['widget'], i18n("Widget"))
|
||||
page['widget'].setIcon(KIcon("utilities-system-monitor"))
|
||||
page['advanced'] = parent.addPage(self.configpage['advanced'], i18n("Advanced"))
|
||||
page['advanced'].setIcon(KIcon("system-run"))
|
||||
page['tooltip'] = parent.addPage(self.configpage['tooltip'], i18n("Tooltip"))
|
||||
page['tooltip'].setIcon(KIcon("preferences-desktop-color"))
|
||||
page['appearance'] = parent.addPage(self.configpage['appearance'], i18n("Appearance"))
|
||||
page['appearance'].setIcon(KIcon("preferences-desktop-theme"))
|
||||
page['dataengine'] = parent.addPage(self.configpage['dataengine'], i18n("DataEngine"))
|
||||
page['dataengine'].setIcon(KIcon("utilities-system-monitor"))
|
||||
|
||||
QObject.connect(parent, SIGNAL("okClicked()"), self.configAccepted)
|
@ -1,350 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import Plasma
|
||||
|
||||
import datetime
|
||||
|
||||
timeLetters = ['dddd', 'ddd', 'dd', 'd', \
|
||||
'MMMM', 'MMM', 'MM', 'M', 'yyyy', 'yy', \
|
||||
'hh', 'h', 'mm', 'm', 'ss', 's']
|
||||
|
||||
|
||||
|
||||
class DataEngine:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
self.parent = parent
|
||||
|
||||
|
||||
def connectToEngine(self, bools=None, dataEngines=None, interval=1000, names=None):
|
||||
"""function to initializate engine"""
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [connectToEngine]")
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [connectToEngine] : Run function with bools '%s'" %(bools))
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [connectToEngine] : Run function with dataengines '%s'" %(dataEngines))
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [connectToEngine] : Run function with names '%s'" %(names))
|
||||
if (bools['cpu'] > 0):
|
||||
dataEngines['system'].connectSource("cpu/system/TotalLoad", self.parent, interval)
|
||||
for core in range(8):
|
||||
dataEngines['system'].connectSource("cpu/cpu" + str(core) + "/TotalLoad", self.parent, interval)
|
||||
if (bools['cpuclock'] > 0):
|
||||
dataEngines['system'].connectSource("cpu/system/AverageClock", self.parent, interval)
|
||||
for core in range(8):
|
||||
dataEngines['system'].connectSource("cpu/cpu" + str(core) + "/clock", self.parent, interval)
|
||||
if (bools['custom'] > 0):
|
||||
dataEngines['ext'].connectSource("custom", self.parent, interval)
|
||||
if (bools['disk'] > 0):
|
||||
for item in names['disk']:
|
||||
dataEngines['system'].connectSource(item + "/Rate/rblk", self.parent, interval)
|
||||
dataEngines['system'].connectSource(item + "/Rate/wblk", self.parent, interval)
|
||||
if (bools['gpu'] > 0):
|
||||
dataEngines['ext'].connectSource("gpu", self.parent, interval)
|
||||
if (bools['gputemp'] > 0):
|
||||
dataEngines['ext'].connectSource("gputemp", self.parent, interval)
|
||||
if (bools['hdd'] > 0):
|
||||
for item in names['hdd']:
|
||||
dataEngines['system'].connectSource("partitions" + item + "/filllevel", self.parent, interval)
|
||||
dataEngines['system'].connectSource("partitions" + item + "/freespace", self.parent, interval)
|
||||
dataEngines['system'].connectSource("partitions" + item + "/usedspace", self.parent, interval)
|
||||
if (bools['hddtemp'] > 0):
|
||||
dataEngines['ext'].connectSource("hddtemp", self.parent, interval)
|
||||
if (bools['mem'] > 0):
|
||||
dataEngines['system'].connectSource("mem/physical/free", self.parent, interval)
|
||||
dataEngines['system'].connectSource("mem/physical/used", self.parent, interval)
|
||||
dataEngines['system'].connectSource("mem/physical/application", self.parent, interval)
|
||||
if (bools['net'] > 0):
|
||||
self.updateNetdev = 0
|
||||
dataEngines['system'].connectSource("network/interfaces/" + names['net'] + "/transmitter/data", self.parent, interval)
|
||||
dataEngines['system'].connectSource("network/interfaces/" + names['net'] + "/receiver/data", self.parent, interval)
|
||||
if (bools['pkg'] > 0):
|
||||
dataEngines['ext'].connectSource("pkg", self.parent, 60*60*1000, Plasma.AlignToHour)
|
||||
if (bools['player'] > 0):
|
||||
dataEngines['ext'].connectSource("player", self.parent, interval)
|
||||
if (bools['ps'] > 0):
|
||||
dataEngines['ext'].connectSource("ps", self.parent, interval)
|
||||
if (bools['swap'] > 0):
|
||||
dataEngines['system'].connectSource("mem/swap/free", self.parent, interval)
|
||||
dataEngines['system'].connectSource("mem/swap/used", self.parent, interval)
|
||||
if (bools['temp'] > 0):
|
||||
for item in names['temp']:
|
||||
dataEngines['system'].connectSource(item, self.parent, interval)
|
||||
if (bools['time'] > 0):
|
||||
dataEngines['time'].connectSource("Local", self.parent, 1000)
|
||||
if (bools['uptime'] > 0):
|
||||
dataEngines['system'].connectSource("system/uptime", self.parent, interval)
|
||||
|
||||
|
||||
def dataUpdated(self, sourceName, data, ptm):
|
||||
"""function to update data"""
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [dataUpdated]")
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [dataUpdated] : Run function with source '%s'" %(sourceName))
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [dataUpdated] : Run function with data '%s'" %(data))
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [dataUpdated] : Run function with settings '%s'" %(ptm))
|
||||
adv = ptm['vars']['adv']
|
||||
systemDataEngine = ptm['dataengine']['system']
|
||||
formats = ptm['vars']['formats']
|
||||
interval = ptm['vars']['app']['interval']
|
||||
names = ptm['names']
|
||||
updatedData = {'name':None, 'type':None, 'value':None}
|
||||
try:
|
||||
if (sourceName == "cpu/system/TotalLoad"):
|
||||
updatedData['name'] = "cpu"
|
||||
updatedData['type'] = -1
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif ((sourceName[:7] == "cpu/cpu") and (sourceName.split('/')[2] == "TotalLoad")):
|
||||
updatedData['name'] = "cpu"
|
||||
updatedData['type'] = int(sourceName[7])
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "cpu/system/AverageClock"):
|
||||
updatedData['name'] = "cpuclock"
|
||||
updatedData['type'] = -1
|
||||
value = round(data[QString(u'value')].toFloat()[0], 0)
|
||||
updatedData['value'] = value
|
||||
elif ((sourceName[:7] == "cpu/cpu") and (sourceName.split('/')[2] == "clock")):
|
||||
updatedData['name'] = "cpuclock"
|
||||
updatedData['type'] = int(sourceName[7])
|
||||
value = round(data[QString(u'value')].toFloat()[0], 0)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "custom"):
|
||||
updatedData['name'] = "custom"
|
||||
updatedData['value'] = {}
|
||||
for singleData in data.keys():
|
||||
updatedData['value'][str(singleData.toLower())] = str(data[singleData].toUtf8()).decode("utf-8")
|
||||
elif ((sourceName[:4] == "disk") and (sourceName[-4:] == "rblk")):
|
||||
updatedData['name'] = "disk-r"
|
||||
updatedData['type'] = '/'.join(str(sourceName).split('/')[0:2])
|
||||
value = round(data[QString(u'value')].toFloat()[0], 0)
|
||||
updatedData['value'] = value
|
||||
elif ((sourceName[:4] == "disk") and (sourceName[-4:] == "wblk")):
|
||||
updatedData['name'] = "disk-w"
|
||||
updatedData['type'] = '/'.join(str(sourceName).split('/')[0:2])
|
||||
value = round(data[QString(u'value')].toFloat()[0], 0)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "gpu"):
|
||||
updatedData['name'] = "gpu"
|
||||
value = round(data[QString(u'GPU')], 1)
|
||||
updatedData['value'] = "%4.1f" % (value)
|
||||
elif (sourceName == "gputemp"):
|
||||
updatedData['name'] = "gputemp"
|
||||
value = round(data[QString(u'GPUTemp')], 1)
|
||||
updatedData['value'] = "%4.1f" % (value)
|
||||
elif (sourceName.split('/')[0] == "partitions") and (sourceName.split('/')[-1] == "filllevel"):
|
||||
updatedData['name'] = "hdd"
|
||||
updatedData['type'] = '/' + '/'.join(sourceName.split('/')[1:-1])
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName.split('/')[0] == "partitions") and (sourceName.split('/')[-1] == "freespace"):
|
||||
updatedData['name'] = "hddfreemb"
|
||||
updatedData['type'] = '/' + '/'.join(sourceName.split('/')[1:-1])
|
||||
value = data[QString(u'value')].toFloat()[0]
|
||||
updatedData['value'] = value
|
||||
elif (sourceName.split('/')[0] == "partitions") and (sourceName.split('/')[-1] == "usedspace"):
|
||||
updatedData['name'] = "hddmb"
|
||||
updatedData['type'] = '/' + '/'.join(sourceName.split('/')[1:-1])
|
||||
value = data[QString(u'value')].toFloat()[0]
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "hddtemp"):
|
||||
updatedData['name'] = "hddtemp"
|
||||
updatedData['value'] = {}
|
||||
for item in names['hddtemp']:
|
||||
value = round(data[QString(item)], 1)
|
||||
updatedData['value'][item] = "%4.1f" % (value)
|
||||
elif (sourceName == "mem/physical/application"):
|
||||
updatedData['name'] = "mem"
|
||||
updatedData['type'] = "app"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "mem/physical/free"):
|
||||
updatedData['name'] = "mem"
|
||||
updatedData['type'] = "free"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "mem/physical/used"):
|
||||
updatedData['name'] = "mem"
|
||||
updatedData['type'] = "used"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif ((sourceName.split('/')[0] == "network") and (sourceName.split('/')[3] == "receiver")):
|
||||
updatedData['name'] = "net"
|
||||
updatedData['type'] = "down"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 0)
|
||||
updatedData['value'] = value
|
||||
# update network device
|
||||
self.updateNetdev = self.updateNetdev + 1
|
||||
if (self.updateNetdev == 30):
|
||||
self.updateNetdev = 0
|
||||
if (adv['netdevBool'] == 0):
|
||||
systemDataEngine.disconnectSource("network/interfaces/" + names['net'] + "/transmitter/data", self.parent)
|
||||
systemDataEngine.disconnectSource("network/interfaces/" + names['net'] + "/receiver/data", self.parent)
|
||||
names['net'] = self.parent.setNetdev()
|
||||
systemDataEngine.connectSource("network/interfaces/" + names['net'] + "/transmitter/data", self.parent, interval)
|
||||
systemDataEngine.connectSource("network/interfaces/" + names['net'] + "/receiver/data", self.parent, interval)
|
||||
elif ((sourceName.split('/')[0] == "network") and (sourceName.split('/')[3] == "transmitter")):
|
||||
updatedData['name'] = "net"
|
||||
updatedData['type'] = "up"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 0)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "pkg"):
|
||||
updatedData['name'] = "pkg"
|
||||
updatedData['value'] = {}
|
||||
for singleData in data.keys():
|
||||
updatedData['value'][str(singleData.toLower())] = "%i" % (data[singleData])
|
||||
elif (sourceName == "player"):
|
||||
updatedData['name'] = "player"
|
||||
updatedData['value'] = {}
|
||||
updatedData['value']['album'] = str(data[QString(u'album')].toUtf8()).decode("utf-8")
|
||||
updatedData['value']['artist'] = str(data[QString(u'artist')].toUtf8()).decode("utf-8")
|
||||
updatedData['value']['progress'] = str(data[QString(u'progress')].toUtf8()).decode("utf-8")
|
||||
updatedData['value']['time'] = str(data[QString(u'duration')].toUtf8()).decode("utf-8")
|
||||
updatedData['value']['title'] = str(data[QString(u'title')].toUtf8()).decode("utf-8")
|
||||
elif (sourceName == "ps"):
|
||||
updatedData['name'] = "ps"
|
||||
updatedData['value'] = {}
|
||||
updatedData['value']['num'] = "%i" % (data[QString(u'psCount')])
|
||||
updatedData['value']['total'] = "%i" % (data[QString(u'psTotal')])
|
||||
updatedData['value']['list'] = data[QString(u'ps')]
|
||||
elif (sourceName == "mem/swap/free"):
|
||||
updatedData['name'] = "swap"
|
||||
updatedData['type'] = "free"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "mem/swap/used"):
|
||||
updatedData['name'] = "swap"
|
||||
updatedData['type'] = "used"
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = value
|
||||
elif (sourceName.split('/')[0] == "lmsensors"):
|
||||
updatedData['name'] = "temp"
|
||||
updatedData['type'] = sourceName
|
||||
value = round(data[QString(u'value')].toFloat()[0], 1)
|
||||
updatedData['value'] = "%4.1f" % (value)
|
||||
elif (sourceName == "Local"):
|
||||
updatedData['name'] = "time"
|
||||
if (formats['time'].split('$time')[0] != formats['time']):
|
||||
value = str(data[QString(u'DateTime')].toString(Qt.TextDate).toUtf8()).decode("utf-8")
|
||||
elif (formats['time'].split('$isotime')[0] != formats['time']):
|
||||
value = str(data[QString(u'DateTime')].toString(Qt.ISODate).toUtf8()).decode("utf-8")
|
||||
elif (formats['time'].split('$shorttime')[0] != formats['time']):
|
||||
value = str(data[QString(u'DateTime')].toString(Qt.SystemLocaleShortDate).toUtf8()).decode("utf-8")
|
||||
elif (formats['time'].split('$longtime')[0] != formats['time']):
|
||||
value = str(data[QString(u'DateTime')].toString(Qt.SystemLocaleLongDate).toUtf8()).decode("utf-8")
|
||||
elif (formats['time'].split('$custom')[0] != formats['time']):
|
||||
rawDate = data[QString(u'DateTime')]
|
||||
value = adv['customTime']
|
||||
for letters in timeLetters:
|
||||
if (value.split('$' + letters)[0] != value):
|
||||
value = value.split('$' + letters)[0] + str(rawDate.toString(letters).toUtf8()).decode("utf-8") + value.split('$' + letters)[1]
|
||||
updatedData['value'] = value
|
||||
elif (sourceName == "system/uptime"):
|
||||
updatedData['name'] = "uptime"
|
||||
value = datetime.timedelta(0, int(round(float(data[QString(u'value')]), 1)))
|
||||
days = value.days
|
||||
hours = int(value.seconds / 60 / 60)
|
||||
minutes = int(value.seconds / 60 % 60)
|
||||
if (formats['uptime'].split('$uptime')[0] != formats['uptime']):
|
||||
updatedData['value'] = "%3id%2ih%2im" % (days, hours, minutes)
|
||||
elif (formats['uptime'].split('$custom')[0] != formats['uptime']):
|
||||
updatedData['value'] = adv['customUptime']
|
||||
if (updatedData['value'].split('$dd')[0] != updatedData['value']):
|
||||
updatedData['value'] = "%s%03i%s" % (updatedData['value'].split('$dd')[0], days, updatedData['value'].split('$dd')[1])
|
||||
if (updatedData['value'].split('$d')[0] != updatedData['value']):
|
||||
updatedData['value'] = "%s%i%s" % (updatedData['value'].split('$d')[0], days, updatedData['value'].split('$d')[1])
|
||||
if (updatedData['value'].split('$hh')[0] != updatedData['value']):
|
||||
updatedData['value'] = "%s%02i%s" % (updatedData['value'].split('$hh')[0], hours, updatedData['value'].split('$hh')[1])
|
||||
if (updatedData['value'].split('$h')[0] != updatedData['value']):
|
||||
updatedData['value'] = "%s%i%s" % (updatedData['value'].split('$h')[0], hours, updatedData['value'].split('$h')[1])
|
||||
if (updatedData['value'].split('$mm')[0] != updatedData['value']):
|
||||
updatedData['value'] = "%s%02i%s" % (updatedData['value'].split('$mm')[0], minutes, updatedData['value'].split('$mm')[1])
|
||||
if (updatedData['value'].split('$m')[0] != updatedData['value']):
|
||||
updatedData['value'] = "%s%i%s" % (updatedData['value'].split('$m')[0], minutes, updatedData['value'].split('$m')[1])
|
||||
except:
|
||||
pass
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [dataUpdated] : Returns '%s'" %(updatedData))
|
||||
return updatedData
|
||||
|
||||
|
||||
def disconnectFromSource(self, dataEngines=None, keys=None, name=None):
|
||||
"""function to disconnect from sources"""
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [disconnectFromSource]")
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [disconnectFromSource] : Run function with dataengines '%s'" %(dataEngines))
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [disconnectFromSource] : Run function with keys '%s'" %(keys))
|
||||
if self.debug: qDebug("[PTM] [dataengine.py] [disconnectFromSource] : Run function with name '%s'" %(name))
|
||||
if (name == "bat"):
|
||||
pass
|
||||
elif (name == "cpu"):
|
||||
dataEngines['system'].disconnectSource("cpu/system/TotalLoad", self.parent)
|
||||
for item in keys['cpu']:
|
||||
if (item != -1):
|
||||
dataEngines['system'].disconnectSource("cpu/cpu" + str(item) + "/TotalLoad", self.parent)
|
||||
elif (name == "cpuclock"):
|
||||
dataEngines['system'].disconnectSource("cpu/system/AverageClock", self.parent)
|
||||
for item in keys['cpuclock']:
|
||||
if (item != -1):
|
||||
dataEngines['system'].disconnectSource("cpu/cpu" + str(item) + "/clock", self.parent)
|
||||
elif (name == "custom"):
|
||||
dataEngines['ext'].disconnectSource("custom", self.parent)
|
||||
elif (name == "disk"):
|
||||
for item in keys['disk']:
|
||||
dataEngines['system'].disconnectSource(item + "/Rate/rblk", self.parent)
|
||||
dataEngines['system'].disconnectSource(item + "/Rate/rblk", self.parent)
|
||||
elif (name == "gpu"):
|
||||
dataEngines['ext'].disconnectSource("gpu", self.parent)
|
||||
elif (name == "gputemp"):
|
||||
dataEngines['ext'].disconnectSource("gputemp", self.parent)
|
||||
elif (name == "hdd"):
|
||||
for item in keys['hdd']:
|
||||
dataEngines['system'].disconnectSource("partitions" + item + "/filllevel", self.parent)
|
||||
dataEngines['system'].disconnectSource("partitions" + item + "/usedspace", self.parent)
|
||||
elif (name == "hddtemp"):
|
||||
dataEngines['ext'].disconnectSource("hddtemp", self.parent)
|
||||
elif (name == "mem"):
|
||||
dataEngines['system'].disconnectSource("mem/physical/application", self.parent)
|
||||
dataEngines['system'].disconnectSource("mem/physical/free", self.parent)
|
||||
dataEngines['system'].disconnectSource("mem/physical/used", self.parent)
|
||||
elif (name == "net"):
|
||||
dataEngines['system'].disconnectSource("network/interfaces/" + keys['net'] + "/transmitter/data", self.parent)
|
||||
dataEngines['system'].disconnectSource("network/interfaces/" + keys['net'] + "/receiver/data", self.parent)
|
||||
elif (name == "pkg"):
|
||||
dataEngines['ext'].disconnectSource("pkg", self.parent)
|
||||
elif (name == "player"):
|
||||
dataEngines['ext'].disconnectSource("player", self.parent)
|
||||
elif (name == "ps"):
|
||||
dataEngines['ext'].disconnectSource("ps", self.parent)
|
||||
elif (name == "swap"):
|
||||
dataEngines['system'].disconnectSource("mem/swap/used", self.parent)
|
||||
dataEngines['system'].disconnectSource("mem/swap/free", self.parent)
|
||||
elif (name == "temp"):
|
||||
for item in keys['temp']:
|
||||
dataEngines['system'].disconnectSource(item, self.parent)
|
||||
elif (name == "time"):
|
||||
dataEngines['time'].disconnectSource("Local", self.parent)
|
||||
elif (name == "uptime"):
|
||||
dataEngines['system'].disconnectSource("system/uptime", self.parent)
|
@ -1,94 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import *
|
||||
from PyQt4 import uic
|
||||
|
||||
|
||||
|
||||
class DEConfigWindow(QWidget):
|
||||
def __init__(self, parent):
|
||||
"""settings window definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'deconfig.ui'), self)
|
||||
self.parent = parent
|
||||
|
||||
QObject.connect(self.ui.pushButton_customCommand, SIGNAL("clicked()"), self.addCustomCommand)
|
||||
QObject.connect(self.ui.pushButton_pkgCommand, SIGNAL("clicked()"), self.addPkgCommand)
|
||||
QObject.connect(self.ui.listWidget_customCommand, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_customCommand.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_pkgCommand, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_pkgCommand.openPersistentEditor)
|
||||
QObject.connect(self.ui.comboBox_pkgCommand, SIGNAL("currentIndexChanged(int)"), self.updatePkgNullValue)
|
||||
QObject.connect(self.ui.comboBox_pkgCommand, SIGNAL("editTextChanged(QString)"), self.updatePkgNullValue)
|
||||
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""delete events"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [keyPressEvent]")
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [keyPressEvent] : Run function with event '%s'" %(event.key()))
|
||||
if (event.key() == Qt.Key_Delete):
|
||||
if (self.ui.listWidget_customCommand.hasFocus() and
|
||||
(self.ui.listWidget_customCommand.currentRow() > -1)):
|
||||
self.ui.listWidget_customCommand.takeItem(self.ui.listWidget_customCommand.currentRow())
|
||||
elif (self.ui.listWidget_pkgCommand.hasFocus() and
|
||||
(self.ui.listWidget_pkgCommand.currentRow() > -1)):
|
||||
self.ui.listWidget_pkgCommand.takeItem(self.ui.listWidget_pkgCommand.currentRow())
|
||||
|
||||
|
||||
def addCustomCommand(self):
|
||||
"""function to add custom command"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addCustomCommand]")
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addCustomCommand] : Cmd '%s'" %(self.ui.lineEdit_customCommand.text()))
|
||||
self.ui.listWidget_customCommand.clearSelection()
|
||||
self.ui.listWidget_customCommand.addItem(self.ui.lineEdit_customCommand.text())
|
||||
|
||||
|
||||
def addPkgCommand(self):
|
||||
"""function to add package manager command"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addPkgCommand]")
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addPkgCommand] : Cmd '%s'" %(self.ui.comboBox_pkgCommand.currentText()))
|
||||
self.ui.listWidget_pkgCommand.clearSelection()
|
||||
self.ui.listWidget_pkgCommand.addItem(self.ui.comboBox_pkgCommand.currentText() +\
|
||||
QString(":") + QString.number(self.ui.spinBox_pkgCommandNum.value()))
|
||||
|
||||
|
||||
def updatePkgNullValue(self):
|
||||
"""function to set default values to PKGNULL spinbox"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [updatePkgNullValue]")
|
||||
if (self.ui.comboBox_pkgCommand.currentText().contains(QString("pacman -Qu"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("apt-show-versions -u -b"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("aptitude search '~U'"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("yum list updates"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(3)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("pkg_version -I -l '<'"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("urpmq --auto-select"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
@ -1,794 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.kdecore import *
|
||||
from PyKDE4.kdeui import *
|
||||
from PyKDE4.kio import *
|
||||
from PyKDE4 import plasmascript
|
||||
from PyKDE4.plasma import Plasma
|
||||
import commands, os
|
||||
|
||||
import advanced
|
||||
import appearance
|
||||
import configdef
|
||||
import dataengine
|
||||
import deconfig
|
||||
import ptmnotify
|
||||
import reinit
|
||||
import tooltip
|
||||
import tooltipconfig
|
||||
import widget
|
||||
|
||||
|
||||
|
||||
def getTemp(temp, unit):
|
||||
"""function to return temperature"""
|
||||
if (unit == "Celsius"):
|
||||
pass
|
||||
elif (unit == "Fahrenheit"):
|
||||
temp = str(round(((float(temp) * 9.0 / 5.0) + 32.0), 1))
|
||||
elif (unit == "Kelvin"):
|
||||
temp = str(round((float(temp) + 273.15), 1))
|
||||
return temp
|
||||
|
||||
|
||||
|
||||
class CustomPlasmaLabel(Plasma.Label):
|
||||
"""new Label with defined clicked() event"""
|
||||
def __init__(self, applet, name, enablePopup):
|
||||
"""class definition"""
|
||||
Plasma.Label.__init__(self, applet)
|
||||
self.enablePopup = enablePopup
|
||||
self.name = name
|
||||
self.notify = ptmnotify.PTMNotify(self)
|
||||
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
"""mouse click event"""
|
||||
if (self.enablePopup > 0):
|
||||
if (event.button() == Qt.LeftButton):
|
||||
self.notify.init(self.name)
|
||||
|
||||
|
||||
|
||||
class pyTextWidget(plasmascript.Applet):
|
||||
def __init__(self, parent, args=None):
|
||||
"""widget definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
plasmascript.Applet.__init__(self, parent)
|
||||
|
||||
|
||||
# initialization
|
||||
def init(self):
|
||||
"""function to initializate widget"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [init]")
|
||||
self.setupVar()
|
||||
|
||||
self.dataengine = dataengine.DataEngine(self)
|
||||
self.reinit = reinit.Reinit(self, self.ptm['defaults'])
|
||||
self.tooltipAgent = tooltip.Tooltip(self)
|
||||
|
||||
self.timer = QTimer()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.startPolling)
|
||||
|
||||
self.initTooltip()
|
||||
self.reInit()
|
||||
self.applet.setLayout(self.ptm['layout'])
|
||||
self.theme = Plasma.Svg(self)
|
||||
self.theme.setImagePath("widgets/background")
|
||||
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
|
||||
self.setHasConfigurationInterface(True)
|
||||
|
||||
# actions
|
||||
self.createActions()
|
||||
|
||||
|
||||
# context menu
|
||||
def createActions(self):
|
||||
"""function to create actions"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [createActions]")
|
||||
self.ptmActions = {}
|
||||
self.ptmActions['ksysguard'] = QAction(i18n("Run ksysguard"), self)
|
||||
QObject.connect(self.ptmActions['ksysguard'], SIGNAL("triggered(bool)"), self.runKsysguard)
|
||||
self.ptmActions['readme'] = QAction(i18n("Show README"), self)
|
||||
QObject.connect(self.ptmActions['readme'], SIGNAL("triggered(bool)"), self.showReadme)
|
||||
self.ptmActions['update'] = QAction(i18n("Update text"), self)
|
||||
QObject.connect(self.ptmActions['update'], SIGNAL("triggered(bool)"),
|
||||
self.ptm['dataengine']['ext'], SLOT("updateAllSources()"))
|
||||
QObject.connect(self.ptmActions['update'], SIGNAL("triggered(bool)"),
|
||||
self.ptm['dataengine']['system'], SLOT("updateAllSources()"))
|
||||
QObject.connect(self.ptmActions['update'], SIGNAL("triggered(bool)"),
|
||||
self.ptm['dataengine']['time'], SLOT("updateAllSources()"))
|
||||
QObject.connect(self.ptmActions['update'], SIGNAL("triggered(bool)"), self.updateNetdev)
|
||||
|
||||
|
||||
def contextualActions(self):
|
||||
"""function to create context menu"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [contextualActions]")
|
||||
contextMenu = []
|
||||
contextMenu.append(self.ptmActions['ksysguard'])
|
||||
contextMenu.append(self.ptmActions['readme'])
|
||||
contextMenu.append(self.ptmActions['update'])
|
||||
return contextMenu
|
||||
|
||||
|
||||
def runKsysguard(self, event):
|
||||
"""function to run ksysguard"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [runKsysguard]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [runKsysguard] : Run cmd " + "'ksysguard &'")
|
||||
os.system("ksysguard &")
|
||||
|
||||
|
||||
def showReadme(self):
|
||||
"""function to show readme file"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [showReadme]")
|
||||
kdehome = unicode(KGlobal.dirs().localkdedir())
|
||||
if (os.path.exists("/usr/share/pytextmonitor/")):
|
||||
dirPath = "/usr/share/pytextmonitor/"
|
||||
elif (os.path.exists(kdehome + "/share/pytextmonitor/")):
|
||||
dirPath = kdehome + "/share/pytextmonitor/"
|
||||
else:
|
||||
return
|
||||
locale = str(QLocale.system().name())
|
||||
if (os.path.exists(dirPath + locale + ".html")):
|
||||
filePath = dirPath + locale + ".html"
|
||||
else:
|
||||
locale = locale.split('_')[0]
|
||||
if (os.path.exists(dirPath + locale + ".html")):
|
||||
filePath = dirPath + locale + ".html"
|
||||
elif (os.path.exists(dirPath + "en.html")):
|
||||
filePath = dirPath + "en.html"
|
||||
else:
|
||||
return
|
||||
if self.debug: qDebug("[PTM] [main.py] [showReadme] : Run cmd " + "'kioclient exec " + str(filePath) + " &'")
|
||||
os.system("kioclient exec " + str(filePath) + " &")
|
||||
|
||||
|
||||
# internal functions
|
||||
def addDiskDevice(self, sourceName):
|
||||
if self.debug: qDebug("[PTM] [main.py] [addDiskDevice]")
|
||||
diskRegexp = QRegExp("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)")
|
||||
if (diskRegexp.indexIn(sourceName) > -1):
|
||||
if self.debug: qDebug("[PTM] [main.py] [addDiskDevice] : Add device '%s'" %(str(sourceName).split('/')[1]))
|
||||
self.ptm['defaults']['disk'].append('/'.join(str(sourceName).split('/')[0:2]))
|
||||
|
||||
|
||||
def createConfigurationInterface(self, parent):
|
||||
"""function to setup configuration window"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [createConfigurationInterface]")
|
||||
configpage = {}
|
||||
configpage['advanced'] = advanced.AdvancedWindow(self)
|
||||
configpage['appearance'] = appearance.AppearanceWindow(self)
|
||||
configpage['dataengine'] = deconfig.DEConfigWindow(self)
|
||||
configpage['tooltip'] = tooltipconfig.TooltipWindow(self)
|
||||
configpage['widget'] = widget.WidgetWindow(self)
|
||||
|
||||
self.confdef = configdef.ConfigDefinition(self, configpage, self.ptm['defaults'])
|
||||
self.confdef.createConfigurationInterface(parent)
|
||||
|
||||
|
||||
def initTooltip(self):
|
||||
"""function to create tooltip"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [initTooltip]")
|
||||
self.tooltip = Plasma.ToolTipContent()
|
||||
self.tooltip.setMainText("PyTextMonitor")
|
||||
self.tooltip.setSubText('')
|
||||
Plasma.ToolTipManager.self().registerWidget(self.applet)
|
||||
# graphical tooltip
|
||||
self.tooltipScene = QGraphicsScene()
|
||||
self.tooltipView = QGraphicsView(self.tooltipScene)
|
||||
self.tooltipView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.tooltipView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
# show tooltip
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
|
||||
|
||||
|
||||
def setupVar(self):
|
||||
"""function to setup variables"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [setupVar]")
|
||||
# variables
|
||||
self.ptm = {}
|
||||
# dataengines
|
||||
self.ptm['dataengine'] = {'ext':None, 'system':None, 'time':None}
|
||||
# defaults
|
||||
self.ptm['defaults'] = {}
|
||||
self.ptm['defaults']['confBool'] = {'bat':'batBool', 'cpu':'cpuBool',
|
||||
'cpuclock':'cpuclockBool', 'custom':'customBool', 'disk':'diskBool',
|
||||
'gpu':'gpuBool', 'gputemp':'gputempBool', 'hdd':'hddBool',
|
||||
'hddtemp':'hddtempBool', 'mem':'memBool', 'net':'netBool', 'pkg':'pkgBool',
|
||||
'player':'playerBool', 'ps':'psBool', 'swap':'swapBool', 'temp':'tempBool',
|
||||
'uptime':'uptimeBool', 'time':'timeBool'}
|
||||
self.ptm['defaults']['confColor'] = {'cpu':'cpu_color', 'cpuclock':'cpuclock_color',
|
||||
'down':'down_color', 'mem':'mem_color', 'swap':'swap_color', 'up':'up_color'}
|
||||
self.ptm['defaults']['confFormat'] = {'bat':'batFormat', 'cpu':'cpuFormat',
|
||||
'cpuclock':'cpuclockFormat', 'custom':'customFormat', 'disk':'diskFormat',
|
||||
'gpu':'gpuFormat', 'gputemp':'gputempFormat', 'hdd':'hddFormat',
|
||||
'hddtemp':'hddtempFormat', 'mem':'memFormat', 'net':'netFormat',
|
||||
'pkg':'pkgFormat', 'player':'playerFormat', 'ps':'psFormat', 'swap':'swapFormat',
|
||||
'temp':'tempFormat', 'time':'timeFormat', 'uptime':'uptimeFormat'}
|
||||
self.ptm['defaults']['bool'] = {'bat':0, 'cpu':2, 'cpuclock':0, 'custom':0,
|
||||
'disk':0, 'gpu':0, 'gputemp':0, 'hdd':0, 'hddtemp':0, 'mem':2, 'net':2,
|
||||
'pkg':0, 'player':0, 'ps':0, 'swap':2, 'temp':0, 'time':0, 'uptime':0}
|
||||
self.ptm['defaults']['format'] = {'bat':'[bat: $bat%$ac]', 'cpu':'[cpu: $cpu%]',
|
||||
'cpuclock':'[mhz: $cpucl]', 'custom':'[$custom]', 'disk':'[disk: $hddr0/$hddw0 KB/s]',
|
||||
'gpu':'[gpu: $gpu%]', 'gputemp':'[gpu temp: $gputemp°C]', 'hdd':'[hdd: $hdd0%]',
|
||||
'hddtemp':'[hdd temp: $hddtemp0°C]', 'mem':'[mem: $mem%]',
|
||||
'net':'[$netdev: $down/$upKB/s]', 'pkg':'[upgrade: $pkgcount0]',
|
||||
'player':'[$artist - $title]', 'ps':'[proc: $pscount]', 'swap':'[swap: $swap%]',
|
||||
'temp':'[temp: $temp0°C]', 'time':'[$time]', 'uptime':'[uptime: $uptime]'}
|
||||
self.ptm['defaults']['order'] = {'1':'cpu', '2':'temp', '3':'mem', '4':'swap', '5':'net',
|
||||
'6':'bat', '7':'cpuclock', '8':'uptime', '9':'gpu', 'a':'gputemp', 'b':'hdd',
|
||||
'c':'hddtemp', 'd':'player', 'e':'time', 'f':'custom', 'g':'ps', 'h':'pkg', 'i':'disk'}
|
||||
# disk devices for r/w speed
|
||||
self.ptm['defaults']['disk'] = []
|
||||
# labels
|
||||
self.ptm['labels'] = {}
|
||||
# names
|
||||
self.ptm['names'] = {}
|
||||
self.ptm['names']['disk'] = []
|
||||
self.ptm['names']['hdd'] = []
|
||||
self.ptm['names']['hddtemp'] = []
|
||||
self.ptm['names']['net'] = ""
|
||||
self.ptm['names']['temp'] = []
|
||||
# tooltips
|
||||
self.ptm['tooltip'] = {}
|
||||
self.ptm['tooltip']['bounds'] = {'cpu':100.0, 'cpuclock':4000.0, 'mem':16000.0,
|
||||
'swap':16000, 'down':10000.0, 'up':10000.0}
|
||||
self.ptm['tooltip']['values'] = {'cpu':[0.0, 0.0], 'cpuclock':[0, 0], 'mem':[0, 0],
|
||||
'swap':[0, 0], 'down':[0, 0], 'up':[0, 0]}
|
||||
# values
|
||||
self.ptm['values'] = {}
|
||||
self.ptm['values']['cpu'] = {-1:0.0}
|
||||
self.ptm['values']['cpuclock'] = {-1:0.0}
|
||||
numCores = int(commands.getoutput("grep -c '^processor' /proc/cpuinfo"))
|
||||
if self.debug: qDebug("[PTM] [main.py] [setupVar] : Number of cores '%s'" %(numCores))
|
||||
for i in range(numCores):
|
||||
self.ptm['values']['cpu'][i] = 0.0
|
||||
self.ptm['values']['cpuclock'][i] = 0.0
|
||||
self.ptm['values']['disk-r'] = {}
|
||||
self.ptm['values']['disk-w'] = {}
|
||||
self.ptm['values']['hdd'] = {}
|
||||
self.ptm['values']['hddfreemb'] = {}
|
||||
self.ptm['values']['hddmb'] = {}
|
||||
self.ptm['values']['hddtemp'] = {}
|
||||
self.ptm['values']['mem'] = {'app':0.0, 'used':0.0, 'free':1.0}
|
||||
self.ptm['values']['net'] = {"up":0.0, "down":0.0}
|
||||
self.ptm['values']['swap'] = {'used':0.0, 'free':1.0}
|
||||
self.ptm['values']['temp'] = {}
|
||||
# variables
|
||||
self.ptm['vars'] = {}
|
||||
self.ptm['vars']['adv'] = {}
|
||||
self.ptm['vars']['app'] = {}
|
||||
self.ptm['vars']['bools'] = {}
|
||||
self.ptm['vars']['formats'] = {}
|
||||
self.ptm['vars']['tooltip'] = {}
|
||||
|
||||
|
||||
def showConfigurationInterface(self):
|
||||
"""function to show configuration window"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [showConfigurationInterface]")
|
||||
plasmascript.Applet.showConfigurationInterface(self)
|
||||
|
||||
|
||||
def startPolling(self):
|
||||
"""function to update"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [startPolling]")
|
||||
try:
|
||||
self.updateLabel()
|
||||
self.tooltip.setSubText('')
|
||||
if self.debug: qDebug("[PTM] [main.py] [startPolling] : Update without errors")
|
||||
except Exception as strerror:
|
||||
self.tooltip.setSubText(str(strerror))
|
||||
if self.debug: qDebug("[PTM] [main.py] [startPolling] : There is some errors '%s'" %(str(strerror)))
|
||||
return
|
||||
|
||||
|
||||
def updateLabel(self):
|
||||
"""function to update label"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [updateLabel]")
|
||||
if (self.ptm['vars']['bools']['bat'] > 0):
|
||||
self.batText()
|
||||
if (self.ptm['vars']['bools']['cpu'] > 0):
|
||||
self.cpuText()
|
||||
if (self.ptm['vars']['bools']['cpuclock'] > 0):
|
||||
self.cpuclockText()
|
||||
if (self.ptm['vars']['bools']['disk'] > 0):
|
||||
self.diskText()
|
||||
if (self.ptm['vars']['bools']['hdd'] > 0):
|
||||
self.hddText()
|
||||
if (self.ptm['vars']['bools']['hddtemp'] > 0):
|
||||
self.hddtempText()
|
||||
if (self.ptm['vars']['bools']['mem'] > 0):
|
||||
self.memText()
|
||||
if (self.ptm['vars']['bools']['net'] > 0):
|
||||
self.netText()
|
||||
if (self.ptm['vars']['bools']['swap'] > 0):
|
||||
self.swapText()
|
||||
if (self.ptm['vars']['bools']['temp'] > 0):
|
||||
self.tempText()
|
||||
self.updateTooltip()
|
||||
|
||||
|
||||
def updateNetdev(self):
|
||||
"""function to update netdev"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [updateNetdev]")
|
||||
self.ptm['names']['net'] = self.setNetdev()
|
||||
|
||||
|
||||
def updateTooltip(self):
|
||||
"""function to update tooltip"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [updateTooltip]")
|
||||
self.tooltipView.resize(100.0*(len(self.ptm['vars']['tooltip']['required']) - self.ptm['vars']['tooltip']['required'].count('up')), 100.0)
|
||||
self.tooltipAgent.createGraphic(self.ptm['vars']['tooltip'], self.ptm['tooltip'], self.tooltipScene)
|
||||
self.tooltip.setImage(QPixmap.grabWidget(self.tooltipView))
|
||||
Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
|
||||
|
||||
|
||||
# update functions
|
||||
# update dataengines
|
||||
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
|
||||
def dataUpdated(self, sourceName, data):
|
||||
"""function to update label"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [dataUpdated]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [dataUpdated] : Run function with source '%s'" %(sourceName))
|
||||
if self.debug: qDebug("[PTM] [main.py] [dataUpdated] : Run function with data '%s'" %(data))
|
||||
updatedData = self.dataengine.dataUpdated(str(sourceName), data, self.ptm)
|
||||
if self.debug: qDebug("[PTM] [main.py] [dataUpdated] : Received data '%s'" %(updatedData))
|
||||
if (updatedData['value'] == None):
|
||||
return
|
||||
# update values where is needed
|
||||
if (updatedData['type'] != None):
|
||||
self.ptm['values'][updatedData['name']][updatedData['type']] = updatedData['value']
|
||||
elif (updatedData['name'] in ['custom', 'gpu', 'gputemp', 'pkg', 'player', 'ps', 'time', 'uptime']):
|
||||
text = self.textPrepare(updatedData['name'], updatedData['value'])
|
||||
self.setText(updatedData['name'], text)
|
||||
else:
|
||||
self.ptm['values'][updatedData['name']] = updatedData['value']
|
||||
# update tooltips
|
||||
if ((updatedData['name'] in ['cpu', 'cpuclock', 'mem', 'swap', 'net']) and (self.ptm['vars']['bools'][updatedData['name']] == 2)):
|
||||
if (updatedData['name'] == "net"):
|
||||
if (len(self.ptm['tooltip']['values'][updatedData['type']]) > self.ptm['vars']['tooltip']['num']):
|
||||
self.ptm['tooltip']['values'][updatedData['type']] = self.ptm['tooltip']['values'][updatedData['type']][1:]
|
||||
else:
|
||||
if (len(self.ptm['tooltip']['values'][updatedData['name']]) > self.ptm['vars']['tooltip']['num']):
|
||||
self.ptm['tooltip']['values'][updatedData['name']] = self.ptm['tooltip']['values'][updatedData['name']][1:]
|
||||
if ((updatedData['name'] in ['cpu', 'cpuclock']) and (updatedData['type'] == -1)):
|
||||
self.ptm['tooltip']['values'][updatedData['name']].append(updatedData['value'])
|
||||
elif ((updatedData['name'] == "mem") and (updatedData['type'] == "app")):
|
||||
self.ptm['tooltip']['values'][updatedData['name']].append(updatedData['value'])
|
||||
elif ((updatedData['name'] == "mem") and (updatedData['type'] == "used")):
|
||||
self.ptm['tooltip']['bounds']['mem'] = self.ptm['values']['mem']['free'] + self.ptm['values']['mem']['used']
|
||||
elif ((updatedData['name'] == "swap") and (updatedData['type'] == "used")):
|
||||
self.ptm['tooltip']['values'][updatedData['name']].append(updatedData['value'])
|
||||
self.ptm['tooltip']['bounds']['swap'] = self.ptm['values']['swap']['free'] + self.ptm['values']['swap']['used']
|
||||
elif (updatedData['name'] == "net"):
|
||||
self.ptm['tooltip']['values'][updatedData['type']].append(updatedData['value'])
|
||||
self.update()
|
||||
|
||||
|
||||
# update labels
|
||||
def batText(self):
|
||||
"""function to set battery text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [batText]")
|
||||
line = self.ptm['vars']['formats']['bat']
|
||||
if (line.split('$bat')[0] != line):
|
||||
try:
|
||||
with open (self.ptm['vars']['adv']['batDev'], 'r') as batFile:
|
||||
bat = batFile.readline()[:-1]
|
||||
except:
|
||||
bat = "off"
|
||||
bat = "%3s" % (bat)
|
||||
line = line.split('$bat')[0] + bat + line.split('$bat')[1]
|
||||
if (line.split('$ac')[0] != line):
|
||||
try:
|
||||
with open (self.ptm['vars']['adv']['acDev'], 'r') as batFile:
|
||||
bat = batFile.readline()[:-1]
|
||||
if (bat == "1"):
|
||||
bat = self.ptm['vars']['adv']['acOnline']
|
||||
else:
|
||||
bat = self.ptm['vars']['adv']['acOffline']
|
||||
except:
|
||||
bat = "N\\A"
|
||||
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("bat", text)
|
||||
|
||||
|
||||
def cpuText(self):
|
||||
"""function to set cpu text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [cpuText]")
|
||||
line = self.ptm['vars']['formats']['cpu']
|
||||
keys = self.ptm['values']['cpu'].keys()
|
||||
keys.sort()
|
||||
keys.reverse()
|
||||
for core in keys[:-1]:
|
||||
if (line.split('$cpu' + str(core))[0] != line):
|
||||
value = "%5.1f" % (self.ptm['values']['cpu'][core])
|
||||
line = line.split('$cpu' + str(core))[0] + value + line.split('$cpu' + str(core))[1]
|
||||
if (line.split('$cpu')[0] != line):
|
||||
value = "%5.1f" % (self.ptm['values']['cpu'][-1])
|
||||
line = line.split('$cpu')[0] + value + line.split('$cpu')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("cpu", text)
|
||||
|
||||
|
||||
def cpuclockText(self):
|
||||
"""function to set cpu clock text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [cpuclockText]")
|
||||
line = self.ptm['vars']['formats']['cpuclock']
|
||||
keys = self.ptm['values']['cpuclock'].keys()
|
||||
keys.sort()
|
||||
keys.reverse()
|
||||
for core in keys[:-1]:
|
||||
if (line.split('$cpucl' + str(core))[0] != line):
|
||||
value = "%4.0f" % (self.ptm['values']['cpuclock'][core])
|
||||
line = line.split('$cpucl' + str(core))[0] + value + line.split('$cpucl' + str(core))[1]
|
||||
if (line.split('$cpucl')[0] != line):
|
||||
value = "%4.0f" % (self.ptm['values']['cpuclock'][-1])
|
||||
line = line.split('$cpucl')[0] + value + line.split('$cpucl')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("cpuclock", text)
|
||||
|
||||
|
||||
def diskText(self):
|
||||
"""function to update hdd speed text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [diskText]")
|
||||
line = self.ptm['vars']['formats']['disk']
|
||||
devices = range(len(self.ptm['names']['disk']))
|
||||
devices.reverse()
|
||||
for i in devices:
|
||||
if (line.split('$hddr' + str(i))[0] != line):
|
||||
hdd = "%4i" % (self.ptm['values']['disk-r'][self.ptm['names']['disk'][i]])
|
||||
line = line.split('$hddr' + str(i))[0] + hdd + line.split('$hddr' + str(i))[1]
|
||||
if (line.split('$hddw' + str(i))[0] != line):
|
||||
hdd = "%4i" % (self.ptm['values']['disk-w'][self.ptm['names']['disk'][i]])
|
||||
line = line.split('$hddw' + str(i))[0] + hdd + line.split('$hddw' + str(i))[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("disk", text)
|
||||
|
||||
|
||||
def hddText(self):
|
||||
"""function to set hdd text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [hddText]")
|
||||
line = self.ptm['vars']['formats']['hdd']
|
||||
devices = range(len(self.ptm['names']['hdd']))
|
||||
devices.reverse()
|
||||
for i in devices:
|
||||
if (line.split('$hdd' + str(i))[0] != line):
|
||||
hdd = "%4.1f" % (self.ptm['values']['hdd'][self.ptm['names']['hdd'][i]])
|
||||
line = line.split('$hdd' + str(i))[0] + hdd + line.split('$hdd' + str(i))[1]
|
||||
if (line.split('$hddmb' + str(i))[0] != line):
|
||||
hdd = "%i" % (self.ptm['values']['hddmb'][self.ptm['names']['hdd'][i]] / 1024.0)
|
||||
line = line.split('$hddmb' + str(i))[0] + hdd + line.split('$hddmb' + str(i))[1]
|
||||
if (line.split('$hddgb' + str(i))[0] != line):
|
||||
hdd = "%5.1f" % (self.ptm['values']['hddmb'][self.ptm['names']['hdd'][i]] / (1024.0 * 1024.0))
|
||||
line = line.split('$hddgb' + str(i))[0] + hdd + line.split('$hddgb' + str(i))[1]
|
||||
if (line.split('$hddtotmb' + str(i))[0] != line):
|
||||
hdd = "%i" % ((self.ptm['values']['hddfreemb'][self.ptm['names']['hdd'][i]] +\
|
||||
self.ptm['values']['hddmb'][self.ptm['names']['hdd'][i]]) / 1024.0)
|
||||
line = line.split('$hddtotmb' + str(i))[0] + hdd + line.split('$hddtotmb' + str(i))[1]
|
||||
if (line.split('$hddtotgb' + str(i))[0] != line):
|
||||
hdd = "%5.1f" % ((self.ptm['values']['hddfreemb'][self.ptm['names']['hdd'][i]] +\
|
||||
self.ptm['values']['hddmb'][self.ptm['names']['hdd'][i]]) / (1024.0 * 1024.0))
|
||||
line = line.split('$hddtotgb' + str(i))[0] + hdd + line.split('$hddtotgb' + str(i))[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("hdd", text)
|
||||
|
||||
|
||||
def hddtempText(self):
|
||||
"""function to set hddtemp text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [hddtempText]")
|
||||
line = self.ptm['vars']['formats']['hddtemp']
|
||||
devices = range(len(self.ptm['names']['hddtemp']))
|
||||
devices.reverse()
|
||||
for i in devices:
|
||||
if (line.split('$hddtemp' + str(i))[0] != line):
|
||||
line = line.split('$hddtemp' + str(i))[0] +\
|
||||
getTemp(str(self.ptm['values']['hddtemp'][self.ptm['names']['hddtemp'][i]]), self.ptm['vars']['adv']['tempUnits']) +\
|
||||
line.split('$hddtemp' + str(i))[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("hddtemp", text)
|
||||
|
||||
|
||||
def memText(self):
|
||||
"""function to set mem text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [memText]")
|
||||
line = self.ptm['vars']['formats']['mem']
|
||||
if (line.split('$memtotgb')[0] != line):
|
||||
mem = "%4.1f" %((self.ptm['values']['mem']['free'] + self.ptm['values']['mem']['used']) / (1024.0 * 1024.0))
|
||||
line = line.split('$memtotgb')[0] + mem + line.split('$memtotgb')[1]
|
||||
if (line.split('$memtotmb')[0] != line):
|
||||
mem = "%i" %((self.ptm['values']['mem']['free'] + self.ptm['values']['mem']['used']) / 1024.0)
|
||||
line = line.split('$memtotmb')[0] + mem + line.split('$memtotmb')[1]
|
||||
if (line.split('$memgb')[0] != line):
|
||||
mem = "%4.1f" % (self.ptm['values']['mem']['app'] / (1024.0 * 1024.0))
|
||||
line = line.split('$memgb')[0] + mem + line.split('$memgb')[1]
|
||||
if (line.split('$memmb')[0] != line):
|
||||
mem = "%i" % (self.ptm['values']['mem']['app'] / 1024.0)
|
||||
line = line.split('$memmb')[0] + mem + line.split('$memmb')[1]
|
||||
if (line.split('$mem')[0] != line):
|
||||
try:
|
||||
mem = 100 * self.ptm['values']['mem']['app'] / (self.ptm['values']['mem']['free'] + self.ptm['values']['mem']['used'])
|
||||
mem = "%5.1f" % (round(mem, 1))
|
||||
except:
|
||||
mem = " N\\A"
|
||||
line = line.split('$mem')[0] + mem + line.split('$mem')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("mem", text)
|
||||
|
||||
|
||||
def netText(self):
|
||||
"""function to set network text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [netText]")
|
||||
line = self.ptm['vars']['formats']['net']
|
||||
if (line.split('$netdev')[0] != 0):
|
||||
line = line.split('$netdev')[0] + self.ptm['names']['net'] + line.split('$netdev')[1]
|
||||
if (line.split('$down')[0] != line):
|
||||
value = "%4.0f" %(self.ptm['values']['net']['down'])
|
||||
line = line.split('$down')[0] + value + line.split('$down')[1]
|
||||
if (line.split('$up')[0] != line):
|
||||
value = "%4.0f" %(self.ptm['values']['net']['up'])
|
||||
line = line.split('$up')[0] + value + line.split('$up')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("net", text)
|
||||
|
||||
|
||||
def swapText(self):
|
||||
"""function to set swap text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [swapText]")
|
||||
line = self.ptm['vars']['formats']['swap']
|
||||
if (line.split('$swaptotgb')[0] != line):
|
||||
mem = "%4.1f" % ((self.ptm['values']['swap']['free'] + self.ptm['values']['swap']['used']) / (1024.0 * 1024.0))
|
||||
line = line.split('$swaptotgb')[0] + mem + line.split('$swaptotgb')[1]
|
||||
if (line.split('$swaptotmb')[0] != line):
|
||||
mem = "%i" % ((self.ptm['values']['swap']['free'] + self.ptm['values']['swap']['used']) / 1024.0)
|
||||
line = line.split('$swaptotmb')[0] + mem + line.split('$swaptotmb')[1]
|
||||
if (line.split('$swapgb')[0] != line):
|
||||
mem = "%4.1f" % (self.ptm['values']['swap']['used'] / (1024.0 * 1024.0))
|
||||
line = line.split('$swapgb')[0] + mem + line.split('$swapgb')[1]
|
||||
if (line.split('$swapmb')[0] != line):
|
||||
mem = "%i" % (self.ptm['values']['swap']['used'] / 1024.0)
|
||||
line = line.split('$swapmb')[0] + mem + line.split('$swapmb')[1]
|
||||
if (line.split('$swap')[0] != line):
|
||||
try:
|
||||
mem = 100 * self.ptm['values']['swap']['used'] / (self.ptm['values']['swap']['free'] + self.ptm['values']['swap']['used'])
|
||||
mem = "%5.1f" % (round(mem, 1))
|
||||
except:
|
||||
mem = " N\\A"
|
||||
line = line.split('$swap')[0] + mem + line.split('$swap')[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("swap", text)
|
||||
|
||||
|
||||
def tempText(self):
|
||||
"""function to set temperature text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [tempText]")
|
||||
line = self.ptm['vars']['formats']['temp']
|
||||
devices = range(len(self.ptm['names']['temp']))
|
||||
devices.reverse()
|
||||
for i in devices:
|
||||
if (line.split('$temp' + str(i))[0] != line):
|
||||
line = line.split('$temp' + str(i))[0] +\
|
||||
getTemp(str(self.ptm['values']['temp'][self.ptm['names']['temp'][i]]), self.ptm['vars']['adv']['tempUnits']) +\
|
||||
line.split('$temp' + str(i))[1]
|
||||
text = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
self.setText("temp", text)
|
||||
|
||||
|
||||
# external functions
|
||||
def addLabel(self, name=None, text=None, add=True, enablePopup=2):
|
||||
"""function to add new label"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [addLabel]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [addLabel] : Run function with name '%s'" %(name))
|
||||
if self.debug: qDebug("[PTM] [main.py] [addLabel] : Run function with text '%s'" %(text))
|
||||
if self.debug: qDebug("[PTM] [main.py] [addLabel] : Run function with add '%s'" %(add))
|
||||
if self.debug: qDebug("[PTM] [main.py] [addLabel] : Run function with popup '%s'" %(enablePopup))
|
||||
if (add):
|
||||
self.ptm['labels'][name] = CustomPlasmaLabel(self.applet, name, enablePopup)
|
||||
self.ptm['layout'].addItem(self.ptm['labels'][name])
|
||||
self.setText(name, text)
|
||||
else:
|
||||
self.setText(name, '')
|
||||
self.ptm['layout'].removeItem(self.ptm['labels'][name])
|
||||
|
||||
|
||||
def applySettings(self, name=None, ptm=None):
|
||||
"""function to read settings"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [applySettings]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [applySettings] : Run function with name '%s'" %(name))
|
||||
if self.debug: qDebug("[PTM] [main.py] [applySettings] : Run function with settings '%s'" %(ptm))
|
||||
self.ptm[name] = ptm
|
||||
if (name == "names"):
|
||||
for item in ['hddtemp', 'temp']:
|
||||
for value in self.ptm['names'][item]:
|
||||
self.ptm['values'][item][value] = 0.0
|
||||
for value in self.ptm['names']['hdd']:
|
||||
self.ptm['values']['hdd'][value] = 0.0
|
||||
self.ptm['values']['hddfreemb'][value] = 0.0
|
||||
self.ptm['values']['hddmb'][value] = 0.0
|
||||
for value in self.ptm['names']['disk']:
|
||||
self.ptm['values']['disk-r'][value] = 0.0
|
||||
self.ptm['values']['disk-w'][value] = 0.0
|
||||
|
||||
|
||||
|
||||
def connectToEngine(self):
|
||||
"""function to connect to dataengines"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [connectToEngine]")
|
||||
self.ptm['dataengine']['ext'] = self.dataEngine("ext-sysmon")
|
||||
self.ptm['dataengine']['system'] = self.dataEngine("systemmonitor")
|
||||
self.ptm['dataengine']['time'] = self.dataEngine("time")
|
||||
QObject.connect(self.ptm['dataengine']['system'], SIGNAL("sourceAdded(QString)"), self.addDiskDevice)
|
||||
self.dataengine.connectToEngine(self.ptm['vars']['bools'], self.ptm['dataengine'],
|
||||
self.ptm['vars']['app']['interval'], self.ptm['names'])
|
||||
|
||||
|
||||
def createLayout(self, verticalLayout=0, leftStretch=2):
|
||||
"""function to create layout"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [createLayout]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [createLayout] : Run function with vertical layout '%s'" %(verticalLayout))
|
||||
if self.debug: qDebug("[PTM] [main.py] [createLayout] : Run function with left stretch '%s'" %(leftStretch))
|
||||
if (verticalLayout == 0):
|
||||
self.ptm['layout'] = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
|
||||
else:
|
||||
self.ptm['layout'] = QGraphicsLinearLayout(Qt.Vertical, self.applet)
|
||||
self.ptm['layout'].setContentsMargins(1, 1, 1, 1)
|
||||
if (leftStretch == 2):
|
||||
self.ptm['layout'].addStretch(1)
|
||||
|
||||
|
||||
def disconnectFromSource(self):
|
||||
"""function to disconnect from sources"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [disconnectFromSource]")
|
||||
for label in self.ptm['defaults']['format'].keys():
|
||||
if (self.ptm['vars']['bools'][label] > 0):
|
||||
self.addLabel(label, None, False)
|
||||
keys = {'cpu':self.ptm['values']['cpu'].keys(), 'cpuclock':self.ptm['values']['cpuclock'].keys(),
|
||||
'disk':self.ptm['values']['disk-r'].keys(), 'hdd':self.ptm['values']['hdd'].keys(),
|
||||
'net':self.ptm['names']['net'], 'temp':self.ptm['values']['temp'].keys()}
|
||||
self.dataengine.disconnectFromSource(self.ptm['dataengine'], keys, label)
|
||||
|
||||
|
||||
def reInit(self):
|
||||
"""function to run reinit"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [reInit]")
|
||||
self.reinit.reinit()
|
||||
# add stretch
|
||||
if (self.ptm['vars']['adv']['rightStretch'] == 2):
|
||||
self.ptm['layout'].addStretch(1)
|
||||
self.updateNetdev()
|
||||
self.resize(10, 10)
|
||||
|
||||
# create dataengines
|
||||
self.thread().wait(60000)
|
||||
self.connectToEngine()
|
||||
|
||||
self.timer.setInterval(self.ptm['vars']['app']['interval'])
|
||||
self.timer.start()
|
||||
self.startPolling()
|
||||
|
||||
|
||||
def setNetdev(self):
|
||||
"""function to set network device"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [setNetdev]")
|
||||
if (self.ptm['vars']['adv']['netdevBool'] > 0):
|
||||
return self.ptm['vars']['adv']['netdev']
|
||||
netdev = "lo"
|
||||
netdir = self.ptm['vars']['adv']['netDir']
|
||||
interfaces = QDir.entryList(QDir(netdir), QDir.Dirs | QDir.NoDotAndDotDot)
|
||||
for device in interfaces:
|
||||
if (str(device) != "lo"):
|
||||
try:
|
||||
with open(netdir + '/' + str(device) + '/operstate', 'r') as stateFile:
|
||||
if (stateFile.readline() == "up\n"):
|
||||
netdev = str(device)
|
||||
except:
|
||||
pass
|
||||
if self.debug: qDebug("[PTM] [main.py] [setNetdev] : Returns '%s'" %(netdev))
|
||||
return netdev
|
||||
|
||||
|
||||
def setText(self, name=None, text=None):
|
||||
"""function to set text to labels"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [setText]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [setText] : Run function with name '%s'" %(name))
|
||||
if self.debug: qDebug("[PTM] [main.py] [setText] : Run function with text '%s'" %(text))
|
||||
self.ptm['labels'][name].setText(text)
|
||||
|
||||
|
||||
def textPrepare(self, name=None, text=None):
|
||||
"""function to prepare text"""
|
||||
if self.debug: qDebug("[PTM] [main.py] [textPrepare]")
|
||||
if self.debug: qDebug("[PTM] [main.py] [textPrepare] : Run function with name '%s'" %(name))
|
||||
if self.debug: qDebug("[PTM] [main.py] [textPrepare] : Run function with text '%s'" %(text))
|
||||
line = self.ptm['vars']['formats'][name]
|
||||
if (name == "custom"):
|
||||
cmds = range(len(text.keys()))
|
||||
cmds.reverse()
|
||||
for i in cmds:
|
||||
if (line.split('$custom' + str(i))[0] != line):
|
||||
line = line.split('$custom' + str(i))[0] + \
|
||||
text['custom'+str(i)] + \
|
||||
line.split('$custom' + str(i))[1]
|
||||
elif (name == "gpu"):
|
||||
if (line.split('$gpu')[0] != line):
|
||||
line = line.split('$gpu')[0] + text + line.split('$gpu')[1]
|
||||
elif (name == "gputemp"):
|
||||
if (line.split('$gputemp')[0] != line):
|
||||
line = line.split('$gputemp')[0] + getTemp(text, self.ptm['vars']['adv']['tempUnits']) + line.split('$gputemp')[1]
|
||||
elif (name == "pkg"):
|
||||
pkgs = range(len(text.keys()))
|
||||
pkgs.reverse()
|
||||
for i in pkgs:
|
||||
if (line.split('$pkgcount' + str(i))[0] != line):
|
||||
line = line.split('$pkgcount' + str(i))[0] + \
|
||||
text['pkgcount'+str(i)] + \
|
||||
line.split('$pkgcount' + str(i))[1]
|
||||
elif (name == "player"):
|
||||
if (line.split('$album')[0] != line):
|
||||
line = line.split('$album')[0] + text['album'] + line.split('$album')[1]
|
||||
if (line.split('$artist')[0] != line):
|
||||
line = line.split('$artist')[0] + text['artist'] + line.split('$artist')[1]
|
||||
if (line.split('$progress')[0] != line):
|
||||
line = line.split('$progress')[0] + text['progress'] + line.split('$progress')[1]
|
||||
if (line.split('$time')[0] != line):
|
||||
line = line.split('$time')[0] + text['time'] + line.split('$time')[1]
|
||||
if (line.split('$title')[0] != line):
|
||||
line = line.split('$title')[0] + text['title'] + line.split('$title')[1]
|
||||
elif (name == "ps"):
|
||||
if (line.split('$pscount')[0] != line):
|
||||
line = line.split('$pscount')[0] + text['num'] + line.split('$pscount')[1]
|
||||
if (line.split('$pstotal')[0] != line):
|
||||
line = line.split('$pstotal')[0] + text['total'] + line.split('$pstotal')[1]
|
||||
if (line.split('$ps')[0] != line):
|
||||
line = line.split('$ps')[0] + text['list'] + line.split('$ps')[1]
|
||||
elif (name == "time"):
|
||||
if (line.split('$time')[0] != line):
|
||||
line = line.split('$time')[0] + text + line.split('$time')[1]
|
||||
elif (line.split('$isotime')[0] != line):
|
||||
line = line.split('$isotime')[0] + text + line.split('$isotime')[1]
|
||||
elif (line.split('$shorttime')[0] != line):
|
||||
line = line.split('$shorttime')[0] + text + line.split('$shorttime')[1]
|
||||
elif (line.split('$longtime')[0] != line):
|
||||
line = line.split('$longtime')[0] + text + line.split('$longtime')[1]
|
||||
elif (line.split('$custom')[0] != line):
|
||||
line = line.split('$custom')[0] + text + line.split('$custom')[1]
|
||||
elif (name == "uptime"):
|
||||
if (line.split('$uptime')[0] != line):
|
||||
line = line.split('$uptime')[0] + text + line.split('$uptime')[1]
|
||||
elif (line.split('$custom')[0] != line):
|
||||
line = line.split('$custom')[0] + text + line.split('$custom')[1]
|
||||
output = self.ptm['vars']['app']['format'][0] + line + self.ptm['vars']['app']['format'][1]
|
||||
if self.debug: qDebug("[PTM] [main.py] [textPrepare] : Returns '%s'" %(output))
|
||||
return output
|
||||
|
||||
|
||||
|
||||
def CreateApplet(parent):
|
||||
return pyTextWidget(parent)
|
@ -1,250 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyKDE4.kdecore import KComponentData
|
||||
from PyKDE4.kdeui import KNotification
|
||||
import commands
|
||||
|
||||
|
||||
|
||||
class PTMNotify:
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
|
||||
|
||||
def init(self, name=None):
|
||||
"""function to init notification"""
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [init]")
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [init] : Run function with name '%s'" %(name))
|
||||
content = self.initText(name)
|
||||
self.createNotify(content)
|
||||
|
||||
|
||||
def createNotify(self, content):
|
||||
"""function to create notification for label"""
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [createNotify]")
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [createNotify] : Run function with content '%s'" %(content))
|
||||
notification = KNotification(content[0])
|
||||
notification.setComponentData(KComponentData("plasma_applet_pytextmonitor"))
|
||||
notification.setTitle("PyTextMonitor info ::: " + content[0]);
|
||||
notification.setText(content[1]);
|
||||
notification.sendEvent();
|
||||
|
||||
|
||||
def createText(self, type):
|
||||
"""function to create text"""
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [createText]")
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [createText] : Run function with type '%s'" %(type))
|
||||
text = ""
|
||||
if (type == "battery"):
|
||||
try:
|
||||
text = "%s" %(commands.getoutput("acpi -abi"))
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "disk"):
|
||||
try:
|
||||
for line in commands.getoutput("df -h --output='source,target,used,size,pcent' --exclude-type=fuseblk --exclude-type=tmpfs --exclude-type=devtmpfs").split("\n")[1:]:
|
||||
text = text + "%s (to %s): %s of %s (%s)\n" % (line.split()[0], line.split()[1], line.split()[2], line.split()[3], line.split()[4])
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "graphical"):
|
||||
try:
|
||||
output = commands.getoutput("lspci -m | grep 'VGA\|3D'")
|
||||
if (output.lower().find('nvidia') > -1):
|
||||
gpudev = "nvidia"
|
||||
elif (output.lower().find('radeon') > -1):
|
||||
gpudev = "ati"
|
||||
for line in output.split("\n"):
|
||||
text = text + "%s %s\n" % (line.split('"')[0], line.split('"')[5])
|
||||
if (gpudev == 'nvidia'):
|
||||
output = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
|
||||
try:
|
||||
value = "%5.1f" % (round(float(output.split()[2]), 1))
|
||||
except:
|
||||
value = " N\A"
|
||||
elif (gpudev == 'ati'):
|
||||
output = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
|
||||
try:
|
||||
value = "%5.1f" % (round(float(output.split()[3]), 1))
|
||||
except:
|
||||
value = " N\A"
|
||||
else:
|
||||
value = " N\A"
|
||||
text = text + "Load: %s%%\n" % (value)
|
||||
if (gpudev == 'nvidia'):
|
||||
output = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
|
||||
try:
|
||||
value = "%5.1f" % (round(float(output.split()[2]), 1))
|
||||
except:
|
||||
value = " N\A"
|
||||
elif (gpudev == 'ati'):
|
||||
output = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
|
||||
try:
|
||||
value = "%5.1f" % (round(float(output.split()[3]), 1))
|
||||
except:
|
||||
value = " N\A"
|
||||
else:
|
||||
value = " N\A"
|
||||
text = text + "Temp: %s\xb0C\n" % (value)
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "memory"):
|
||||
try:
|
||||
output = commands.getoutput("free -m -o").split("\n")
|
||||
memUsage = int(output[1].split()[1]) - (int(output[1].split()[3]) + int(output[1].split()[5]) + int(output[1].split()[6]))
|
||||
text = text + "Memory: %i of %s (%i%%)\n" % (memUsage, output[1].split()[1], int(100*memUsage/int(output[1].split()[1])))
|
||||
text = text + "Swap: %s of %s (%i%%)\n" % (output[2].split()[2], output[2].split()[1], int(100*int(output[2].split()[2])/int(output[2].split()[1])))
|
||||
output = commands.getoutput("swapon --show").split("\n")
|
||||
text = text + "Swap Device: %s (%s)" % (output[1].split()[0], output[1].split()[1])
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "network"):
|
||||
try:
|
||||
output = commands.getoutput("ifconfig -a -s").split("\n")[1:]
|
||||
devices = [line.split()[0] for line in output]
|
||||
text = text + "Devices: %s\n" % (' '.join(devices))
|
||||
for dev in devices:
|
||||
output = commands.getoutput("ifconfig -a -s " + dev + " && sleep 0.2 && ifconfig -a -s " + dev).split("\n")
|
||||
download = int((int(output[3].split()[2]) - int(output[1].split()[2])) / (0.2 * 1024))
|
||||
upload = int((int(output[3].split()[6]) - int(output[1].split()[6])) / (0.2 * 1024))
|
||||
text = text + "%s: %i/%i KB/s" % (dev, download, upload)
|
||||
output = commands.getoutput("ifconfig " + dev + " | grep 'inet ' || echo ' inet Null'").split()[1]
|
||||
text = text + " (IP: %s)\n" % (output)
|
||||
output = commands.getoutput("wget -qO- http://ifconfig.me/ip")
|
||||
text = text + "External IP: %s" % (output)
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "player"):
|
||||
try:
|
||||
artist = "N\\A"
|
||||
album = "N\\A"
|
||||
title = "N\\A"
|
||||
if (len(commands.getoutput("pgrep amarok")) > 0):
|
||||
player = "amarok"
|
||||
elif (len(commands.getoutput("pgrep clementine")) > 0):
|
||||
player = "clementine"
|
||||
elif (len(commands.getoutput("pgrep mpd")) > 0):
|
||||
player = "mpd"
|
||||
elif (len(commands.getoutput("pgrep qmmp")) > 0):
|
||||
player = "qmmp"
|
||||
else:
|
||||
player = ""
|
||||
if (player == "amarok"):
|
||||
artist = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-")
|
||||
album = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep album: | cut -c8-")
|
||||
title = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep title: | cut -c8-")
|
||||
elif (player == "clementine"):
|
||||
artist = commands.getoutput("qdbus org.mpris.clementine /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-")
|
||||
album = commands.getoutput("qdbus org.mpris.clementine /Player GetMetadata 2> /dev/null | grep album: | cut -c8-")
|
||||
title = commands.getoutput("qdbus org.mpris.clementine /Player GetMetadata 2> /dev/null | grep title: | cut -c8-")
|
||||
elif (player == "mpd"):
|
||||
output = commands.getoutput("echo 'currentsong\nclose' | curl --connect-timeout 1 -fsm 3 telnet://localhost:6600 2> /dev/null")
|
||||
for line in output.split("\n"):
|
||||
if (line.split(": ")[0] == "Artist"):
|
||||
artist = line.split(": ")[1]
|
||||
elif (line.split(": ")[0] == "Album"):
|
||||
album = line.split(": ")[1]
|
||||
elif (line.split(": ")[0] == "Title"):
|
||||
title = line.split(": ")[1]
|
||||
elif (player == "qmmp"):
|
||||
artist = commands.getoutput("qmmp --nowplaying '%if(%p,%p,Unknown)' 2> /dev/null")
|
||||
album = commands.getoutput("qmmp --nowplaying '%if(%a,%a,Unknown)' 2> /dev/null")
|
||||
title = commands.getoutput("qmmp --nowplaying '%if(%t,%t,Unknown)' 2> /dev/null")
|
||||
text = text + "Artist: %s\nAlbum: %s\nTitle: %s" % (artist, album, title)
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "processor"):
|
||||
try:
|
||||
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
|
||||
text = text + "Model: %s\n" % (' '.join(output.split()[3:]))
|
||||
output = commands.getoutput("sar -u | tail -1")
|
||||
text = text + "CPU Usage: %5.1f%%\n" % (100-float(output.split()[-1]))
|
||||
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
|
||||
text = text + "CPU Freq: %i MHz\n" % (int(float(output.split()[-1])))
|
||||
output = commands.getoutput("sensors -u")
|
||||
text = text + "Temps:"
|
||||
for line in output.split("\n"):
|
||||
if (line.find("_input") > -1):
|
||||
text = text + " %3.0f\xb0C" % (round(float(line.split()[-1]), 0))
|
||||
except:
|
||||
text = "Something wrong"
|
||||
elif (type == "system"):
|
||||
try:
|
||||
text = text + "Kernel: %s\n" % (commands.getoutput("uname -rsm"))
|
||||
text = text + "Hostname: %s\n" % (commands.getoutput("uname -n"))
|
||||
text = text + "Whoami: %s\n" % (commands.getoutput("whoami"))
|
||||
text = text + "Uptime: %s\n" % (commands.getoutput("uptime"))
|
||||
except:
|
||||
text = "Something wrong"
|
||||
content = [type, text]
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [createText] : Returns '%s'" %(content))
|
||||
return content
|
||||
|
||||
|
||||
def initText(self, name):
|
||||
"""function to send text"""
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [initText]")
|
||||
if self.debug: qDebug("[PTM] [ptmnotify.py] [initText] : Run function with name '%s'" %(name))
|
||||
if (name == "bat"):
|
||||
return self.createText("battery")
|
||||
elif (name == "cpu"):
|
||||
return self.createText("processor")
|
||||
elif (name == "cpuclock"):
|
||||
return self.createText("processor")
|
||||
elif (name == "custom"):
|
||||
return self.createText("system")
|
||||
elif (name == "disk"):
|
||||
return self.createText("disk")
|
||||
elif (name == "gpu"):
|
||||
return self.createText("graphical")
|
||||
elif (name == "gputemp"):
|
||||
return self.createText("graphical")
|
||||
elif (name == "hdd"):
|
||||
return self.createText("disk")
|
||||
elif (name == "hddtemp"):
|
||||
return self.createText("disk")
|
||||
elif (name == "mem"):
|
||||
return self.createText("memory")
|
||||
elif (name == "net"):
|
||||
return self.createText("network")
|
||||
elif (name == "pkg"):
|
||||
return self.createText("system")
|
||||
elif (name == "player"):
|
||||
return self.createText("player")
|
||||
elif (name == "ps"):
|
||||
return self.createText("system")
|
||||
elif (name == "swap"):
|
||||
return self.createText("memory")
|
||||
elif (name == "temp"):
|
||||
return self.createText("processor")
|
||||
elif (name == "time"):
|
||||
return self.createText("system")
|
||||
elif (name == "uptime"):
|
||||
return self.createText("system")
|
||||
else:
|
||||
return None
|
@ -1,110 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
import config
|
||||
|
||||
|
||||
|
||||
class Reinit():
|
||||
def __init__(self, parent, defaults=None):
|
||||
"""class definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
self.parent = parent
|
||||
self.defaults = defaults
|
||||
self.labels = defaults['format'].keys()
|
||||
|
||||
|
||||
def reinit(self):
|
||||
"""function to reinitializate widget"""
|
||||
if self.debug: qDebug("[PTM] [reinit.py] [reinit]")
|
||||
settings = config.Config(self.parent)
|
||||
ptmVars = {}
|
||||
|
||||
ptmVars['adv'] = {}
|
||||
ptmVars['adv']['acDev'] = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
|
||||
ptmVars['adv']['acOnline'] = str(settings.get('ac_online', '(*)'))
|
||||
ptmVars['adv']['acOffline'] = str(settings.get('ac_offline', '( )'))
|
||||
ptmVars['adv']['batDev'] = str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
|
||||
ptmVars['adv']['customTime'] = str(settings.get('custom_time', '$hh:$mm'))
|
||||
ptmVars['adv']['customUptime'] = str(settings.get('custom_uptime', '$dd,$hh,$mm'))
|
||||
ptmVars['adv']['layout'] = settings.get('layout', 0).toInt()[0]
|
||||
ptmVars['adv']['leftStretch'] = settings.get('left_stretch', 2).toInt()[0]
|
||||
ptmVars['adv']['netdevBool'] = settings.get('netdevBool', 0).toInt()[0]
|
||||
ptmVars['adv']['netdev'] = str(settings.get('custom_netdev', 'lo'))
|
||||
ptmVars['adv']['netDir'] = str(settings.get('netdir', '/sys/class/net'))
|
||||
ptmVars['adv']['rightStretch'] = settings.get('right_stretch', 2).toInt()[0]
|
||||
ptmVars['adv']['tempUnits'] = str(settings.get('temp_units', 'Celsius'))
|
||||
ptmVars['adv']['popup'] = settings.get('popup', 2).toInt()[0]
|
||||
|
||||
ptmVars['app'] = {}
|
||||
ptmVars['app']['format'] = ["<pre><p align=\"center\"><span style=\" font-family:'" + str(settings.get('font_family', 'Terminus')) +\
|
||||
"'; font-style:" + str(settings.get('font_style', 'normal')) + "; font-size:" + str(settings.get('font_size', 12)) +\
|
||||
"pt; font-weight:" + str(settings.get('font_weight', 400)) + "; color:" + str(settings.get('font_color', '#000000')) +\
|
||||
";\">", "</span></p></pre>"]
|
||||
ptmVars['app']['interval'] = settings.get('interval', 2000).toInt()[0]
|
||||
ptmVars['app']['order'] = str(settings.get('label_order', '1345'))
|
||||
|
||||
ptmVars['tooltip'] = {}
|
||||
ptmVars['tooltip']['colors'] = {}
|
||||
ptmVars['tooltip']['colors']['cpu'] = str(settings.get('cpu_color', '#ff0000'))
|
||||
ptmVars['tooltip']['colors']['cpuclock'] = str(settings.get('cpuclock_color', '#00ff00'))
|
||||
ptmVars['tooltip']['colors']['mem'] = str(settings.get('mem_color', '#0000ff'))
|
||||
ptmVars['tooltip']['colors']['swap'] = str(settings.get('swap_color', '#ffff00'))
|
||||
ptmVars['tooltip']['colors']['down'] = str(settings.get('down_color', '#00ffff'))
|
||||
ptmVars['tooltip']['colors']['up'] = str(settings.get('up_color', '#ff00ff'))
|
||||
ptmVars['tooltip']['num'] = settings.get('tooltip_num', 100).toInt()[0]
|
||||
|
||||
ptmVars['bools'] = {}
|
||||
for label in self.labels:
|
||||
ptmVars['bools'][label] = settings.get(self.defaults['confBool'][label], self.defaults['bool'][label]).toInt()[0]
|
||||
|
||||
ptmNames = {}
|
||||
ptmNames['disk'] = str(settings.get('disk', 'disk/sda_(8:0)')).split('@@')
|
||||
ptmNames['hdd'] = str(settings.get('mount', '/')).split('@@')
|
||||
ptmNames['hddtemp'] = str(settings.get('hdd', '/dev/sda')).split('@@')
|
||||
ptmNames['temp'] = str(settings.get('temp_device', '')).split('@@')
|
||||
if self.debug: qDebug("[PTM] [reinit.py] [reinit] : Returns names '%s'" %(ptmNames))
|
||||
self.parent.applySettings('names', ptmNames)
|
||||
|
||||
self.parent.createLayout(ptmVars['adv']['layout'], ptmVars['adv']['leftStretch'])
|
||||
ptmVars['formats'] = {}
|
||||
ptmVars['tooltip']['required'] = []
|
||||
for order in ptmVars['app']['order']:
|
||||
label = self.defaults['order'][order]
|
||||
if (ptmVars['bools'][label] > 0):
|
||||
ptmVars['formats'][label] = str(settings.get(self.defaults['confFormat'][label], self.defaults['format'][label]))
|
||||
text = ptmVars['app']['format'][0] + ptmVars['formats'][label] + ptmVars['app']['format'][1]
|
||||
self.parent.addLabel(label, text, True, ptmVars['adv']['popup'])
|
||||
if ((label in ['cpu', 'cpuclock', 'mem', 'net', 'swap']) and (ptmVars['bools'][label] == 2)):
|
||||
if (label == 'net'):
|
||||
ptmVars['tooltip']['required'].append("down")
|
||||
ptmVars['tooltip']['required'].append("up")
|
||||
else:
|
||||
ptmVars['tooltip']['required'].append(label)
|
||||
if self.debug: qDebug("[PTM] [reinit.py] [reinit] : Returns vars '%s'" %(ptmVars))
|
||||
self.parent.applySettings('vars', ptmVars)
|
@ -1,73 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
|
||||
|
||||
class Tooltip():
|
||||
def __init__(self, parent):
|
||||
"""class definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
self.parent = parent
|
||||
|
||||
|
||||
def createGraphic(self, ptmVars, ptmTooltip, widget):
|
||||
"""function to create graph"""
|
||||
if self.debug: qDebug("[PTM] [tooltip.py] [createGraphic]")
|
||||
widget.clear()
|
||||
pen = QPen()
|
||||
bounds = ptmTooltip['bounds']
|
||||
colors = ptmVars['colors']
|
||||
types = ptmVars['required']
|
||||
values = ptmTooltip['values']
|
||||
maxOne = [100.0, 100.0]
|
||||
bounds['down'] = 1.0
|
||||
for value in values['down']:
|
||||
if (bounds['down'] < value):
|
||||
bounds['down'] = value
|
||||
for value in values['up']:
|
||||
if (bounds['down'] < value):
|
||||
bounds['down'] = value
|
||||
bounds['up'] = bounds['down']
|
||||
down = False
|
||||
for type in types:
|
||||
norm = [maxOne[0] / len(values[type]), maxOne[1] / (1.5 * bounds[type])]
|
||||
pen.setColor(QColor(colors[type]))
|
||||
if (down):
|
||||
shift = (types.index(type) - 1) * maxOne[0]
|
||||
else:
|
||||
shift = types.index(type) * maxOne[0]
|
||||
for i in range(len(values[type])-1):
|
||||
x1 = i * norm[0] + shift
|
||||
y1 = -values[type][i] * norm[1]
|
||||
x2 = (i + 1) * norm[0] + shift
|
||||
y2 = -values[type][i+1] * norm[1]
|
||||
widget.addLine(x1, y1, x2, y2, pen)
|
||||
if (type == 'down'):
|
||||
down = True
|
||||
|
@ -1,44 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
############################################################################
|
||||
# This file is part of pytextmonitor #
|
||||
# #
|
||||
# pytextmonitor is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# pytextmonitor is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with pytextmonitor. If not, see http://www.gnu.org/licenses/ #
|
||||
############################################################################
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyKDE4.plasma import *
|
||||
from PyQt4 import uic
|
||||
|
||||
|
||||
|
||||
class TooltipWindow(QWidget):
|
||||
def __init__(self, parent):
|
||||
"""settings window definition"""
|
||||
# debug
|
||||
environment = QProcessEnvironment.systemEnvironment()
|
||||
debugEnv = environment.value(QString("PTM_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes")):
|
||||
self.debug = True
|
||||
else:
|
||||
self.debug = False
|
||||
# main
|
||||
QWidget.__init__(self)
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'tooltipconfig.ui'), self)
|
||||
self.parent = parent
|
||||
self.kcolorcombos = {'cpu':self.ui.kcolorcombo_cpu,
|
||||
'cpuclock':self.ui.kcolorcombo_cpuclock, 'down':self.ui.kcolorcombo_down,
|
||||
'mem':self.ui.kcolorcombo_mem, 'swap':self.ui.kcolorcombo_swap,
|
||||
'up':self.ui.kcolorcombo_up}
|