1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-10-09 19:11:15 +02:00

local: changed and updated scripts

This commit is contained in:
2024-03-17 22:52:40 +01:00
parent 62c161c3c1
commit 923fba39f4
20 changed files with 70 additions and 53 deletions

View File

@@ -2,38 +2,75 @@
# A general audio interface for LARBS.
# Based on a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
# Heavily extended and updated to a pipewire system
[ -z "$2" ] && num="5" || num="$2"
case "$1" in
up) wpctl set-volume @DEFAULT_AUDIO_SINK@ "$num"%+ ;;
down) wpctl set-volume @DEFAULT_AUDIO_SINK@ "$num"%- ;;
deaf) wpctl set-mute @DEFAULT_SINK@ 1;;
undeaf) wpctl set-mute @DEFAULT_SINK@ 0;;
mute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1;;
unmute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0;;
previous) playerctl previous;;
playpause) playerctl play-pause;;
next) playerctl next;;
shuffle) playerctl shuffle toggle;;
loop) playerctl loop none;;
*) cat << EOF
up) wpctl set-volume @DEFAULT_AUDIO_SINK@ "$num"%+
pkill -RTMIN+4 $STATUSBAR ;;
down) wpctl set-volume @DEFAULT_AUDIO_SINK@ "$num"%-
pkill -RTMIN+4 $STATUSBAR ;;
deaf) wpctl set-mute @DEFAULT_SINK@ 1
pkill -RTMIN+4 $STATUSBAR ;;
undeaf) wpctl set-mute @DEFAULT_SINK@ 0
pkill -RTMIN+4 $STATUSBAR ;;
mute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1
pkill -RTMIN+4 $STATUSBAR ;;
unmute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0
pkill -RTMIN+4 $STATUSBAR ;;
deaf_toggle)
if amixer get Master | tail -2 | grep -q '\[on\]'; then
notify-send -u low 'sxhkd' 'Sound muted\nMicrophone muted'
lmc mute
lmc deaf
else
lmc mute
lmc undeaf
paplay ~/.local/bin/etc/sxhkd/audio/sound_resumed.wav
fi ;;
mute_toggle)
if amixer get Capture | tail -2 | grep -q '\[on\]'; then
lmc mute
lmc undeaf
paplay ~/.local/bin/etc/sxhkd/audio/mic_muted.wav
else
lmc unmute
lmc undeaf
paplay ~/.local/bin/etc/sxhkd/audio/mic_activated.wav
fi ;;
previous) playerctl previous
sleep 1
pkill -RTMIN+9 $STATUSBAR ;;
playpause) playerctl play-pause
sleep 1
pkill -RTMIN+9 $STATUSBAR ;;
next) playerctl next
sleep 1
pkill -RTMIN+9 $STATUSBAR ;;
shuffle) playerctl shuffle toggle
sleep 1
pkill -RTMIN+9 $STATUSBAR ;;
loop) playerctl loop none
sleep 1
pkill -RTMIN+9 $STATUSBAR ;;
*) cat << EOF
lmc: cli music interface for pulse for those with divine intellect too
grand to remember the pamixer commands.
Allowed options:
up NUM Increase volume (5% default)
down NUM Decrease volume (5% default)
mute mute microphone
unmute unmute microphone
deaf deaf sound
undeaf undeaf sound
previous play previous song in player
playpause toggle play or pause in player
next play next song in player
mute Mute microphone
unmute Unmute microphone
deaf Deaf sound
undeaf Undeaf sound
deaf_toggle Toggle between deaf and undeaf
mute_toggle Toggle between mute and unmute
previous Play previous song in player
playpause Toggle play or pause in player
next Play next song in player
all else Print this message
EOF
esac
pkill -RTMIN+4 $STATUSBAR
sleep 1 && pkill -RTMIN+9 $STATUSBAR

View File

@@ -1,10 +0,0 @@
#!/bin/sh
if amixer get Capture | tail -2 | grep -q '\[on\]'; then
lmc mute
lmc undeaf
paplay ~/.local/bin/etc/sxhkd/audio/mic_muted.wav
else
lmc unmute
lmc undeaf
paplay ~/.local/bin/etc/sxhkd/audio/mic_activated.wav
fi

View File

