config-perso/modules/desktop/sway.nix

284 lines
10 KiB
Nix
Raw Normal View History

2024-02-19 17:15:40 +01:00
{
2024-05-14 19:21:19 +02:00
global =
{
config,
pkgs,
lib,
mods,
...
}:
{
programs.wshowkeys.enable = true;
programs.sway.enable = true;
services.dbus.packages = with pkgs; [ dconf ];
xdg.portal = {
enable = true;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
];
};
2024-02-19 17:15:40 +01:00
};
2024-05-14 19:21:19 +02:00
home =
{
config,
pkgs,
lib,
mods,
...
}:
{
xdg.configFile."sway/config".onChange = lib.mkForce "";
home.sessionVariables = {
MOZ_ENABLE_WAYLAND = "1";
MOZ_USE_XINPUT2 = "1";
SDL_VIDEODRIVER = "wayland";
QT_QPA_PLATFORM = "wayland";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
_JAVA_AWT_WM_NONREPARETING = "1";
XDG_SESSION_TYPE = "wayland";
XDG_CURRENT_DESKTOP = "sway";
};
2024-02-19 17:15:40 +01:00
2024-05-14 19:21:19 +02:00
programs.waybar.enable = true;
home.file.".config/waybar" = {
source = ./waybar;
recursive = true;
};
2024-02-19 17:15:40 +01:00
2024-05-14 19:21:19 +02:00
services.swayidle =
let
lockwall = pkgs.runCommand "lock_wall.jpg" { } ''
${pkgs.ffmpeg}/bin/ffmpeg -i ${./wall.jpg} -filter_complex 'gblur=sigma=3' $out -y
'';
in
2024-02-19 17:15:40 +01:00
{
2024-05-14 19:21:19 +02:00
enable = true;
timeouts = [
{
timeout = 300;
command = ''${pkgs.systemd}/bin/loginctl lock-session && ${pkgs.sway}/bin/swaymsg "output * dpms off"'';
resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * dpms on"'';
}
];
events = [
{
event = "before-sleep";
command = "${pkgs.systemd}/bin/loginctl lock-session";
}
{
event = "lock";
command = "${pkgs.swaylock}/bin/swaylock -f -i ${lockwall}";
}
];
};
2024-03-13 11:11:16 +01:00
2024-05-14 19:21:19 +02:00
wayland.windowManager.sway = {
enable = true;
xwayland = true;
wrapperFeatures = {
base = false;
gtk = false;
};
extraConfig = ''workspace 1'';
config =
let
menuCmd = "${pkgs.wofi}/bin/wofi --show drun -i | xargs swaymsg exec --";
2024-02-19 17:15:40 +01:00
exitMd = ''Exit Mode:| (l)Log out | (r)Reboot | (p)Poweroff'';
weechatCmd = pkgs.writeShellScript "weechat.sh" ''
2024-03-13 11:11:16 +01:00
nix-shell -p python3 python311Packages.dbus-python python311Packages.notify2 --run 'python ${./weenotify.py} -s' > /dev/null &
2024-02-19 17:15:40 +01:00
while true; do
ssh -R 5431:localhost:5431 weecat@watcher.kat -t screen -xaA -S weechat
sleep 1
done
'';
2024-05-14 19:21:19 +02:00
in
rec {
window.border = 1;
gaps.smartBorders = "on";
modifier = "Mod4";
terminal = "alacritty";
input."type:keyboard".xkb_layout = "fr";
startup = [
2024-05-31 14:51:59 +02:00
{ command = "waybar -b bar-0"; }
2024-05-14 19:21:19 +02:00
{ command = "${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ on"; }
2024-05-31 14:51:59 +02:00
{ command = "${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ on"; }
2024-02-19 17:15:40 +01:00
2024-05-14 19:21:19 +02:00
{ command = "discord"; }
{ command = "thunderbird"; }
{ command = "mattermost-desktop"; }
{ command = "signal-desktop --"; }
2024-05-31 14:51:59 +02:00
{ command = "${lib.getExe pkgs.element-desktop}"; }
2024-05-14 19:21:19 +02:00
{ command = ''sh -c "sleep 2 && exec keepassxc"''; }
{
command = "alacritty --class weechat --title weechat --command ${pkgs.bash}/bin/bash -c ${weechatCmd}";
}
];
assigns = {
"1" = [ { app_id = "firefox"; } ];
"9" = [ { app_id = "thunderbird"; } ];
"10" = [
{ class = "Mattermost"; }
{ class = "Signal"; }
{ class = "discord"; }
2024-05-31 14:51:59 +02:00
{ class = "Element"; }
2024-05-14 19:21:19 +02:00
{ app_id = "weechat"; }
];
};
bars = [
{
command = "waybar";
mode = "hide";
}
];
output."*".bg = "${./wall.jpg} fill";
seat."*"."hide_cursor" = "5000";
focus.wrapping = "yes";
window.titlebar = false;
colors =
let
black = "#000000";
dark = "#111111";
adark = "#111111BB";
aadark = "#11111177";
highl = "#222222";
gray = "#777777";
white = "#FFFFFF";
color = "#FFBB00";
urgent = "#FF0000";
in
{
focused = {
border = adark;
background = adark;
text = white;
indicator = color;
childBorder = color;
};
unfocused = {
border = aadark;
background = aadark;
text = gray;
indicator = dark;
childBorder = dark;
};
focusedInactive = {
border = adark;
background = adark;
text = gray;
indicator = dark;
childBorder = dark;
};
urgent = {
border = urgent;
background = urgent;
text = white;
indicator = urgent;
childBorder = urgent;
};
};
modes = {
"display" = {
"Left" = "output - transform 90";
"Down" = "output - transform normal";
"Up" = "output - transform 180";
"Right" = "output - transform 270";
2024-02-19 17:15:40 +01:00
2024-05-14 19:21:19 +02:00
"Shift+Left" = "output - transform flipped-90";
"Shift+Down" = "output - transform flipped";
"Shift+Up" = "output - transform flipped-180";
"Shift+Right" = "output - transform flipped-270";
"Escape" = ''mode default"'';
};
"resize" = {
"Left" = "resize shrink width 10px";
"Down" = "resize grow height 10px";
"Up" = "resize shrink height 10px";
"Right" = "resize grow width 10px";
"Escape" = ''mode default"'';
};
"${exitMd}" = {
"l" = "exec swaymsg exit";
"r" = "exec systemctl reboot";
"p" = "exec systemctl poweroff";
"Escape" = ''mode default"'';
};
};
keybindings = {
"${modifier}+Return" = "exec ${terminal}";
"${modifier}+q" = "kill";
"${modifier}+d" = "exec ${menuCmd}";
"${modifier}+Shift+f" = "exec firefox";
"${modifier}+Shift+c" = "reload";
"${modifier}+p" = ''exec ${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp -d)" - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png'';
"Print" = "exec ${pkgs.grim}/bin/grim - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png";
"${modifier}+x" = ''mode "display"'';
"${modifier}+r" = ''mode "resize"'';
2024-02-19 17:15:40 +01:00
2024-05-14 19:21:19 +02:00
"${modifier}+Shift+e" = ''mode "${exitMd}"'';
"${modifier}+l" = "exec ${pkgs.systemd}/bin/loginctl lock-session";
"Ctrl+Shift+l" = ''exec ${pkgs.grim}/bin/grim /tmp/t_lock.png && ${pkgs.swaylock}/bin/swaylock -f -i /tmp/t_lock.png'';
"${modifier}+Left" = "focus left";
"${modifier}+Down" = "focus down";
"${modifier}+Up" = "focus up";
"${modifier}+Right" = "focus right";
"${modifier}+ampersand" = "workspace 1";
"${modifier}+eacute" = "workspace 2";
"${modifier}+quotedbl" = "workspace 3";
"${modifier}+apostrophe" = "workspace 4";
"${modifier}+parenleft" = "workspace 5";
"${modifier}+minus" = "workspace 6";
"${modifier}+egrave" = "workspace 7";
"${modifier}+underscore" = "workspace 8";
"${modifier}+ccedilla" = "workspace 9";
"${modifier}+agrave" = "workspace 10";
"${modifier}+Shift+Left" = "move left";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Right" = "move right";
"${modifier}+Shift+ampersand" = "move container to workspace 1";
"${modifier}+Shift+eacute" = "move container to workspace 2";
"${modifier}+Shift+quotedbl" = "move container to workspace 3";
"${modifier}+Shift+apostrophe" = "move container to workspace 4";
"${modifier}+Shift+parenleft" = "move container to workspace 5";
"${modifier}+Shift+minus" = "move container to workspace 6";
"${modifier}+Shift+egrave" = "move container to workspace 7";
"${modifier}+Shift+underscore" = "move container to workspace 8";
"${modifier}+Shift+ccedilla" = "move container to workspace 9";
"${modifier}+Shift+agrave" = "move container to workspace 10";
"${modifier}+b" = "splith";
"${modifier}+v" = "splitv";
"${modifier}+Shift+s" = "layout stacking";
"${modifier}+w" = "layout tabbed";
"${modifier}+s" = "layout toggle split";
"${modifier}+f" = "fullscreen";
"${modifier}+Shift+space" = "floating toggle";
"${modifier}+space" = "focus mode toggle";
"${modifier}+z" = "focus parent";
"${modifier}+Shift+z" = "focus child";
"${modifier}+Shift+F1" = "move scratchpad";
"${modifier}+F1" = "scratchpad show";
"XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
"XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
"XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
};
2024-02-19 17:15:40 +01:00
};
};
};
}