Only 1 format string necessary
This commit is contained in:
parent
823f3de739
commit
604fe4aac5
2 changed files with 13 additions and 12 deletions
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
FIFO="/tmp/bar.fifo"
|
FIFO="/tmp/bar.fifo"
|
||||||
|
|
||||||
FORMAT_LEFT=" %(music)s %(services)s %(diskspace)s"
|
FORMAT=" %(music)s %(services)s %(diskspace)s %%{c} %(debug)s %%{r} %(updates)s %(wifi)s %(battery)s %(clock)s "
|
||||||
FORMAT_RIGHT="%(updates)s %(wifi)s %(battery)s %(clock)s "
|
|
||||||
|
|
||||||
icon_color="#A0A57E"
|
icon_color="#A0A57E"
|
||||||
icon() { echo -n "%{F$icon_color}"; printf '%b' "\ue$1"; echo -n "%{F-}"; }
|
icon() { echo -n "%{F$icon_color}"; printf '%b' "\ue$1"; echo -n "%{F-}"; }
|
||||||
|
@ -133,7 +132,7 @@ run_handler() {
|
||||||
cd $(dirname $0)
|
cd $(dirname $0)
|
||||||
|
|
||||||
#Trap magic
|
#Trap magic
|
||||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
trap "trap - SIGTERM && kill -9 -- -$$" SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
#Fifo
|
#Fifo
|
||||||
[ -e "$FIFO" ] && rm -f $FIFO
|
[ -e "$FIFO" ] && rm -f $FIFO
|
||||||
|
@ -148,5 +147,6 @@ diskspace &
|
||||||
wifi &
|
wifi &
|
||||||
updates &
|
updates &
|
||||||
|
|
||||||
( while true; do cat $FIFO; done ) | python ./barformatter.py "$FORMAT_LEFT" "$FORMAT_RIGHT" | lemonbar -g 1366x15 -f "Stlarch:size=6:style=regular" -f "Terminus:size=8" -B "#88000000" | run_handler
|
( while true; do cat $FIFO; done ) | python ./barformatter.py "$FORMAT" | lemonbar -g 1366x15 -f "Stlarch:size=6:style=regular" -f "Terminus:size=8" -B "#88000000" | run_handler
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -8,17 +8,18 @@ class DefaultDict(dict):
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self.get(key, self.default)
|
return self.get(key, self.default)
|
||||||
|
|
||||||
if len(argv) <= 2:
|
if len(argv) <= 1:
|
||||||
print("%s <format_left> <format_right>" % argv[0])
|
print("%s <format>" % argv[0])
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
format_left = argv[1]
|
format_str = argv[1]
|
||||||
format_right = argv[2]
|
|
||||||
cache = DefaultDict("")
|
cache = DefaultDict("")
|
||||||
|
|
||||||
_format = lambda: '%{l}' + (format_left % cache) + '%{r}' + (format_right % cache)
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print(_format())
|
print(format_str % cache)
|
||||||
tag,content = input().rstrip('\n').split(' ',1)
|
data = input().rstrip('\n').split(' ',1)
|
||||||
|
if len(data) < 2:
|
||||||
|
tag,content = data[0],""
|
||||||
|
else:
|
||||||
|
tag,content = data
|
||||||
cache[tag] = content
|
cache[tag] = content
|
||||||
|
|
Loading…
Reference in a new issue