configuration.nix/home/scripts.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

2023-04-04 09:39:55 +05:30
{ osConfig, pkgs, ... }:
2023-03-29 21:48:55 +05:30
let
2023-03-17 22:44:27 +05:30
notify-send = "${pkgs.libnotify}/bin/notify-send";
dmenu = "${pkgs.rofi-wayland}/bin/rofi -dmenu";
2023-03-29 21:48:55 +05:30
in
{
2023-03-16 23:36:17 +05:30
xdg.configFile = {
2023-04-04 09:58:29 +05:30
"scripts/chpaper.sh" = {
text = ''
#!/bin/sh
2023-04-04 09:39:55 +05:30
2023-04-04 09:58:29 +05:30
set -eu
2023-04-04 09:39:55 +05:30
2023-04-04 09:58:29 +05:30
DIR="''${HOME}/.local/share/wallpapers"
2023-04-04 09:39:55 +05:30
2023-04-04 09:58:29 +05:30
random_paper() {
find -L "''${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1
}
2023-04-04 09:39:55 +05:30
2023-04-04 09:58:29 +05:30
SWAYSOCK="''${SWAYSOCK:-""}"
if [ -z "''${SWAYSOCK}" ] ; then
SWAYSOCK="$(find /run/user/"$(id -u)"/ -name "sway-ipc.$(id -u).*.sock")"
export SWAYSOCK
fi
${pkgs.imagemagick}/bin/convert "$(random_paper)" /tmp/wallpaper.jpg && swaymsg "output * bg '/tmp/wallpaper.jpg' fill" &
${pkgs.imagemagick}/bin/convert "$(random_paper)" /tmp/lockpaper.jpg
'';
executable = true;
};
2023-03-16 23:36:17 +05:30
2023-03-29 21:48:55 +05:30
"scripts/volume_up.sh" =
let
wpctl = "${pkgs.wireplumber}/bin/wpctl";
in
{
executable = true;
text = ''
#!/bin/sh
2023-03-16 23:36:17 +05:30
2023-03-29 21:48:55 +05:30
set -eu
2023-03-16 23:36:17 +05:30
2023-03-29 21:48:55 +05:30
${wpctl} set-mute @DEFAULT_AUDIO_SINK@ 0
[ $(${wpctl} get-volume @DEFAULT_AUDIO_SINK@ | awk -F': ' '{print $2}' | sed 's/\.//') -lt 100 ] && ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 5%+
'';
};
2023-03-16 23:36:17 +05:30
2023-03-29 21:48:55 +05:30
"scripts/tmux_sessions.sh" =
let
kitty = "${pkgs.kitty}/bin/kitty";
tmux = "${pkgs.tmux}/bin/tmux";
in
{
executable = true;
text = ''
#!/bin/sh
2023-03-16 23:36:17 +05:30
2023-03-29 21:48:55 +05:30
set -eu
2023-03-16 23:36:17 +05:30
2023-03-29 21:48:55 +05:30
SESSION="$(${tmux} list-sessions -F "(#{session_attached}) #S [#{pane_current_command} in #{pane_current_path}] #{pane_title}" | sort | ${dmenu} -p "Running TMUX Sessions" | awk '{print $2}')"
case "$SESSION" in
"")
;;
*)
${kitty} ${tmux} -u attach-session -dEt "$SESSION"
;;
esac'';
};
2023-03-15 22:11:59 +05:30
};
}