Debian Codegraph @

fvwm/components/scripts/FvwmScript-AcpiBatt

raw
1 #
2 # LiNiO <[email protected]> - 2005.01.15
3 # 2005.08.12 - jeśli wartość się nie zmieniła, nie wyświetla jej ponownie - usunięcie efektu "migotania"
4 # 2015.09.23 - Jorge Sampayo ([email protected]), change the function to
5 # the new way to get the acpi battery status:
6 # http://askubuntu.com/questions/69556/how-to-check-battery-status-using-terminal
7 #
8 # o 2015.10.02 - Use new colorsets instead of statically changing the colors
9 # Dominique Michel <[email protected]>
10
11
12 WindowTitle {FvwmScript-AcpiBatt}
13 WindowSize 48 24
14 Font "xft:Tahoma:pixelsize=12:Bold"
15 Colorset 12
16
17 Init
18 Begin
19 Set $acstate = (GetOutput {cat /sys/class/power_supply/BAT0/status} 1 -1)
20 Set $batt = (GetOutput {cat /sys/class/power_supply/BAT0/capacity} 1 -1)
21
22 Set $batt_prev = -1
23 Set $batt = $batt %
24
25 If $acstate==Discharging Then
26 Set $batt = * $batt
27 ChangeTitle 1 $batt
28 End
29
30 PeriodicTasks
31 Begin
32 If (RemainderOfDiv (GetTime) 30)==0 Then
33 Begin
34 If $batt==$batt_prev Then
35 Begin
36 # do nothing
37 End
38 Else
39 Begin
40 Set $batt = (GetOutput {cat /sys/class/power_supply/BAT0/capacity} 1 -1)
41 Set $acstate = (GetOutput {cat /sys/class/power_supply/BAT0/status} 1 -1)
42 Set $batt_prev = $batt
43
44 If $batt>99 Then
45 # amiga.cs: black
46 ChangeColorset 1 12
47 Else
48 Begin
49 If $batt>74 Then
50 # dark blue #0000ff
51 ChangeColorset 1 13
52 Else
53 Begin
54 If $batt>49 Then
55 # green #00ff00
56 ChangeColorset 1 14
57 Else
58 Begin
59 If $batt>24 Then
60 # yellow #ffff00
61 ChangeColorset 1 15
62 Else
63 Begin
64 If $batt>12 Then
65 # orange #ff4400
66 ChangeColorset 1 16
67 Else
68 # red #ff0000
69 ChangeColorset 1 17
70 End
71 End
72 End
73 End
74
75 Set $batt = $batt %
76
77 If $acstate==Discharging Then
78 Set $batt = * $batt
79
80 ChangeTitle 1 $batt
81 End
82 End
83 End
84
85 Widget 1
86 Property
87 Position 0 -2
88 Size 48 24
89 Type ItemDraw
90 Flags NoReliefString
91 Title {}
92 Colorset 1
93 Main
94 Case message of
95 SingleClic :
96 Begin
97 End
98 End
99