2023-03-12 03:59:11 +00:00
|
|
|
{
|
|
|
|
options,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.aa.desktop.sway;
|
2023-03-30 05:11:22 +00:00
|
|
|
user_cfg = config.home-manager.users.${config.aa.user.name};
|
2023-03-12 18:14:43 +00:00
|
|
|
nag = "swaynag";
|
2023-03-19 15:16:10 +00:00
|
|
|
left = "h";
|
|
|
|
right = "l";
|
2023-06-24 15:17:36 +00:00
|
|
|
up = "k";
|
|
|
|
down = "j";
|
2023-03-19 15:16:10 +00:00
|
|
|
modifier = "Mod4";
|
|
|
|
|
|
|
|
# TODO: This assume I'll be using rofi and alacritty. Should make more
|
|
|
|
# generic.
|
|
|
|
menu = "rofi -show run";
|
|
|
|
terminal = "alacritty";
|
2023-09-09 21:02:35 +00:00
|
|
|
|
|
|
|
generate_grimshot_command = target: ''exec mkdir -p ~/screenshots && ${pkgs.sway-contrib.grimshot}/bin/grimshot --notify save ${target} ~/screenshots/"$(date -u --iso-8601=seconds)".png'';
|
2023-03-12 03:59:11 +00:00
|
|
|
in {
|
|
|
|
options.aa.desktop.sway = with types; {
|
|
|
|
enable = mkEnableOption "sway";
|
2023-03-30 05:11:22 +00:00
|
|
|
|
|
|
|
wallpaperPath = mkOption {
|
|
|
|
type = str;
|
|
|
|
default = "sway/wallpaper.jpg";
|
|
|
|
description = ''
|
|
|
|
Path to wallpaper, relative to config.home-home-manager.users.<username>.xdg.dataHome
|
|
|
|
'';
|
|
|
|
};
|
2023-03-12 03:59:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
aa.desktop.addons = {
|
|
|
|
alacritty.enable = true;
|
2023-03-20 01:50:22 +00:00
|
|
|
|
2023-03-12 03:59:11 +00:00
|
|
|
# TODO
|
|
|
|
# light
|
|
|
|
};
|
|
|
|
|
2023-05-28 02:25:52 +00:00
|
|
|
aa.system.fonts.enable = true;
|
|
|
|
|
2023-06-11 01:31:32 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
2024-03-23 05:27:45 +00:00
|
|
|
feh
|
2023-06-11 01:31:32 +00:00
|
|
|
grim
|
|
|
|
slurp
|
2023-07-22 17:05:56 +00:00
|
|
|
sway-contrib.grimshot
|
|
|
|
wev
|
2024-03-23 05:27:45 +00:00
|
|
|
wl-clipboard
|
|
|
|
xdg-desktop-portal-wlr
|
|
|
|
xdg-utils
|
2023-06-11 01:31:32 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# For screen sharing to work
|
|
|
|
xdg.portal = {
|
|
|
|
enable = true;
|
|
|
|
extraPortals = with pkgs; [xdg-desktop-portal-gtk];
|
|
|
|
wlr.enable = true;
|
2024-02-06 04:30:30 +00:00
|
|
|
config.common.default = "*";
|
2023-06-11 01:31:32 +00:00
|
|
|
};
|
2023-03-25 17:39:03 +00:00
|
|
|
|
2023-03-30 05:11:22 +00:00
|
|
|
aa.home.dataFile = {
|
|
|
|
${cfg.wallpaperPath}.source = ./wallpaper.jpg;
|
|
|
|
};
|
2023-03-12 03:59:11 +00:00
|
|
|
aa.home.extraOptions = {
|
|
|
|
wayland.windowManager.sway = {
|
2024-05-26 23:38:06 +00:00
|
|
|
# WORKAROUND: https://github.com/nix-community/home-manager/issues/5311
|
|
|
|
checkConfig = false;
|
|
|
|
|
2023-03-12 03:59:11 +00:00
|
|
|
enable = true;
|
|
|
|
swaynag.enable = true;
|
|
|
|
wrapperFeatures.gtk = true; # so that gtk works properly
|
2023-07-09 15:25:22 +00:00
|
|
|
systemd.enable = true; # needed this for screen sharing to work
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
config = {
|
2023-03-19 15:16:10 +00:00
|
|
|
inherit (terminal menu left right up down modifier);
|
2023-03-12 03:59:11 +00:00
|
|
|
workspaceAutoBackAndForth = true;
|
|
|
|
|
|
|
|
colors = {
|
|
|
|
focused = {
|
|
|
|
border = "#2B3C44";
|
|
|
|
background = "#4E3D45";
|
|
|
|
text = "#FFFFFF";
|
|
|
|
indicator = "#333333";
|
|
|
|
childBorder = "#000000";
|
|
|
|
};
|
|
|
|
focusedInactive = {
|
|
|
|
border = "#484848";
|
|
|
|
background = "#333333";
|
|
|
|
text = "#FFFFFF";
|
|
|
|
indicator = "#000000";
|
|
|
|
childBorder = "#000000";
|
|
|
|
};
|
|
|
|
unfocused = {
|
|
|
|
border = "#484848";
|
|
|
|
background = "#333333";
|
|
|
|
text = "#FFFFFF";
|
|
|
|
indicator = "#000000";
|
|
|
|
childBorder = "#000000";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
window = {
|
|
|
|
titlebar = true;
|
|
|
|
commands = [
|
|
|
|
{
|
|
|
|
command = "inhibit_idle fullscreen";
|
|
|
|
criteria = {class = ".*";};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
focus.followMouse = false;
|
|
|
|
|
|
|
|
fonts = {
|
|
|
|
names = ["Hack Nerd Font"];
|
|
|
|
size = 10.0;
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: Should this live at the system configuration level?
|
|
|
|
output = {
|
2023-03-30 05:11:22 +00:00
|
|
|
"*".bg = "${user_cfg.xdg.dataHome}/${cfg.wallpaperPath} fill";
|
2024-07-27 06:57:24 +00:00
|
|
|
"eDP-1".scale = "1";
|
2024-02-19 04:28:49 +00:00
|
|
|
"Dell Inc. DELL S2721QS 4FR7M43".position = "0 0";
|
|
|
|
"Dell Inc. DELL S2721QS 47W7M43".position = "0 2160";
|
2023-03-12 03:59:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
modes = {
|
|
|
|
resize = {
|
|
|
|
# left will shrink the containers width
|
|
|
|
# right will grow the containers width
|
|
|
|
# up will shrink the containers height
|
|
|
|
# down will grow the containers height
|
2023-03-19 15:16:10 +00:00
|
|
|
"${left}" = "resize shrink width 50px";
|
|
|
|
"${down}" = "resize grow height 50px";
|
|
|
|
"${up}" = "resize shrink height 50px";
|
|
|
|
"${right}" = "resize grow width 50px";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
# Ditto, with arrow keys
|
|
|
|
"Left" = "resize shrink width 50px";
|
|
|
|
"Down" = "resize grow height 50px";
|
|
|
|
"Up" = "resize shrink height 50px";
|
|
|
|
"Right" = "resize grow width 50px";
|
|
|
|
|
|
|
|
# Exit resize mode
|
|
|
|
"Insert" = "mode default";
|
|
|
|
"Escape" = "mode default";
|
|
|
|
"Return" = "mode default";
|
|
|
|
};
|
|
|
|
|
|
|
|
nag = {
|
|
|
|
"Ctrl+d" = "mode default";
|
|
|
|
|
|
|
|
"Ctrl+c" = "exec ${nag} --exit";
|
|
|
|
"q" = "exec ${nag} --exit";
|
|
|
|
"Escape" = "exec ${nag} --exit";
|
|
|
|
|
|
|
|
"Return" = "exec ${nag} --confirm";
|
|
|
|
|
|
|
|
"j" = "exec ${nag} --next";
|
|
|
|
"Tab" = "exec ${nag} --next";
|
|
|
|
"Up" = "exec ${nag} --next";
|
|
|
|
|
|
|
|
"k" = "exec ${nag} --prev";
|
|
|
|
"Shift+Tab" = "exec ${nag} prev";
|
|
|
|
"Down" = "exec ${nag} prev";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
keybindings = {
|
|
|
|
# Activate modes
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+s" = "mode resize";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
# Misc
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Return" = "exec ${terminal}";
|
|
|
|
"${modifier}+c" = "kill";
|
|
|
|
"${modifier}+p" = "exec ${menu}";
|
|
|
|
"${modifier}+z" = "reload";
|
2023-03-26 15:39:28 +00:00
|
|
|
"${modifier}+x" = "exec swaylock";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
# Volume control
|
|
|
|
"XF86AudioRaiseVolume" = " exec 'pamixer --increase 5'";
|
|
|
|
"XF86AudioLowerVolume" = " exec 'pamixer --decrease 5'";
|
|
|
|
"XF86AudioMute" = " exec 'pamixer --toggle-mute'";
|
|
|
|
|
|
|
|
# Music player control
|
|
|
|
"XF86AudioPrev" = "exec 'playerctl previous'";
|
|
|
|
"XF86AudioNext" = "exec 'playerctl next'";
|
|
|
|
"XF86AudioPlay" = "exec 'playerctl play-pause'";
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Down" = "exec 'playerctl pause'";
|
|
|
|
"${modifier}+Up" = "exec 'playerctl play'";
|
|
|
|
"${modifier}+Right" = "exec 'playerctl next'";
|
|
|
|
"${modifier}+Left" = "exec 'playerctl previous'";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
# Backlight keys
|
|
|
|
"XF86MonBrightnessDown" = "exec 'light -U 5'";
|
|
|
|
"XF86MonBrightnessUp" = "exec 'light -A 5'";
|
|
|
|
|
|
|
|
# Navigation
|
|
|
|
|
|
|
|
## Focus
|
|
|
|
|
|
|
|
### Move your focus around
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+${left}" = "focus left";
|
|
|
|
"${modifier}+${down}" = "focus down";
|
|
|
|
"${modifier}+${up}" = "focus up";
|
|
|
|
"${modifier}+${right}" = "focus right";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
### Move the focused window with the same, but add Shift
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Shift+${left}" = "move left";
|
|
|
|
"${modifier}+Shift+${down}" = "move down";
|
|
|
|
"${modifier}+Shift+${up}" = "move up";
|
|
|
|
"${modifier}+Shift+${right}" = "move right";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## Workspaces
|
|
|
|
|
|
|
|
### Switch to a workspace
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+q" = "workspace number 1";
|
|
|
|
"${modifier}+w" = "workspace number 2";
|
|
|
|
"${modifier}+e" = "workspace number 3";
|
|
|
|
"${modifier}+r" = "workspace number 4";
|
|
|
|
"${modifier}+t" = "workspace number 5";
|
|
|
|
"${modifier}+y" = "workspace number 6";
|
|
|
|
"${modifier}+u" = "workspace number 7";
|
|
|
|
"${modifier}+i" = "workspace number 8";
|
|
|
|
"${modifier}+o" = "workspace number 9";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
### Move focused container to workspace
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Shift+q" = "move container to workspace number 1";
|
|
|
|
"${modifier}+Shift+w" = "move container to workspace number 2";
|
|
|
|
"${modifier}+Shift+e" = "move container to workspace number 3";
|
|
|
|
"${modifier}+Shift+r" = "move container to workspace number 4";
|
|
|
|
"${modifier}+Shift+t" = "move container to workspace number 5";
|
|
|
|
"${modifier}+Shift+y" = "move container to workspace number 6";
|
|
|
|
"${modifier}+Shift+u" = "move container to workspace number 7";
|
|
|
|
"${modifier}+Shift+i" = "move container to workspace number 8";
|
|
|
|
"${modifier}+Shift+o" = "move container to workspace number 9";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
# Layout
|
|
|
|
|
|
|
|
## Split direction
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+v" = "splith";
|
|
|
|
"${modifier}+g" = "splitv";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## Switch the current container between different layout styles
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+b" = "layout stacking";
|
|
|
|
"${modifier}+n" = "layout tabbed";
|
|
|
|
"${modifier}+m" = "layout toggle split";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## Make the current focus fullscreen
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+f" = "fullscreen";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## move container between displays
|
2024-02-19 04:28:49 +00:00
|
|
|
"${modifier}+semicolon" = "move workspace to output up";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## Toggle the current focus between tiling and floating mode
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Shift+f" = "floating toggle";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## Swap focus between the tiling area and the floating area
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+space" = "focus mode_toggle";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
## Move focus to the parent container
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+a" = "focus parent";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
2024-07-11 03:16:16 +00:00
|
|
|
# Notifications
|
|
|
|
|
|
|
|
## Toggle notification center
|
|
|
|
"${modifier}+Shift+n" = "exec '${pkgs.swaynotificationcenter}/bin/swaync-client -t -sw'";
|
|
|
|
|
|
|
|
## Toggle Do Not Disturb
|
|
|
|
"${modifier}+Shift+d" = "exec '${pkgs.swaynotificationcenter}/bin/swaync-client -d -sw'";
|
|
|
|
|
2023-07-22 17:05:56 +00:00
|
|
|
# Screenshots
|
|
|
|
|
|
|
|
## Current window
|
2023-09-09 21:02:35 +00:00
|
|
|
"${modifier}+period" = generate_grimshot_command "active";
|
2023-07-22 17:05:56 +00:00
|
|
|
|
|
|
|
## Area selection
|
2023-09-09 21:02:35 +00:00
|
|
|
"${modifier}+Shift+period" = generate_grimshot_command "area";
|
2023-07-22 17:05:56 +00:00
|
|
|
|
|
|
|
## Current output
|
2023-09-09 21:02:35 +00:00
|
|
|
"${modifier}+Alt+period" = generate_grimshot_command "output";
|
2023-07-22 17:05:56 +00:00
|
|
|
|
|
|
|
## Window selection
|
2023-09-09 21:02:35 +00:00
|
|
|
"${modifier}+Ctrl+period" = generate_grimshot_command "window";
|
2023-07-22 17:05:56 +00:00
|
|
|
|
2023-03-12 03:59:11 +00:00
|
|
|
# Scratchpad
|
|
|
|
# Move the currently focused window to the scratchpad
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Shift+minus" = "move scratchpad";
|
2023-03-12 03:59:11 +00:00
|
|
|
# Show the next scratchpad window or hide the focused scratchpad window.
|
|
|
|
# If there are multiple scratchpad windows, this command cycles through them.
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+minus" = "scratchpad show";
|
2023-03-12 03:59:11 +00:00
|
|
|
|
|
|
|
# Exit sway (logs you out of your Wayland session)
|
2023-03-19 15:16:10 +00:00
|
|
|
"${modifier}+Shift+z" = "exec ${nag} -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit' -b 'Reload' 'swaymsg reload'";
|
2023-03-12 03:59:11 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|