mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-25 09:36:14 +01:00
bd9c1faee1
Signed-off-by: Magic_RB <magic_rb@redalder.org>
106 lines
3.6 KiB
Nix
106 lines
3.6 KiB
Nix
{ pkgs, lib, ... }:
|
|
{
|
|
home.file.".xmonad/xmonad.hs".source = pkgs.writeSubstitutedFile {
|
|
name = "xmonad.hs";
|
|
file = ./xmonad.hs;
|
|
substitutes = {
|
|
"brightnessctl" = lib.getExe pkgs.brightnessctl;
|
|
"playerctl" = lib.getExe pkgs.playerctl;
|
|
"dmenu_run" = "${pkgs.dmenu}/bin/dmenu_run";
|
|
"polybar" = pkgs.writeShellScript "polybar"
|
|
''
|
|
export PATH=${lib.makeBinPath [ pkgs.polybarFull ]}:$PATH
|
|
|
|
monitors=$(polybar --list-monitors | cut -f 1 -d':' | tr '\n' ' ')
|
|
monitors=($monitors)
|
|
MONITOR=''${monitors[$1]} polybar -c ${./polybar.ini} top
|
|
'';
|
|
"reload" = pkgs.writeShellScript "xmonad-reload"
|
|
''
|
|
${lib.getExe pkgs.libnotify} -t 5000 "recompiling xmonad"
|
|
|
|
if xmonad --recompile
|
|
then
|
|
${lib.getExe pkgs.libnotify} -t 5000 "compilation succeeded"
|
|
xmonad --restart
|
|
else
|
|
${lib.getExe pkgs.libnotify} -t 5000 "compilation failed"
|
|
fi
|
|
'';
|
|
"toggle_touchpad" = pkgs.writeShellScript "toggle-touchpad"
|
|
''
|
|
read TPdevice <<< $( xinput | sed -nre '/TouchPad|Touchpad/s/.*id=([0-9]*).*/\1/p' )
|
|
state=$( xinput list-props "$TPdevice" | grep "Device Enabled" | grep -o "[01]$" )
|
|
|
|
if [ "$state" -eq '1' ];then
|
|
xinput --disable "$TPdevice" && notify-send -i emblem-nowrite "Touchpad" "Disabled"
|
|
else
|
|
xinput --enable "$TPdevice" && notify-send -i emblem-nowrite "Touchpad" "Enabled"
|
|
fi
|
|
'';
|
|
"auxmenu" = pkgs.writeShellScript "auxmenu"
|
|
''
|
|
export SUDO_ASKPASS=${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass
|
|
|
|
_options="toggle-mic\ntoggle-wifi\ntoggle-bluetooth\nscreenshot-all\nscreenshot-select\nscreenshot-focused\nsuspend\nreboot\nkexec\npoweroff\nlogout\nnmtui"
|
|
|
|
_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)
|
|
if [ "$(nmcli radio wifi)" = "enabled" ]
|
|
then
|
|
nmcli radio wifi off
|
|
else
|
|
nmcli radio wifi on
|
|
fi
|
|
;;
|
|
toggle-bluetooth)
|
|
if [ "$(nmcli radio wifi)" = "enabled" ]
|
|
then
|
|
nmcli radio wifi off
|
|
else
|
|
nmcli radio wifi on
|
|
fi
|
|
;;
|
|
screenshot-all)
|
|
${lib.getExe pkgs.magic-screenshot} screen
|
|
;;
|
|
screenshot-select)
|
|
${lib.getExe pkgs.magic-screenshot} select
|
|
;;
|
|
screenshot-focused)
|
|
${lib.getExe pkgs.magic-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
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
fi
|
|
'';
|
|
};
|
|
};
|
|
}
|