Debian Codegraph @

fvwm/components/scripts/FvwmScript-CpuFreq-small

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