2023-03-16 23:36:17 +05:30
|
|
|
{ osConfig, pkgs, ... }:
|
2023-03-15 22:11:59 +05:30
|
|
|
|
|
|
|
{
|
2023-03-16 23:36:17 +05:30
|
|
|
xdg.configFile = {
|
|
|
|
"scripts/power_menu.sh" = {
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!/bin/sh
|
2023-03-15 22:11:59 +05:30
|
|
|
|
2023-03-16 23:36:17 +05:30
|
|
|
set -eu
|
2023-03-15 22:11:59 +05:30
|
|
|
|
2023-03-16 23:36:17 +05:30
|
|
|
chpower() {
|
|
|
|
case "$1" in
|
|
|
|
"")
|
|
|
|
;;
|
|
|
|
Shutdown)
|
|
|
|
exec systemctl poweroff
|
|
|
|
;;
|
|
|
|
Reboot)
|
|
|
|
exec systemctl reboot
|
|
|
|
;;
|
|
|
|
Hibernate)
|
|
|
|
exec systemctl hibernate
|
|
|
|
;;
|
|
|
|
Logout)
|
|
|
|
swaymsg exit
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
${pkgs.libnotify}/bin/notify-send -t 1500 -u low "Invalid Option"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2023-03-15 22:11:59 +05:30
|
|
|
|
2023-03-16 23:36:17 +05:30
|
|
|
OPTIONS="Shutdown\nReboot\nHibernate\nLogout"
|
|
|
|
|
|
|
|
chpower "$(printf "%b" "$OPTIONS" | sort | ${pkgs.rofi-wayland}/bin/rofi -dmenu -p "Power Menu")"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
"scripts/volume_up.sh" = {
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
|
|
|
|
[ $(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk -F': ' '{print $2}' | sed 's/\.//') -lt 100 ] && ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
"scripts/tmux_sessions.sh" = {
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
SESSION="$(${pkgs.tmux}/bin/tmux list-sessions -F "(#{session_attached}) #S [#{pane_current_command} in #{pane_current_path}] #{pane_title}" | sort | ${pkgs.rofi-wayland}/bin/rofi -dmenu -p "Running TMUX Sessions" | awk '{print $2}')"
|
|
|
|
case "$SESSION" in
|
|
|
|
"")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
${pkgs.kitty}/bin/kitty ${pkgs.tmux}/bin/tmux -u attach-session -dEt "$SESSION"
|
|
|
|
;;
|
|
|
|
esac'';
|
|
|
|
};
|
|
|
|
"scripts/power_profile.sh" =
|
|
|
|
let
|
|
|
|
sudo = "/run/wrappers/bin/sudo";
|
|
|
|
cpupower = "${osConfig.boot.kernelPackages.cpupower}/bin/cpupower";
|
|
|
|
powerprofilesctl = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl";
|
|
|
|
in {
|
|
|
|
executable = true;
|
|
|
|
text = ''
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
POWER_PROFILE_FILE="$HOME/.cache/power_profile"
|
|
|
|
POWER_PROFILE="powersave"
|
|
|
|
|
|
|
|
if [ -f "$POWER_PROFILE_FILE" ]; then
|
|
|
|
POWER_PROFILE="$(<$POWER_PROFILE_FILE)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"toggle")
|
|
|
|
if [ "$POWER_PROFILE" == "powersave" ]; then
|
|
|
|
${sudo} ${cpupower} frequency-set --governor performance > /dev/null
|
|
|
|
${powerprofilesctl} set performance
|
|
|
|
POWER_PROFILE="performance"
|
|
|
|
elif [ "$POWER_PROFILE" == "performance" ]; then
|
|
|
|
${sudo} ${cpupower} frequency-set --governor powersave > /dev/null
|
|
|
|
${powerprofilesctl} set power-saver
|
|
|
|
POWER_PROFILE="powersave"
|
|
|
|
fi
|
|
|
|
echo $POWER_PROFILE > $POWER_PROFILE_FILE
|
|
|
|
;;
|
|
|
|
"icon")
|
|
|
|
if [ "$POWER_PROFILE" == "powersave" ]; then
|
|
|
|
echo ""
|
|
|
|
elif [ "$POWER_PROFILE" == "performance" ]; then
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
2023-03-15 22:11:59 +05:30
|
|
|
|
2023-03-16 23:36:17 +05:30
|
|
|
'';
|
|
|
|
};
|
2023-03-15 22:11:59 +05:30
|
|
|
};
|
|
|
|
}
|