From 95b1292562630adb346c53f62c300cf12700f9c6 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 29 May 2019 00:49:49 +0200 Subject: [PATCH] Move panel variables to zprofile --- .config/zsh/.zprofile | 5 +++++ .scripts/panel/brightness.sh | 3 +-- .scripts/panel/lemonbar.sh | 36 ++++++++++++------------------------ .scripts/panel/volume.sh | 3 +-- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index a1e15a4..d082712 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -32,6 +32,11 @@ export LESS_TERMCAP_se="$(printf '%b' '\e[0m')" # reset reverse video export LESS_TERMCAP_us="$(printf '%b' '\e[04;95m')" # begin underline export LESS_TERMCAP_ue="$(printf '%b' '\e[0m')" # reset underline +# Panel +export PANEL_HEIGHT=38 +export PANEL_NAME="lemonbar_panel" +export PANEL_PIPE="/tmp/lemonbar_pipe" + # Qt5 export QT_AUTO_SCREEN_SCALE_FACTOR=0 export QT_SCREEN_SCALE_FACTORS=2 diff --git a/.scripts/panel/brightness.sh b/.scripts/panel/brightness.sh index c6b2778..b3e29eb 100755 --- a/.scripts/panel/brightness.sh +++ b/.scripts/panel/brightness.sh @@ -19,6 +19,5 @@ fi INPUT="%{$R}%{$U}%{$D}" END="%{A}%{A}%{A}" -PIPE="$("$(dirname "$0")"/lemonbar.sh get_pipe)" -printf "%s\n" "brightness$INPUT$ICON $PERCENTAGE%$END" > "$PIPE" & +printf "%s\n" "brightness$INPUT$ICON $PERCENTAGE%$END" > "$PANEL_PIPE" & diff --git a/.scripts/panel/lemonbar.sh b/.scripts/panel/lemonbar.sh index 4a70980..25ceb5a 100755 --- a/.scripts/panel/lemonbar.sh +++ b/.scripts/panel/lemonbar.sh @@ -1,9 +1,5 @@ #!/bin/sh -PIPE="/tmp/lemonbar_pipe" -PANEL="lemonbar_panel" -PANEL_HEIGHT=38 - title() { # Grab focused window's ID if [ -n "$1" ]; then @@ -35,7 +31,7 @@ clock() { bar() { lemonbar \ - -a 20 -g x$PANEL_HEIGHT -n "$PANEL" \ + -a 20 -g x$PANEL_HEIGHT -n "$PANEL_NAME" \ -f "DejaVu Sans-8" -o 0 \ -f "FontAwesome5Free Solid-8" -o -3 \ -f "FontAwesome5Free Regular-8" -o -3 \ @@ -53,8 +49,8 @@ start() { trap 'trap - TERM; kill 0' INT TERM QUIT EXIT # Create named pipe - [ -p $PIPE ] && rm "$PIPE" - mkfifo "$PIPE" + [ -p $PANEL_PIPE ] && rm "$PANEL_PIPE" + mkfifo "$PANEL_PIPE" # Directory of this script DIR="$(dirname "$0")" @@ -62,23 +58,23 @@ start() { # Setup workspaces block with xprop events xprop -root -spy _NET_CURRENT_DESKTOP _NET_NUMBER_OF_DESKTOPS | while read -r line; do "$DIR"/workspaces.sh - done > "$PIPE" & + done > "$PANEL_PIPE" & # Setup window title block with xprop events xprop -root -spy '\t$0\n' _NET_ACTIVE_WINDOW | while read -r line; do title "$line" - done > "$PIPE" & + done > "$PANEL_PIPE" & # Setup interrupt blocks "$DIR"/volume.sh "$DIR"/brightness.sh # Setup block timers - while :; do title; sleep 1; done > "$PIPE" & - while :; do "$DIR"/wifi.sh; sleep 10; done > "$PIPE" & - while :; do "$DIR"/iface.sh; sleep 10; done > "$PIPE" & - while :; do "$DIR"/battery.sh; sleep 30; done > "$PIPE" & - while :; do clock; sleep 5; done > "$PIPE" & + while :; do title; sleep 1; done > "$PANEL_PIPE" & + while :; do "$DIR"/wifi.sh; sleep 10; done > "$PANEL_PIPE" & + while :; do "$DIR"/iface.sh; sleep 10; done > "$PANEL_PIPE" & + while :; do "$DIR"/battery.sh; sleep 30; done > "$PANEL_PIPE" & + while :; do clock; sleep 5; done > "$PANEL_PIPE" & while read -r line ; do case $line in @@ -108,21 +104,13 @@ start() { ;; esac printf "%s\n" "%{l}$workspaces%{c}$title%{r}$volume $brightness $wifi $iface $battery $clock " - done < "$PIPE" | bar | sh & + done < "$PANEL_PIPE" | bar | sh & wait } -get_height() { - printf "%s" "$PANEL_HEIGHT" -} - -get_pipe() { - printf "%s" "$PIPE" -} - case "$1" in - start | get_height | get_pipe) + start) "$1" ;; "") diff --git a/.scripts/panel/volume.sh b/.scripts/panel/volume.sh index 61313b6..b9fb2a8 100755 --- a/.scripts/panel/volume.sh +++ b/.scripts/panel/volume.sh @@ -30,6 +30,5 @@ fi INPUT="%{$L}%{$S}%{$R}%{$U}%{$D}" END="%{A}%{A}%{A}%{A}%{A}" -PIPE="$("$(dirname "$0")"/lemonbar.sh get_pipe)" -printf "%s\n" "volume%{F$COLOR}$INPUT$SYMBOL $VOLUME%$END%{F-}" > "$PIPE" & +printf "%s\n" "volume%{F$COLOR}$INPUT$SYMBOL $VOLUME%$END%{F-}" > "$PANEL_PIPE" &