add wob to install, add mywob script to repo

master
Alex 2022-09-22 23:35:47 -05:00
parent 17de6f8bc8
commit 9a2af58acf
3 changed files with 82 additions and 0 deletions

View File

@ -23,3 +23,4 @@ swhkd-git
nerd-fonts-mononoki nerd-fonts-mononoki
autotiling autotiling
cli-visualizer cli-visualizer
wob

64
mywob Executable file
View File

@ -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 <http://www.gnu.org/licenses/>.
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:

17
vol.sh
View File

@ -6,12 +6,23 @@ refbar() {
pkill sleep -P "$(cat ~/.cache/statusbar_pid )" pkill sleep -P "$(cat ~/.cache/statusbar_pid )"
} }
display() {
VAL="$(get | sed 's/^.*\.//g' )"
[ -n "$1" ] && VAL="$1"
mywob "$VAL"
}
inc() { inc() {
[ "$1" ] && PERC="$1" [ "$1" ] && PERC="$1"
#pulsemixer --change-volume +"$1" && refbar #pulsemixer --change-volume +"$1" && refbar
#amixer sset Master 1%+ && refbar #amixer sset Master 1%+ && refbar
#pamixer -i "$PERC" && refbar #pamixer -i "$PERC" && refbar
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) + $PERC" | bc)" && refbar wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) + $PERC" | bc)" && refbar
display
} }
dec() { dec() {
@ -20,6 +31,8 @@ dec() {
#amixer sset Master 1%- && refbar #amixer sset Master 1%- && refbar
#pamixer -d "$PERC" && refbar #pamixer -d "$PERC" && refbar
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) - $PERC" | bc)" && refbar wpctl set-volume @DEFAULT_AUDIO_SINK@ "$(echo "$(get) - $PERC" | bc)" && refbar
display
} }
mute() { mute() {
@ -27,6 +40,8 @@ mute() {
#amixer sset Master toggle && refbar #amixer sset Master toggle && refbar
#pamixer -t && refbar #pamixer -t && refbar
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && refbar wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && refbar
display
} }
get() { get() {
@ -48,6 +63,8 @@ elif [ "$1" = "--toggle-mute" ]; then
mute mute
elif [ "$1" = "-g" ]; then elif [ "$1" = "-g" ]; then
get get
elif [ "$1" = "-display" ]; then
display
else else
help help
fi fi