config-perso/modules/desktop/sway.nix

280 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 =
{
pkgs,
...
}:
{
programs = {
wshowkeys.enable = true;
sway.enable = true;
dconf.enable = true;
};
2024-05-14 19:21:19 +02:00
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 =
{
pkgs,
lib,
...
}:
{
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";
};
file.".config/waybar" = {
source = ./waybar;
recursive = true;
};
2024-05-14 19:21:19 +02:00
};
2024-02-19 17:15:40 +01:00
2024-05-14 19:21:19 +02:00
programs.waybar.enable = 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 = {
2024-11-08 12:28:49 +01:00
base = true;
gtk = true;
2024-05-14 19:21:19 +02:00
};
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'';
2024-05-14 19:21:19 +02:00
in
rec {
window = {
border = 1;
titlebar = false;
};
2024-05-14 19:21:19 +02:00
gaps.smartBorders = "on";
modifier = "Mod4";
terminal = "alacritty";
input."type:keyboard".xkb_layout = "fr";
startup = [
2024-08-22 17:13:14 +02:00
# { command = "waybar -b bar-0"; }
2024-05-31 14:51:59 +02:00
{ command = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ on"; }
{ command = "${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_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-08-22 17:13:14 +02:00
# { command = "${lib.getExe pkgs.element-desktop}"; }
2024-05-14 19:21:19 +02:00
{ command = ''sh -c "sleep 2 && exec keepassxc"''; }
2024-09-23 14:10:05 +02:00
{
command = "alacritty --class weechat --title weechat --command ${pkgs.weechat}/bin/weechat";
}
2024-05-14 19:21:19 +02:00
];
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";
colors =
let
2024-11-08 08:26:07 +01:00
# black = "#000000";
2024-05-14 19:21:19 +02:00
dark = "#111111";
adark = "#111111BB";
aadark = "#11111177";
2024-11-08 08:26:07 +01:00
# highl = "#222222";
2024-05-14 19:21:19 +02:00
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";
2024-11-08 08:26:07 +01:00
"${modifier}+Shift+v" = "exec virt-manager";
2024-05-14 19:21:19 +02:00
"${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.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioLowerVolume" = "exec ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioMute" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"XF86AudioMicMute" = "exec ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
2024-05-14 19:21:19 +02:00
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
};
2024-02-19 17:15:40 +01:00
};
};
};
}