@@ -1,10 +0,0 @@
#!/bin/sh
if amixer get Master | tail -2 | grep -q '\[on\]'; then
notify-send -u low 'sxhkd' 'Sound muted\nMicrophone muted'
lmc mute
lmc deaf
else
lmc mute
lmc undeaf
paplay ~/.local/bin/etc/sxhkd/audio/sound_resumed.wav
fi

View File

@@ -0,0 +1,14 @@
#!/bin/sh
layout=$(setxkbmap -query | grep "layout" | awk '{print $NF}') #| grep -q 'ru$' && $(setxkbmap de ; notify-send -u low 'SXHKD' 'Set keymap to german') || $(setxkbmap de ru ; notify-send -u low 'SXHKD' 'Set keymap to russian')
variant=$(setxkbmap -query | grep "variant" | awk '{print $NF}')
echo $variant
if [ "$layout" = "de" -a "$variant" = "nodeadkeys" ]
then
setxkbmap de && notify-send -u low 'SXHKD' 'Set keymap to german'
elif [ "$layout" = "de" -a "$variant" = "" ]
then
setxkbmap de ru && notify-send -u low 'SXHKD' 'Set keymap to russian (german)'
elif [ "$layout" = "de" -a "$variant" = "ru" ]
then
setxkbmap de nodeadkeys && notify-send -u low 'SXHKD' 'Set keymap to german (nodeadkeys)'
fi

View File

@@ -0,0 +1,11 @@
#!/bin/sh
# toggle external monitor
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
intern=LVDS1
extern=HDMI2
(xrandr | grep "$extern disconnected")
(xrandr --listactivemonitors | grep $extern) || ((xrandr --output $extern --right-of $intern --auto && setbg) & exit)
(xrandr --listactivemonitors | grep $extern) && xrandr --output $extern --off
background_set

View File

@@ -0,0 +1,61 @@
#!/bin/sh
# Gives a dmenu prompt to mount unmounted drives.
# If they're in /etc/fstab, they'll be mounted automatically.
# Otherwise, you'll be prompted to give a mountpoint from already existsing directories.
# If you input a novel directory, it will prompt you to create that directory.
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
getmount() { \
[ -z "$chosen" ] && exit 1
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")"
[ "$mp" = "" ] && exit 1
if [ ! -d "$mp" ]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?")
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
fi
}
mountusb() { \
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \\( -path *%s -prune \\) \\ \n",$3}')
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
partitiontype="$(lsblk -no "fstype" "$chosen")"
case "$partitiontype" in
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
esac
notify-send "💻 USB mounting" "$chosen mounted to $mp."
}
mountandroid() { \
chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1)
getmount "$HOME -maxdepth 3 -type d"
simple-mtpfs --device "$chosen" "$mp"
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
}
asktype() { \
case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in
USB) mountusb ;;
Android) mountandroid ;;
esac
}
anddrives=$(simple-mtpfs -l 2>/dev/null)
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')"
if [ -z "$usbdrives" ]; then
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
echo "Android device(s) detected."
mountandroid
else
if [ -z "$anddrives" ]; then
echo "USB drive(s) detected."
mountusb
else
echo "Mountable USB drive(s) and Android device(s) detected."
asktype
fi
fi

View File

@@ -0,0 +1,43 @@
#!/bin/sh
# A dmenu prompt to unmount drives.
# Provides you with mounted partitions, select one to unmount.
# Drives mounted at /, /boot and /home will not be options to unmount.
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
unmountusb() {
[ -z "$drives" ] && exit
chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}')
[ -z "$chosen" ] && exit
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
}
unmountandroid() { \
chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")
[ -z "$chosen" ] && exit
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
}
asktype() { \
case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in
USB) unmountusb ;;
Android) unmountandroid ;;
esac
}
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
if ! grep simple-mtpfs /etc/mtab; then
[ -z "$drives" ] && echo "No drives to unmount." && exit
echo "Unmountable USB drive detected."
unmountusb
else
if [ -z "$drives" ]
then
echo "Unmountable Android device detected."
unmountandroid
else
echo "Unmountable USB drive(s) and Android device(s) detected."
asktype
fi
fi

View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Toggle touchpad. Requires xf86-input-synaptics.
# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice
(synclient | grep "TouchpadOff.*1" && synclient TouchpadOff=0)>/dev/null && notify-send "TouchPad reactivated." && exit
synclient TouchpadOff=1 && notify-send "TouchPad deactivated."