diff --git a/configs/default_hooks/sxmo_hook_inputhandler.sh b/configs/default_hooks/sxmo_hook_inputhandler.sh index 1b20315..fb04060 100755 --- a/configs/default_hooks/sxmo_hook_inputhandler.sh +++ b/configs/default_hooks/sxmo_hook_inputhandler.sh @@ -22,7 +22,7 @@ WMNAME="$(printf %s "$XPROPOUT" | grep title: | cut -d" " -f2- | tr '[:upper:]' sxmo_debug "STATE: $(sxmo_state.sh get) ACTION: $ACTION WMCLASS: $WMCLASS WMNAME: $WMNAME" -if ! sxmo_state.sh get | grep -q unlock; then +if sxmo_state.sh is_locked; then case "$WMNAME" in # Handle programs *"epy"*|*"epr"*) case "$ACTION" in diff --git a/configs/default_hooks/sxmo_hook_lockstatusbar.sh b/configs/default_hooks/sxmo_hook_lockstatusbar.sh index b1945e9..dc0a247 100755 --- a/configs/default_hooks/sxmo_hook_lockstatusbar.sh +++ b/configs/default_hooks/sxmo_hook_lockstatusbar.sh @@ -5,7 +5,8 @@ # For use with peanutbutter (peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh) # This filters out the last component (which is usually the time and is already displayed more prominently -# obtain status output to pass to peanutbutter, using awk to remove the last -# column (the time), which we don't need duplicated. We also remove the · symbol which we use in $SXMO_NOTCH -# and is not needed for the lockscreen. -sxmo_status_watch.sh -o pango | tr -d "·" | awk 'NF{NF-=1};1' +# make sure status bar icons are suited for peanutbutter +sxmo_hook_statusbar.sh state_change + +# obtain status output to pass to peanutbutter (this keeps running and updating to stdout) +sxmo_status_watch.sh -o pango diff --git a/configs/default_hooks/sxmo_hook_screenoff.sh b/configs/default_hooks/sxmo_hook_screenoff.sh index 538f383..e56dcb7 100755 --- a/configs/default_hooks/sxmo_hook_screenoff.sh +++ b/configs/default_hooks/sxmo_hook_screenoff.sh @@ -43,6 +43,8 @@ wait case "$SXMO_WM" in sway) - command -v peanutbutter 2> /dev/null && peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh & + if command -v peanutbutter > /dev/null; then + peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh && sxmo_hook_statusbar.sh state_change & + fi ;; esac diff --git a/configs/default_hooks/sxmo_hook_statusbar.sh b/configs/default_hooks/sxmo_hook_statusbar.sh index 947096a..2f3e999 100755 --- a/configs/default_hooks/sxmo_hook_statusbar.sh +++ b/configs/default_hooks/sxmo_hook_statusbar.sh @@ -17,9 +17,14 @@ # right and "variable" icons (that come and go) on the left. set_time() { - date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}" | while read -r date; do - sxmobar -a time 99 "$date" - done + if pidof peanutbutter > /dev/null; then + #peanutbutter already features a clock, no need for one in the icon bar + sxmobar -d time + else + date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}" | while read -r date; do + sxmobar -a time 99 "$date" + done + fi } set_state() { @@ -32,11 +37,10 @@ set_state() { return fi - if command -v peanutbutter 2> /dev/null; then - if [ "$SXMO_STATES" = "unlock screenoff" ]; then - # no need for a state icon in this (default) scenario, the state will be obvious, either peanutbutter is on or it isn't - return - fi + if command -v peanutbutter > /dev/null; then + # no need for a state icon in this (default) scenario, the state will be obvious, either peanutbutter is on or it isn't + sxmobar -d state + return fi case "$(sxmo_state.sh get)" in @@ -426,8 +430,10 @@ set_volume() { } set_notch() { - if [ -n "$SXMO_NOTCH" ]; then + if [ -n "$SXMO_NOTCH" ] && ! pidof peanutbutter > /dev/null; then sxmobar -a notch "${SXMO_NOTCH_PRIO:-29}" "$SXMO_NOTCH" + else + sxmobar -d notch fi } @@ -449,6 +455,7 @@ case "$1" in if [ -z "$SXMO_NO_MODEM" ]; then set_modem fi + set_notch set_state set_network wifi wlan0 ;; diff --git a/scripts/core/sxmo_state.sh b/scripts/core/sxmo_state.sh index fbe7802..513e9a9 100644 --- a/scripts/core/sxmo_state.sh +++ b/scripts/core/sxmo_state.sh @@ -5,7 +5,7 @@ . sxmo_common.sh SXMO_STATE="${SXMO_STATE:-$XDG_RUNTIME_DIR/sxmo.state}" -if command -v peanutbutter 2> /dev/null; then +if command -v peanutbutter > /dev/null; then #no separate lock stage needed when peanutbutter is used SXMO_STATES="${SXMO_STATES:-unlock screenoff}" else @@ -164,6 +164,12 @@ case "$action" in read_state printf %s "$state" ;; + is_locked) + pidof peanutbutter swaylock waylock i3lock > /dev/null && exit 0 + if sxmo_state.sh get | grep -q unlock; then + exit 1 + fi + ;; set) lock_exclusive read_state