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"
|
||||
|
||||
FORMAT_LEFT=" %(music)s %(services)s %(diskspace)s"
|
||||
FORMAT_RIGHT="%(updates)s %(wifi)s %(battery)s %(clock)s "
|
||||
FORMAT=" %(music)s %(services)s %(diskspace)s %%{c} %(debug)s %%{r} %(updates)s %(wifi)s %(battery)s %(clock)s "
|
||||
|
||||
icon_color="#A0A57E"
|
||||
icon() { echo -n "%{F$icon_color}"; printf '%b' "\ue$1"; echo -n "%{F-}"; }
|
||||
|
@ -133,7 +132,7 @@ run_handler() {
|
|||
cd $(dirname $0)
|
||||
|
||||
#Trap magic
|
||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||
trap "trap - SIGTERM && kill -9 -- -$$" SIGINT SIGTERM EXIT
|
||||
|
||||
#Fifo
|
||||
[ -e "$FIFO" ] && rm -f $FIFO
|
||||
|
@ -148,5 +147,6 @@ diskspace &
|
|||
wifi &
|
||||
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):
|
||||
return self.get(key, self.default)
|
||||
|
||||
if len(argv) <= 2:
|
||||
print("%s <format_left> <format_right>" % argv[0])
|
||||
if len(argv) <= 1:
|
||||
print("%s <format>" % argv[0])
|
||||
exit(1)
|
||||
|
||||
format_left = argv[1]
|
||||
format_right = argv[2]
|
||||
format_str = argv[1]
|
||||
cache = DefaultDict("")
|
||||
|
||||
_format = lambda: '%{l}' + (format_left % cache) + '%{r}' + (format_right % cache)
|
||||
|
||||
while True:
|
||||
print(_format())
|
||||
tag,content = input().rstrip('\n').split(' ',1)
|
||||
print(format_str % cache)
|
||||
data = input().rstrip('\n').split(' ',1)
|
||||
if len(data) < 2:
|
||||
tag,content = data[0],""
|
||||
else:
|
||||
tag,content = data
|
||||
cache[tag] = content
|
||||
|
|
Loading…
Reference in a new issue