diff --git a/installers/arch/pkgs/aur.list b/installers/arch/pkgs/aur.list index 1fe4d0a..d16bc80 100644 --- a/installers/arch/pkgs/aur.list +++ b/installers/arch/pkgs/aur.list @@ -23,3 +23,4 @@ swhkd-git nerd-fonts-mononoki autotiling cli-visualizer +wob diff --git a/mywob b/mywob new file mode 100755 index 0000000..fe4c912 --- /dev/null +++ b/mywob @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# https://gitlab.com/wef/dotfiles/-/blob/master/bin/mywob +# shellcheck disable=SC2034 +TIME_STAMP="20220627.145053" + +# Copyright (C) 2020-2021 Bob Hepple < bob dot hepple at gmail dot com> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +PROG=$( basename "$0" ) +wob_pipe=~/.cache/$( basename "$SWAYSOCK" ).wob + +case "$1" in + -h|--help) + echo "Usage: $PROG [percent]" + echo + echo "pops up wob; sets up $wob_pipe if necessary " + exit 0 + ;; +esac + +[[ "$SWAYSOCK" ]] || exit 0 + +# returns 0 (success) if $1 is running and is attached to this sway session; else 1 +is_running_on_this_screen() { + pkill -0 "$1" || return 1 + for pid in $( pgrep "$1" ); do + WOB_SWAYSOCK="$( tr '\0' '\n' < "/proc/$pid/environ" | awk -F'=' '/^SWAYSOCK/ {print $2}' )" + if [[ "$WOB_SWAYSOCK" == "$SWAYSOCK" ]]; then + return 0 + fi + done + return 1 +} + +new_value=$1 # null or a percent; no checking!! + +[[ -p $wob_pipe ]] || mkfifo "$wob_pipe" + +# wob does not appear in $(swaymsg -t get_msg), so: +is_running_on_this_screen wob || { + tail -f "$wob_pipe" | wob & +} + +# sometimes this hangs - need to use a timeout and restart wob if necessary: +[[ "$new_value" ]] && echo "$new_value" > "$wob_pipe" + +# Local Variables: +# mode: shell-script +# time-stamp-pattern: "4/TIME_STAMP=\"%:y%02m%02d.%02H%02M%02S\"" +# eval: (add-hook 'before-save-hook 'time-stamp) +# End: + diff --git a/vol.sh b/vol.sh index d8c5522..2675504 100755 --- a/vol.sh +++ b/vol.sh @@ -6,12 +6,23 @@ refbar() { pkill sleep -P "$(cat ~/.cache/statusbar_pid )" } +display() { + VAL="$(get | sed 's/^.*\.//g' )" + + [ -n "$1" ] && VAL="$1" + + mywob "$VAL" + +} + inc() { [ "$1" ] && PERC="$1" #pulsemixer --change-volume +"$1" && refbar #amixer sset Master 1%+ && refbar #pamixer -i "$PERC" && refbar wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) + $PERC" | bc)" && refbar + + display } dec() { @@ -20,6 +31,8 @@ dec() { #amixer sset Master 1%- && refbar #pamixer -d "$PERC" && refbar wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) - $PERC" | bc)" && refbar + + display } mute() { @@ -27,6 +40,8 @@ mute() { #amixer sset Master toggle && refbar #pamixer -t && refbar wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && refbar + + display } get() { @@ -48,6 +63,8 @@ elif [ "$1" = "--toggle-mute" ]; then mute elif [ "$1" = "-g" ]; then get +elif [ "$1" = "-display" ]; then + display else help fi