cvsimport
[fvwm-themes.git] / scripts / FvwmApplet-APMMon
bloba58011e01cad27a7f67819418fdedba273e08631
1 WindowTitle {FvwmApplet-APMMon}
2 WindowSize 69 25
3 #Font           -*-lucida-bold-r-normal-*-11-*-*-*-*-*-*
4 Font            -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*
5 # Use the FvwmScript default colors.
6 #BackColor {rgb:a0/90/80}
7 #ForeColor {black}
8 #ShadowColor    {black}
9 #HilightColor   {rgb:a0/90/80}
11 Init
12 Begin
13   Set $APMQuery = {cat /proc/apm}
14   # No time remaining info
15   #Set $APMQuery = {echo 1.16 1.2 0x03 0x01 0x00 0x01 100% -1 \?}
16   # On battery
17   #Set $APMQuery = {echo 1.16 1.2 0x03 0x00 0x00 0x01 95% -1 min}
18   # On AC, Charging
19   #Set $APMQuery = {echo 1.16 1.2 0x03 0x01 0x03 0x09 92% -1 min}
21   Set $MainColorset=(GetScriptArgument 1)
22   Set $MainColorset=5
23   If $MainColorset <> {} Then
24   Begin
25     ChangeColorset 0 $MainColorset
26     ChangeColorset 1 $MainColorset
27     ChangeColorset 2 $MainColorset
28     ChangeColorset 3 $MainColorset
30     ChangeForeColor 1 {#ff0028}
31     ChangeForeColor 2 {black}
32     ChangeForeColor 3 {blue}
33   End
34 End
36 PeriodicTasks
37 Begin
38   If (RemainderOfDiv (GetTime) 5)==0 Then
39   Begin
40     # 1.16 1.2 0x03 0x01 0x00 0x01 100% 200 min
41     Set $save_ac_bat = $ac_bat
42     Set $save_charging = $charging
43     Set $changed = 0
44     Set $batcharge = (GetOutput $APMQuery 1 7)
45     Set $remaining = (GetOutput $APMQuery 1 8)
46     Set $ac_batt  =  (GetOutput $APMQuery 1 4)
47     Set $charging =  (GetOutput $APMQuery 1 5)
48   
49     If $remaining == {-1} Then
50       Set $remaining = {}
52     Set $remain_hrs = (Div $remaining 60)
53     Set $raw_remain_min = (RemainderOfDiv $remaining 60)
54     Set $cmd = {printf %02d }$raw_remain_min
55     Set $remain_min = (GetOutput $cmd 1 1)
56     
57     If $ac_batt <> $save_ac_batt Then
58       Set $changed = 1
59     If $save_charging <> $charging Then
60       Set $changed = 1
62     If $changed == 1 Then
63     Begin
64       Set $title = $batcharge
65       If $remaining <> {} Then
66         Set $title = $title{ }$remain_hrs{:}$remain_min
67     
68       If $save_title <> $title Then
69       Begin
70         Set $save_title= $title
71         ChangeTitle 1 $title
72         ChangeTitle 2 $title
73         ChangeTitle 3 $title
74       End
75     
76       If $ac_batt=={0x01} Then
77       Begin
78         # On AC power
79         If $charging=={0x03} Then
80         Begin
81           # On AC power, battery charging 
82           HideWidget 2
83           HideWidget 3
84           ShowWidget 1
85           #ChangeForeColor 1 {#ff0028} 
86         End
87         Else
88         Begin
89           # On AC power, battery charged
90           HideWidget 1
91           HideWidget 3
92           ShowWidget 2
93           #ChangeForeColor 2 {black}
94         End
95       End  
96       Else
97       Begin
98         # On Battery
99         HideWidget 1
100         HideWidget 2
101         ShowWidget 3
102         #ChangeForeColor 1 {#ff6400}
103         #ChangeForeColor 3 {blue}
104       End
105     End
106   End
108     
109 Widget 1
110 # AC/Charging
111 Property
112   Position 0 0
113   Size 69 25
114   Type ItemDraw
115   Flags NoReliefString
116   Title {APMMon}
117   ForeColor {#ff0028} 
118 Main
119   Case message of
120   SingleClic :
121   Begin    
122   End
124         
125 Widget 2
126 # AC/Charged
127 Property
128   Position 0 0
129   Size 69 25
130   Type ItemDraw
131   Flags NoReliefString
132   Title {APMMon}
133   ForeColor {black}
134 Main
135   Case message of
136   SingleClic :
137   Begin 
138   End
140   
141 Widget 3
142 # On Battery
143 Property
144   Position 0 0
145   Size 69 25
146   Type ItemDraw
147   Flags NoReliefString
148   Title {APMMon}
149   ForeColor {blue}
150 Main    
151   Case message of
152   SingleClic :
153   Begin 
154   End