mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-30 03:56:12 +01:00
8ebc3a65ba
Signed-off-by: magic_rb <magic_rb@redalder.org>
75 lines
2.5 KiB
Bash
75 lines
2.5 KiB
Bash
export SUDO_ASKPASS=/home/main/.xmonad/runenv/libexec/x11-ssh-askpass
|
|
|
|
_options="toggle-mic\ntoggle-wifi\ntoggle-bluetooth\nscreenshot-all\nscreenshot-select\nscreenshot-focused\nsuspend\nreboot\nkexec\npoweroff\nlogout\nnmtui\ntoggle-disable-while-typing"
|
|
|
|
_option="$(echo -e $_options | emacs-rofi "command: " 90 30 | awk '{print $1}' | tr -d '\r\n')"
|
|
if [ ''${#_option} -gt 0 ]
|
|
then
|
|
case $_option in
|
|
toggle-mic)
|
|
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
|
|
;;
|
|
toggle-wifi)
|
|
function get_wifi_state() {
|
|
interface="$1"
|
|
|
|
iwlist "$interface" power | sed 's/wlan0//' | awk '{$1=$1};1' | tr -s ' ' | grep "Current mode" | cut -d ':' -f 2
|
|
}
|
|
if [ "$(get_wifi_state "wlan0")" = "on" ]
|
|
then
|
|
iwctl adapter phy0 set-property Powered off
|
|
else
|
|
iwctl adapter phy0 set-property Powered on
|
|
fi
|
|
;;
|
|
toggle-bluetooth)
|
|
if [ "$(bluetoothctl show | grep -i powered | tr '\t' ' ' | cut -f 3 -d ' ')" = "yes" ]
|
|
then
|
|
bluetoothctl power off
|
|
else
|
|
bluetoothctl power on
|
|
fi
|
|
;;
|
|
screenshot-all)
|
|
screenshot screen
|
|
;;
|
|
screenshot-select)
|
|
screenshot select
|
|
;;
|
|
screenshot-focused)
|
|
screenshot focused
|
|
;;
|
|
suspend)
|
|
systemctl suspend
|
|
;;
|
|
reboot)
|
|
systemctl reboot
|
|
;;
|
|
poweroff)
|
|
systemctl poweroff
|
|
;;
|
|
kexec)
|
|
sudo -A kexec -l /run/current-system/kernel --initrd=/run/current-system/initrd --reuse-cmdline
|
|
systemctl kexec
|
|
;;
|
|
logout)
|
|
loginctl terminate-session $XDG_SESSION_ID
|
|
;;
|
|
nmtui)
|
|
alacritty -e nmtui
|
|
;;
|
|
toggle-disable-while-typing)
|
|
ID=$(xinput list|grep touch -i|sed -nr 's/.*id=([0-9]*).*/\1/p')
|
|
IN_TAP=$(xinput list-props $ID|grep "Disable While"|grep -v "Default" |sed -nr 's/.*\(([0-9][0-9][0-9])\).*/\1/p')
|
|
CURRENT=$(xinput list-props 12 | grep "Disable While" | grep -v "Default" | sed -nr 's/.*([0-9]+)$/\1/p')
|
|
if [ "$CURRENT" == "1" ] ; then
|
|
xinput set-prop $ID $IN_TAP 0
|
|
else
|
|
xinput set-prop $ID $IN_TAP 1
|
|
fi
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
fi
|