adding scripts for sway
This commit is contained in:
parent
8be2695ed0
commit
5c0e62ba20
22
modules/applications/sway/scripts/brightness.nix
Normal file
22
modules/applications/sway/scripts/brightness.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
in pkgs.writeShellScriptBin "brightness.sh" ''
|
||||||
|
#! ${pkgs.bash}/bin/bash
|
||||||
|
function notify {
|
||||||
|
val="$(light | cut -d '.' -f 1)"
|
||||||
|
str="$val $(seq -s "▒" "$(($val / 5 ))" | sed 's/[0-9]//g' )"
|
||||||
|
icon=/etc/profiles/per-user/james/share/icons/kora/actions/16/contrast.svg
|
||||||
|
echo "$str"
|
||||||
|
notify-send "$str" -h string:x-canonical-private-synchronous:brightness -i $icon -t 1500
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
up)
|
||||||
|
${pkgs.light}/bin/light -A 5 ; notify ;;
|
||||||
|
down)
|
||||||
|
${pkgs.light}/bin/light -U 5 ; notify ;;
|
||||||
|
*)
|
||||||
|
echo "invalid command"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
''
|
12
modules/applications/sway/scripts/sway-entry.nix
Normal file
12
modules/applications/sway/scripts/sway-entry.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
in pkgs.writeShellScriptBin "sway-entry" ''
|
||||||
|
#! ${pkgs.bash}/bin/bash
|
||||||
|
|
||||||
|
# first import environment variables from the login manager
|
||||||
|
# function is currently deprecated. It should be rolled back in the future
|
||||||
|
systemctl --user import-environment
|
||||||
|
|
||||||
|
# then start the service
|
||||||
|
exec systemctl --user start sway.service
|
||||||
|
''
|
45
modules/applications/sway/scripts/volume.nix
Normal file
45
modules/applications/sway/scripts/volume.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
in pkgs.writeShellScriptBin "volume.sh" ''
|
||||||
|
#! ${pkgs.bash}/bin/bash
|
||||||
|
function get_volume {
|
||||||
|
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_mute {
|
||||||
|
amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function notify {
|
||||||
|
vol=$(get_volume)
|
||||||
|
str="$vol $(seq -s "▒" "$(($vol / 5 ))" | sed 's/[0-9]//g' )"
|
||||||
|
if is_mute ; then
|
||||||
|
icon=/etc/profiles/per-user/james/share/icons/kora/actions/16/audio-volume-muted.svg
|
||||||
|
else
|
||||||
|
if (( "$vol" == "0" )) ; then
|
||||||
|
icon=/etc/profiles/per-user/james/share/icons/kora/actions/16/audio-volume-off.svg
|
||||||
|
elif (( "$vol" < "30" )) ; then
|
||||||
|
icon=/etc/profiles/per-user/james/share/icons/kora/actions/16/audio-volume-low.svg
|
||||||
|
elif (( "$vol" < "60" )) ; then
|
||||||
|
icon=/etc/profiles/per-user/james/share/icons/kora/actions/16/audio-volume-medium.svg
|
||||||
|
else
|
||||||
|
icon=/etc/profiles/per-user/james/share/icons/kora/actions/16/audio-volume-high.svg
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "$str"
|
||||||
|
notify-send "$str" -h string:x-canonical-private-synchronous:volume -i $icon -t 1500
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
up)
|
||||||
|
pactl set-sink-volume @DEFAULT_SINK@ +5% ; notify ;;
|
||||||
|
down)
|
||||||
|
pactl set-sink-volume @DEFAULT_SINK@ -5% ; notify ;;
|
||||||
|
mute)
|
||||||
|
amixer set Master toggle > /dev/null ; notify ;;
|
||||||
|
*)
|
||||||
|
echo "invalid command"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
$(is_mute) ; echo $?
|
||||||
|
''
|
|
@ -7,6 +7,11 @@ let
|
||||||
"https://raw.githubusercontent.com/catppuccin/wallpapers/main/landscapes/evening-sky.png";
|
"https://raw.githubusercontent.com/catppuccin/wallpapers/main/landscapes/evening-sky.png";
|
||||||
sha256 = "sha256-fYMzoY3un4qGOSR4DMqVUAFmGGil+wUze31rLLrjcAc=";
|
sha256 = "sha256-fYMzoY3un4qGOSR4DMqVUAFmGGil+wUze31rLLrjcAc=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
brightness-sh = pkgs.callPackage ./scripts/brightness.nix { inherit pkgs; };
|
||||||
|
sway-entry = pkgs.callPackage ./scripts/sway-entry.nix { inherit pkgs; };
|
||||||
|
volume-sh = pkgs.callPackage ./scripts/volume.nix { inherit pkgs; };
|
||||||
|
scripts = [ brightness-sh sway-entry volume-sh ];
|
||||||
in with lib; {
|
in with lib; {
|
||||||
options = {
|
options = {
|
||||||
this.application.sway = {
|
this.application.sway = {
|
||||||
|
@ -80,18 +85,30 @@ in with lib; {
|
||||||
outer = 2;
|
outer = 2;
|
||||||
};
|
};
|
||||||
# And import and scripts as scene here would be good.
|
# And import and scripts as scene here would be good.
|
||||||
|
keybindings = mkOptionDefault {
|
||||||
|
XF86AudioMute = "exec ${volume-sh}/bin/volume.sh mute";
|
||||||
|
XF86AudioRaiseVolume = "exec ${volume-sh}/bin/volume.sh up";
|
||||||
|
XF86AudioLowerVolume = "exec ${volume-sh}/bin/volume.sh down";
|
||||||
|
XF86AudioPlay = "exec ${pkgs.playerctl}/bin/playerctl play";
|
||||||
|
XF86AudioPause = "exec ${pkgs.playerctl}/bin/playerctl pause";
|
||||||
|
XF86MonBrightnessUp = "exec ${brightness-sh}/bin/brightness.sh up";
|
||||||
|
XF86MonBrightnessDown =
|
||||||
|
"exec ${brightness-sh}/bin/brightness.sh down";
|
||||||
|
};
|
||||||
# https://github.com/gytis-ivaskevicius/nixfiles/blob/master/home-manager/i3-sway.nix
|
# https://github.com/gytis-ivaskevicius/nixfiles/blob/master/home-manager/i3-sway.nix
|
||||||
keybindings = mkOptionDefault { "Mod4+d" = ""; };
|
|
||||||
modifier = "Mod4";
|
modifier = "Mod4";
|
||||||
output = { "eDP-1" = { bg = "${wallpaper} fill"; }; };
|
output = { "eDP-1" = { bg = "${wallpaper} fill"; }; };
|
||||||
terminal = "${pkgs.kitty}/bin/kitty";
|
terminal = "${pkgs.kitty}/bin/kitty";
|
||||||
# https://rycee.gitlab.io/home-manager/options.html#opt-wayland.windowManager.sway.config.window.commands
|
# https://rycee.gitlab.io/home-manager/options.html#opt-wayland.windowManager.sway.config.window.commands
|
||||||
window = { };
|
# window = { };
|
||||||
|
startup = [{ command = "${pkgs.autotiling}/bin/autotiling"; }];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs;
|
||||||
|
[
|
||||||
autotiling
|
autotiling
|
||||||
|
batsignal
|
||||||
dmenu
|
dmenu
|
||||||
grim
|
grim
|
||||||
imagemagick
|
imagemagick
|
||||||
|
@ -102,25 +119,14 @@ in with lib; {
|
||||||
playerctl
|
playerctl
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
wofi
|
wofi
|
||||||
(writeTextFile {
|
] ++ scripts;
|
||||||
name = "sway-entry";
|
|
||||||
destination = "/bin/sway-entry";
|
|
||||||
executable = true;
|
|
||||||
text = ''
|
|
||||||
#! ${pkgs.bash}/bin/bash
|
|
||||||
|
|
||||||
# first import environment variables from the login manager
|
|
||||||
# function is currently deprecated. It should be rolled back in the future
|
|
||||||
systemctl --user import-environment
|
|
||||||
|
|
||||||
# then start the service
|
|
||||||
exec systemctl --user start sway.service
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.light.enable = true;
|
programs.light.enable = true;
|
||||||
|
programs.sway = {
|
||||||
|
enable = true;
|
||||||
|
wrapperFeatures.gtk = true;
|
||||||
|
};
|
||||||
|
|
||||||
systemd.user.targets.sway-session = {
|
systemd.user.targets.sway-session = {
|
||||||
description = "Sway compositor session";
|
description = "Sway compositor session";
|
||||||
|
|
Reference in New Issue
Block a user