-
Notifications
You must be signed in to change notification settings - Fork 0
/
vol.py
executable file
·69 lines (58 loc) · 1.32 KB
/
vol.py
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
#!/usr/bin/env python3
import subprocess
raw = subprocess.run(['/usr/share/i3blocks/volume'], stdout=subprocess.PIPE)
vol_raw = raw.stdout.decode("utf-8")
# Need to reMove the last two charaCters as raw.stdout.decode("utf-8")
# returns a string with a newline: "39%\n"
vol = vol_raw[:-2]
volume = int(vol)
colour="#009900" # Green.
if volume > 99:
VOLUME_ICON=""
colour="#FF0000" # Red.
elif volume > 90:
VOLUME_ICON="9"
elif volume > 80:
VOLUME_ICON="8"
elif volume > 70:
VOLUME_ICON="7"
elif volume > 60:
VOLUME_ICON="6"
elif volume > 50:
VOLUME_ICON="5"
elif volume > 40:
VOLUME_ICON="4"
elif volume > 30:
VOLUME_ICON="3"
elif volume > 20:
VOLUME_ICON="2"
elif volume > 10:
VOLUME_ICON="1"
else:
VOLUME_ICON="-"
full_text=VOLUME_ICON
short_text=full_text
print(short_text)
print(full_text)
print(colour)
# echo "${VOLUME_ICON}"
# This was the 20 echo $VOLUME
# ifvolume > 90:
# VOLUME_ICON="█"
# elif volume > 80:
# VOLUME_ICON="▇"
# elif volume > 70:
# VOLUME_ICON="▆"
# elif volume > 60:
# VOLUME_ICON="▅"
# elif volume > 50:
# VOLUME_ICON="▄"
# elif volume > 40:
# VOLUME_ICON="▃"
# elif volume > 30:
# VOLUME_ICON="▂"
# elif volume > 20:
# VOLUME_ICON="▁"
# elif [[ "${VOLUME}" -le 10:
# VOLUME_ICON="-"
# fi