| 1 |
# |
| 2 |
# LiNiO <[email protected]> - 2005.01.15 |
| 3 |
# 2005.08.12 - jeśli wartość się nie zmieniła, nie wyświetla jej ponownie |
| 4 |
# - usunięcie efektu "migotania" |
| 5 |
# |
| 6 |
# 2006.05.15 - fall back to /proc/cpuinfo which is present on every linux |
| 7 |
# system in case cpufreq is not available |
| 8 |
# Michael Stilkerich <[email protected]> |
| 9 |
# |
| 10 |
# o 2015.10.02 - Use same colorset than the AcpiBatt applet |
| 11 |
# Dominique Michel <[email protected]> |
| 12 |
|
| 13 |
WindowTitle {FvwmScript-CpuFreq} |
| 14 |
WindowSize 72 24 |
| 15 |
Font "xft:Tahoma:pixelsize=12:Bold" |
| 16 |
Colorset 12 |
| 17 |
|
| 18 |
Init |
| 19 |
Begin |
| 20 |
Set $hascpufreq=(GetOutput {if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ]; then echo 1; else echo 0; fi} 1 -1) |
| 21 |
If $hascpufreq == {1} Then |
| 22 |
Set $freqcmd={cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq} |
| 23 |
Else |
| 24 |
Set $freqcmd={cat /proc/cpuinfo | grep "cpu MHz" | sed -e 's/[^0-9]//g'} |
| 25 |
|
| 26 |
Set $freqa = (GetOutput $freqcmd 1 -1) |
| 27 |
Set $freqa_prev = $freqa |
| 28 |
Set $freq = (Div $freqa 1000) |
| 29 |
|
| 30 |
If $freq < 1000 Then |
| 31 |
Set $freq=$freq MHz |
| 32 |
Else |
| 33 |
Begin |
| 34 |
Set $freqg = (Div $freq 1000) |
| 35 |
Set $freqm = (StrCopy $freq 2 3) |
| 36 |
Set $freq=$freqg . $freqm GHz |
| 37 |
End |
| 38 |
|
| 39 |
ChangeTitle 1 $freq |
| 40 |
End |
| 41 |
|
| 42 |
PeriodicTasks |
| 43 |
Begin |
| 44 |
If (RemainderOfDiv (GetTime) 5)==0 Then |
| 45 |
Begin |
| 46 |
Set $freqa = (GetOutput $freqcmd 1 -1) |
| 47 |
If $freqa==$freqa_prev Then |
| 48 |
Begin |
| 49 |
# do nothing |
| 50 |
End |
| 51 |
Else |
| 52 |
Begin |
| 53 |
# We should only get here with cpufreq available |
| 54 |
Set $freqa_prev = $freqa |
| 55 |
Set $freqmin = (GetOutput {cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq} 1 1) |
| 56 |
Set $freqmax = (GetOutput {cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq} 1 1) |
| 57 |
Set $freqminneg = (Mult $freqmin -1) |
| 58 |
Set $freqp1 = (Add $freqa $freqminneg ) |
| 59 |
Set $freqp2 = (Add $freqmax $freqminneg ) |
| 60 |
Set $freqp2 = (Div $freqp2 100 ) |
| 61 |
|
| 62 |
Set $freqp = (Div $freqp1 $freqp2) |
| 63 |
|
| 64 |
Set $freq = (Div $freqa 1000) |
| 65 |
|
| 66 |
If $freq < 1000 Then |
| 67 |
Set $freq=$freq MHz |
| 68 |
Else |
| 69 |
Begin |
| 70 |
Set $freqg = (Div $freq 1000) |
| 71 |
Set $freqm = (StrCopy $freq 2 3) |
| 72 |
Set $freq=$freqg . $freqm GHz |
| 73 |
End |
| 74 |
|
| 75 |
If $freqp>74 Then |
| 76 |
ChangeColorset 1 17 |
| 77 |
Else |
| 78 |
Begin |
| 79 |
If $freqp>43 Then |
| 80 |
ChangeColorset 1 16 |
| 81 |
Else |
| 82 |
Begin |
| 83 |
If $freqp>22 Then |
| 84 |
ChangeColorset 1 15 |
| 85 |
Else |
| 86 |
Begin |
| 87 |
If $freqp>11 Then |
| 88 |
ChangeColorset 1 14 |
| 89 |
Else |
| 90 |
Begin |
| 91 |
If $freqp>1 Then |
| 92 |
ChangeColorset 1 13 |
| 93 |
Else |
| 94 |
ChangeColorset 1 12 |
| 95 |
End |
| 96 |
End |
| 97 |
End |
| 98 |
End |
| 99 |
ChangeTitle 1 $freq |
| 100 |
End |
| 101 |
End |
| 102 |
End |
| 103 |
|
| 104 |
Widget 1 |
| 105 |
Property |
| 106 |
Position 0 -2 |
| 107 |
Size 72 24 |
| 108 |
Type ItemDraw |
| 109 |
Flags NoReliefString |
| 110 |
Title {} |
| 111 |
Colorset 12 |
| 112 |
Main |
| 113 |
Case message of |
| 114 |
SingleClic : |
| 115 |
Begin |
| 116 |
End |
| 117 |
End |
| 118 |
|