add sxhkd mode support to statusbar.py
This commit is contained in:
parent
9053b258c0
commit
921c36dc0f
|
@ -1,3 +1,3 @@
|
||||||
# start the wm
|
# start the wm
|
||||||
sxhkd &
|
mode sxhkdrc
|
||||||
bspwm
|
bspwm
|
||||||
|
|
|
@ -50,5 +50,6 @@ super + {_,shift + } {1-9,0}
|
||||||
super + {t,f,s}
|
super + {t,f,s}
|
||||||
bspc node -t {tiled,floating,fullscreen}
|
bspc node -t {tiled,floating,fullscreen}
|
||||||
|
|
||||||
|
# x230t specific -- activate the tablet menu
|
||||||
XF86RotateWindows
|
XF86RotateWindows
|
||||||
tabletmenu
|
tabletmenu
|
||||||
|
|
|
@ -38,6 +38,22 @@ def generate_desktop_string(monitor_array):
|
||||||
|
|
||||||
return ' '.join(output)
|
return ' '.join(output)
|
||||||
|
|
||||||
|
def filemodfactory(filename: str, modname: str):
|
||||||
|
def filemod(queue, _):
|
||||||
|
orig = 0
|
||||||
|
while True:
|
||||||
|
new = os.path.getmtime(filename)
|
||||||
|
if(new > orig):
|
||||||
|
with open(filename, 'r') as f:
|
||||||
|
queue.put({
|
||||||
|
"module": modname,
|
||||||
|
"data": f.read().rstrip()
|
||||||
|
})
|
||||||
|
orig = new
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
return filemod
|
||||||
|
|
||||||
def bspwm(queue, monitor):
|
def bspwm(queue, monitor):
|
||||||
client = socket.socket(
|
client = socket.socket(
|
||||||
socket.AF_UNIX,
|
socket.AF_UNIX,
|
||||||
|
@ -90,11 +106,12 @@ def filecheckerfactory(filename: str, modname: str, timeout=60):
|
||||||
|
|
||||||
battery = filecheckerfactory("/sys/class/power_supply/BAT0/capacity", "bat")
|
battery = filecheckerfactory("/sys/class/power_supply/BAT0/capacity", "bat")
|
||||||
batterystatus = filecheckerfactory("/sys/class/power_supply/BAT0/status", "batstat")
|
batterystatus = filecheckerfactory("/sys/class/power_supply/BAT0/status", "batstat")
|
||||||
|
sxhkdmode = filemodfactory("/home/usr/.cache/sxhkd_mode", "sxhkdmode")
|
||||||
|
|
||||||
def render(modules) -> str:
|
def render(modules) -> str:
|
||||||
columns, _ = os.get_terminal_size(0)
|
columns, _ = os.get_terminal_size(0)
|
||||||
|
|
||||||
left = "{} | {}".format(modules["clock"], modules["bspwm"])
|
left = "{} | {}({})".format(modules["clock"], modules["bspwm"], modules["sxhkdmode"])
|
||||||
right = "{}({})".format(modules["bat"], modules["batstat"])
|
right = "{}({})".format(modules["bat"], modules["batstat"])
|
||||||
padding = " " * (columns - len(left) - len(right) - 0)
|
padding = " " * (columns - len(left) - len(right) - 0)
|
||||||
|
|
||||||
|
@ -146,7 +163,7 @@ def main():
|
||||||
))
|
))
|
||||||
return
|
return
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
modules = [bspwm, clock, battery, batterystatus]
|
modules = [bspwm, clock, battery, batterystatus, sxhkdmode]
|
||||||
[Process(target=module, args=(queue, argv[1])).start() for module in modules]
|
[Process(target=module, args=(queue, argv[1])).start() for module in modules]
|
||||||
|
|
||||||
module_outputs = defaultdict(lambda: "")
|
module_outputs = defaultdict(lambda: "")
|
||||||
|
|
|
@ -4,6 +4,7 @@ if [ -n "$1" ]; then
|
||||||
pkill sxhkd
|
pkill sxhkd
|
||||||
sxhkd -c ~/.config/sxhkd/$1 & disown
|
sxhkd -c ~/.config/sxhkd/$1 & disown
|
||||||
[ -f "~/.config/sxhkd/$1.sh" ] && ~/.config/sxhkd/$1.sh
|
[ -f "~/.config/sxhkd/$1.sh" ] && ~/.config/sxhkd/$1.sh
|
||||||
|
echo "$1" > ~/.cache/sxhkd_mode
|
||||||
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue