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