init
This commit is contained in:
commit
cbcf6dacae
3 changed files with 131 additions and 0 deletions
62
battery.py
Executable file
62
battery.py
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
BATTERY_ZERO_DATA = subprocess.check_output(["upower", "-i", "/org/freedesktop/UPower/devices/battery_BAT0"]).decode('utf-8')
|
||||
BATTERY_ONE_DATA = subprocess.check_output(["upower", "-i", "/org/freedesktop/UPower/devices/battery_BAT1"]).decode('utf-8')
|
||||
|
||||
BATTERY_STATE_MAP = {
|
||||
'charging': "",
|
||||
'fully-charged': "",
|
||||
'empty': "",
|
||||
}
|
||||
|
||||
bat_0 = {}
|
||||
bat_1 = {}
|
||||
|
||||
|
||||
def get_upower_value(data, key):
|
||||
return data.split(key)[-1].split('\n')[0].strip()
|
||||
|
||||
|
||||
def parse_battery_data(data, obj):
|
||||
obj['state'] = get_upower_value(data, 'state:')
|
||||
obj['percentage'] = get_upower_value(data, 'percentage:')
|
||||
|
||||
if obj['state'] not in BATTERY_STATE_MAP:
|
||||
bat_level = int(obj['percentage'].strip('%'))
|
||||
|
||||
if bat_level < 10:
|
||||
obj['icon'] = ""
|
||||
elif 20 > bat_level >= 10:
|
||||
obj['icon'] = ""
|
||||
elif 30 > bat_level >= 20:
|
||||
obj['icon'] = ""
|
||||
elif 40 > bat_level >= 30:
|
||||
obj['icon'] = ""
|
||||
elif 50 > bat_level >= 40:
|
||||
obj['icon'] = ""
|
||||
elif 60 > bat_level >= 50:
|
||||
obj['icon'] = ""
|
||||
elif 70 > bat_level >= 60:
|
||||
obj['icon'] = ""
|
||||
elif 80 > bat_level >= 70:
|
||||
obj['icon'] = ""
|
||||
elif 90 > bat_level >= 80:
|
||||
obj['icon'] = ""
|
||||
elif 100 > bat_level >= 90:
|
||||
obj['icon'] = ""
|
||||
else:
|
||||
obj['icon'] = ""
|
||||
|
||||
else:
|
||||
obj['icon'] = BATTERY_STATE_MAP.get(obj['state'], "")
|
||||
|
||||
|
||||
parse_battery_data(BATTERY_ZERO_DATA, bat_0)
|
||||
parse_battery_data(BATTERY_ONE_DATA, bat_1)
|
||||
|
||||
print(f"{bat_0['icon']} {bat_0['percentage']} {bat_1['icon']} {bat_1['percentage']}")
|
||||
|
||||
|
54
config
Normal file
54
config
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
# Guess the weather hourly
|
||||
#[weather]
|
||||
#command=curl -Ss 'https://wttr.in?0&T&Q' | cut -c 16- | head -2 | xargs echo
|
||||
#interval=3600
|
||||
#color=#A4C2F4
|
||||
|
||||
[cpu]
|
||||
command=top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}'
|
||||
interval=3
|
||||
label=
|
||||
color=#A7C080
|
||||
|
||||
[temp]
|
||||
command=sensors | grep Core | head -n 1 | cut -d ' ' -f 10 | cut -d '+' -f 2
|
||||
interval=10
|
||||
color=#E67E80
|
||||
|
||||
[pkgs]
|
||||
command=apt-get -q -y --ignore-hold --allow-change-held-packages --allow-unauthenticated -s dist-upgrade | /bin/grep ^Inst | wc -l
|
||||
interval=43200
|
||||
label=
|
||||
color=#A7C080
|
||||
|
||||
[server_pkgs]
|
||||
command=ssh domdit.com checkupdates | wc -l
|
||||
interval=43200
|
||||
label=
|
||||
color=#E67E80
|
||||
|
||||
[brightness]
|
||||
command=brightnessctl | sed -n 2p | cut -d '(' -f 2 | cut -d ')' -f 1
|
||||
label=
|
||||
interval=once
|
||||
signal=20
|
||||
|
||||
[volume]
|
||||
command=/home/dominic/.config/i3blocks/volume.sh
|
||||
label=
|
||||
interval=once
|
||||
signal=10
|
||||
color=#D699B6
|
||||
|
||||
[battery]
|
||||
command=/home/dominic/.config/i3blocks/battery.py
|
||||
interval=5
|
||||
color=#7FBBB3
|
||||
|
||||
[time]
|
||||
command=date +"%D %I:%M"
|
||||
interval=5
|
||||
color=#D3C6AA
|
||||
|
||||
|
15
volume.sh
Executable file
15
volume.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
mute=$(pulsemixer --get-mute)
|
||||
sink_id=$(pulsemixer --list-sinks | grep "Name: Built-in Audio Analog Ster
|
||||
eo" | cut -f 3 | cut -d ' ' -f 3 | sed 's/,//g'
|
||||
)
|
||||
|
||||
if [[ $mute -eq 1 ]]
|
||||
then
|
||||
echo "Mute"
|
||||
else
|
||||
vol=$(pulsemixer --get-volume --id ${sink_id} | cut -d ' ' -f1)
|
||||
per=%
|
||||
echo "${vol}${per}"
|
||||
fi
|
Loading…
Reference in a new issue