File: FvwmScript-AcpiBatt

package info (click to toggle)
fvwm-crystal 3.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,748 kB
  • ctags: 793
  • sloc: sh: 2,815; cs: 880; python: 875; makefile: 212
file content (93 lines) | stat: -rw-r--r-- 2,126 bytes parent folder | download
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
#
# 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"

WindowTitle {FvwmScript-AcpiBatt}
WindowSize 48 24
Font "xft:Tahoma:pixelsize=12:Bold"
Colorset 1

Init
Begin
  Set $last = (GetOutput {cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT*/energy_full} 1 -1)
  Set $remaining = (GetOutput {cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT*/energy_now} 1 -1)
  Set $acstate = (GetOutput {cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT*/status} 1 -1)
  Set $batt = (Div $last 100)
  Set $batt = (Div $remaining $batt)
  Set $batt = $batt %
  Set $batt_prev = -1

  If $acstate==Discharging Then
    Set $batt = * $batt 
  ChangeTitle 1 $batt
End

PeriodicTasks
Begin 
 If (RemainderOfDiv (GetTime) 30)==0 Then
 Begin
   If $batt==$batt_prev Then
   Begin
     # do nothing
   End
   Else
   Begin

    Set $last = (GetOutput {cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT*/energy_full} 1 -1)
    Set $remaining = (GetOutput {cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT*/energy_now} 1 -1)
    Set $batt = (Div $last 100)
    Set $batt = (Div $remaining $batt)
    Set $batt_prev = $batt
    Set $acstate = (GetOutput {cat /sys/bus/acpi/drivers/battery/*/power_supply/BAT*/status} 1 -1)

    If $batt>99 Then
      ChangeColorset 1 1
    Else
      Begin
      If $batt>74 Then
        ChangeForeColor 1 {#FFFF00}
      Else
        Begin
        If $batt>49 Then
          ChangeForeColor 1 {#FFBB00}
        Else
          Begin
          If $batt>24 Then
            ChangeForeColor 1 {#FF8800}
          Else
  	  Begin
            If $batt>12 Then
              ChangeForeColor 1 {#FF4400}
            Else
              ChangeForeColor 1 {#FF0000}
            End
          End
        End
      End
    
      Set $batt = $batt %

      If $acstate==Discharging Then
        Set $batt = * $batt 

      ChangeTitle 1 $batt
    End

  End
End

Widget 1
Property
Position 0 -2
Size 48 24
Type ItemDraw
Flags NoReliefString
Title {}
Colorset 1
Main
Case message of
 SingleClic :
 Begin
 End
End