Change the way swal pywal support works, reword audioctrl

This commit is contained in:
speedie 2022-11-11 22:39:37 +01:00
parent a236a8b327
commit d59c4f01c8
2 changed files with 47 additions and 52 deletions

View file

@ -33,7 +33,7 @@ MUTE() {
RAISE() {
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pactl" ]; then
if [ "$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{ print $5;exit }' | sed 's/%//g')" -gt "100" ]; then
if [ "$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{ print $5;exit }' | sed 's/%//g')" = "110" ]; then
pactl set-sink-volume @DEFAULT_SINK@ 100%
else
pactl set-sink-volume @DEFAULT_SINK@ +10%
@ -125,11 +125,6 @@ fi
;;
esac
# Update status
UPDATESTATUS() {
pkill -x status && status &
}
case "$1" in
"-mute") MUTE && GETMUTE > /tmp/speedwm-audioctrl-mutestatus ;;
"-remute") remute=true ; MUTE && GETMUTE > /tmp/speedwm-audioctrl-mutestatus ; MUTE && GETMUTE > /tmp/speedwm-audioctrl-mutestatus ; remute="" ; exit 0 ;;

View file

@ -11,13 +11,15 @@ SWAL_DEFAULT_CONFIG()
{
SWAL_WALLPAPERDIR=$HOME/Wallpapers
SWAL_OLDWALLPAPERDIR=$SWAL_WALLPAPERDIR
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
SWAL_OPT=xwallpaper
SWAL_EXPORTDIR=$HOME/.config/speedwm/swal # Config directory
SWAL_IMAGE_VIEWER="nsxiv -ato" # Image viewer to use (<char>)
SWAL_ASK_WAL=false # Ask whether or not to use Pywal if possible (true/false)
SWAL_USE_WAL=true # Whether or not to use Pywal if possible (true/false)
SWAL_RANDOMIZE=false # Select a random wallpaper on login
}
@ -46,7 +48,7 @@ fi
SWAL_MKCONFIG() {
mkdir -p $SWAL_EXPORTDIR
touch $SWAL_EXPORTDIR/swalrc
SWAL_ASK_WAL_NEW=$SWAL_ASK_WAL
SWAL_USE_WAL_NEW=$SWAL_USE_WAL
SWAL_WALLPAPERDIR_NEW=$SWAL_WALLPAPERDIR
SWAL_CHANGE_WALLPAPERDIR() {
@ -54,7 +56,7 @@ SWAL_MKCONFIG() {
}
SWAL_CHANGE_ASK_WAL() {
command -v wal > /dev/null && SWAL_ASK_WAL_NEW=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Ask whether or not to use Pywal?" -l 2 | sed "s|No|false|g" | sed "s|Yes|true|g")
command -v wal > /dev/null && SWAL_USE_WAL_NEW=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Use Pywal?" -l 2 | sed "s|No|false|g; s|Yes|true|g")
}
SWAL_CHANGE_IMAGE_VIEWER() {
@ -62,7 +64,7 @@ SWAL_MKCONFIG() {
}
SWAL_CHANGE_RANDOMIZE() {
SWAL_RANDOMIZE=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Pick a random wallpaper on login?" -l 2 | sed "s|No|false|g" | sed "s|Yes|true|g")
SWAL_RANDOMIZE=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Pick a random wallpaper on login?" -l 2 | sed "s|No|false|g; s|Yes|true|g")
}
USER_OPT_ACTION=$(printf "Wallpaper directory\nPywal\nImage Viewer\nRandomize\n------\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 10 -p "What setting do you want to change?")
@ -81,7 +83,7 @@ SWAL_MKCONFIG() {
"") $0 && exit 0 ;;
esac
case "$SWAL_ASK_WAL_NEW" in
case "$SWAL_USE_WAL_NEW" in
"true") ASKED=true ;;
"false") ASKED=true ;;
esac
@ -95,7 +97,7 @@ SWAL_MKCONFIG() {
printf "\nSWAL_OPT=$SWAL_OPT" >> $SWAL_EXPORTDIR/swalrc
printf "\nSWAL_EXPORTDIR=$SWAL_EXPORTDIR" >> $SWAL_EXPORTDIR/swalrc
printf "\nSWAL_IMAGE_VIEWER='$SWAL_IMAGE_VIEWER'" >> $SWAL_EXPORTDIR/swalrc
printf "\nSWAL_ASK_WAL=$SWAL_ASK_WAL_NEW" >> $SWAL_EXPORTDIR/swalrc
printf "\nSWAL_USE_WAL=$SWAL_USE_WAL_NEW" >> $SWAL_EXPORTDIR/swalrc
printf "\nSWAL_RANDOMIZE=$SWAL_RANDOMIZE" >> $SWAL_EXPORTDIR/swalrc
}
@ -235,16 +237,10 @@ SWAL_SETTYPE()
SWAL_WAL_STATUS="0"
# Check whether or not to ask based on configuration file.
if [ "$ARG1" = "" ]; then
case "$SWAL_ASK_WAL" in
"true") command -v wal > /dev/null && SWAL_USE_WAL=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 90 -p "Do you want to use Pywal?" -l 2) && SWAL_WAL_STATUS="1" ;;
"false") command -v wal > /dev/null && SWAL_USE_WAL="Yes" && SWAL_WAL_STATUS="1" ;;
esac
else
if [ "$SWAL_USE_WAL" = "true" ]; then
command -v wal > /dev/null && SWAL_USE_WAL="Yes" && SWAL_WAL_STATUS="1"
fi
# Don't perform pywal actions if not installed/used
if [ "$SWAL_WAL_STATUS" = "0" ]; then
SWAL_USE_WAL="No"
@ -306,9 +302,13 @@ SWAL_EXPORT_SCRIPT_WAL()
printf "$SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
fi
# make script executable
chmod +x $SWAL_EXPORTDIR/swal_wm
rm -rf $HOME/.cache/wal # Delete previous colors
wal -nqi "'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'" && xrdb ~/.cache/wal/colors.Xresources || xrdb -remove # Compatibility with my speedwm build
wal -nqi "'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'" && xrdb ~/.cache/wal/colors.Xresources || xrdb -remove # Remove xrdb values
if [ -e "$SWAL_EXPORTDIR/CurrentWallpaper" ]; then
rm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev ; ln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" $SWAL_EXPORTDIR/CurrentWallpaper_prev
fi