feat(sway): cleanup

This commit is contained in:
winston 2024-09-08 02:14:51 +02:00
parent ded6d601af
commit 96a2ec0dac
Signed by: winston
GPG key ID: 3786770EDBC2B481
4 changed files with 263 additions and 263 deletions

View file

@ -6,6 +6,15 @@
... ...
}: }:
let let
condition = (
builtins.elem osConfig.dotfiles.desktop [
"hyprland"
"sway"
"swayfx"
]
);
isSwayFx = osConfig.dotfiles.desktop == "swayfx";
fonts = { fonts = {
names = [ names = [
"IBM Plex Sans" "IBM Plex Sans"
@ -21,9 +30,20 @@ let
red = "#f38ba8"; red = "#f38ba8";
mauve = "#cba6f7"; mauve = "#cba6f7";
}; };
mod = "Mod4";
modMove = "${mod}+Shift";
modFocus = "${mod}+Ctrl";
hyper = "Mod4+Mod1+Shift+Ctrl";
filebrowser = lib.getExe pkgs.nautilus;
playerctl = lib.getExe pkgs.playerctl;
screenshot = "${lib.getExe pkgs.sway-contrib.grimshot} copy area";
swayosd-client = "${pkgs.swayosd}/bin/swayosd-client";
swayosd-server = "${pkgs.swayosd}/bin/swayosd-server";
in in
{ {
config = lib.mkIf (osConfig.dotfiles.desktop == "sway") { config = lib.mkIf condition {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home = { home = {
@ -53,231 +73,215 @@ in
udiskie.enable = true; udiskie.enable = true;
}; };
wayland.windowManager.sway = wayland.windowManager.sway = {
let enable = true;
modifier = "Mod4"; package = null;
in checkConfig = false;
{ config = rec {
enable = true; modifier = mod;
package = null; focus.wrapping = "no";
checkConfig = false; focus.mouseWarping = "container";
config = rec { startup = [
inherit modifier; {
focus.wrapping = "no"; command = "${lib.getExe pkgs.autotiling} -l2";
focus.mouseWarping = "container"; always = true;
startup = [ }
{ { command = "1password --silent"; }
command = "${pkgs.autotiling}/bin/autotiling -l2"; {
always = true; command = ''
} swayidle -w \
{ command = "1password --silent"; } timeout 180 'swaylock -f' \
{ timeout 360 'swaymsg "output * dpms off"' \
command = '' resume 'swaymsg "output * dpms on"' \
swayidle -w \ before-sleep 'swaylock -f'
timeout 180 'swaylock -f' \ '';
timeout 360 'swaymsg "output * dpms off"' \ always = true;
resume 'swaymsg "output * dpms on"' \ }
before-sleep 'swaylock -f' {
''; command = swayosd-server;
always = true; always = true;
} }
{ { command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; }
command = "${pkgs.swayosd}/bin/swayosd-server"; ];
always = true; workspaceAutoBackAndForth = true;
} # TODO: change this back to wezterm whenever it works on sway
{ command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; } terminal = lib.getExe config.programs.kitty.package;
]; menu = lib.getExe config.programs.rofi.package;
workspaceAutoBackAndForth = true; defaultWorkspace = "workspace number 1";
# TODO: change this back to wezterm whenever it works on sway input."type:keyboard".xkb_options = "ctrl:nocaps,compose:ralt";
terminal = lib.getExe config.programs.kitty.package; output."*" = {
menu = lib.getExe config.programs.rofi.package; scale = "2";
defaultWorkspace = "workspace number 1"; bg = "${../wallpapers/dhm_1610.png} fill #171320";
input."type:keyboard".xkb_options = "ctrl:nocaps,compose:ralt";
output."*" = {
scale = "2";
bg = "${../wallpapers/dhm_1610.png} fill #171320";
};
keybindings =
let
mod = modifier;
modMove = "${mod}+Shift";
modFocus = "${mod}+Ctrl";
hyper = "Mod4+Mod1+Shift+Ctrl";
filebrowser = lib.getExe pkgs.nautilus;
screenshot = "${lib.getExe pkgs.sway-contrib.grimshot} copy area";
playerctl = lib.getExe pkgs.playerctl;
swayosd = pkgs.swayosd + "/bin/swayosd-client";
in
{
"${mod}+Shift+b" = "border none";
"${mod}+b" = "border pixel 2";
"${mod}+n" = "border normal";
# reload the configuration file
"${mod}+Shift+r" = "reload";
# kill focused window
"${mod}+Shift+q" = "kill";
# Start Applications
"${mod}+Shift+Return" = "exec ${terminal}";
"${mod}+e" = "exec --no-startup-id ${filebrowser}";
"${hyper}+p" = "exec --no-startup-id ${screenshot}";
# change focus
"${modFocus}+h" = "focus left";
"${modFocus}+j" = "focus down";
"${modFocus}+k" = "focus up";
"${modFocus}+l" = "focus right";
"${modFocus}+Left" = "focus left";
"${modFocus}+Down" = "focus down";
"${modFocus}+Up" = "focus up";
"${modFocus}+Right" = "focus right";
# move focus
"${modMove}+h" = "move left";
"${modMove}+j" = "move down";
"${modMove}+k" = "move up";
"${modMove}+l" = "move right";
"${modMove}+Left" = "move left";
"${modMove}+Down" = "move down";
"${modMove}+Up" = "move up";
"${modMove}+Right" = "move right";
# move workspaces across monitors
"${modMove}+greater" = "move workspace to output right";
"${modMove}+less" = "move workspace to output left";
# split orientation
"${mod}+q" = "split toggle";
# toggle fullscreen mode for the focused container
"${mod}+f" = "fullscreen toggle";
# change container layout (stacked, tabbed, toggle split)
"${mod}+s" = "layout toggle";
# toggle tiling / floating
"${mod}+Shift+d" = "floating toggle";
# change focus between tiling / floating windows
"${mod}+d" = "focus mode_toggle";
# toggle sticky
"${mod}+Shift+s" = "sticky toggle";
# focus the parent container
"${mod}+a" = "focus parent";
# move the currently focused window to the scratchpad
"${mod}+Shift+Tab" = "move scratchpad";
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
"${mod}+Tab" = "scratchpad show";
"${mod}+m" = "[class=\"discord\"] scratchpad show";
# switch to workspace
"${modFocus}+1" = "workspace 1";
"${modFocus}+2" = "workspace 2";
"${modFocus}+3" = "workspace 3";
"${modFocus}+4" = "workspace 4";
"${modFocus}+5" = "workspace 5";
"${modFocus}+6" = "workspace 6";
"${modFocus}+7" = "workspace 7";
"${modFocus}+8" = "workspace 8";
"${modFocus}+9" = "workspace 9";
"${modFocus}+0" = "workspace 10";
# Move to workspace with focused container
"${modMove}+1" = "move container to workspace 1; workspace 1";
"${modMove}+2" = "move container to workspace 2; workspace 2";
"${modMove}+3" = "move container to workspace 3; workspace 3";
"${modMove}+4" = "move container to workspace 4; workspace 4";
"${modMove}+5" = "move container to workspace 5; workspace 5";
"${modMove}+6" = "move container to workspace 6; workspace 6";
"${modMove}+7" = "move container to workspace 7; workspace 7";
"${modMove}+8" = "move container to workspace 8; workspace 8";
"${modMove}+9" = "move container to workspace 9; workspace 9";
"${modMove}+0" = "move container to workspace 10; workspace 10";
# rofi instead of drun
"${mod}+space" = "exec --no-startup-id ${menu} -show drun -dpi $dpi";
# 1password
"${mod}+Shift+space" = "exec ${pkgs._1password-gui}/bin/1password --quick-access";
# audio
"XF86AudioRaiseVolume" = "exec ${swayosd} --output-volume 5";
"XF86AudioLowerVolume" = "exec ${swayosd} --output-volume -5";
"XF86AudioMute" = "exec ${swayosd} --output-volume mute-toggle";
"XF86AudioNext" = "exec --no-startup-id ${playerctl} next";
"XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous";
"XF86AudioPlay" = "exec --no-startup-id ${playerctl} play-pause";
# modes
"${mod}+r" = "mode \"resize\"";
"${mod}+p" = "mode \"power: (l)ock, (e)xit, (r)eboot, (s)uspend, (h)ibernate, (S)hut off\"";
};
modes = {
"power: (l)ock, (e)xit, (r)eboot, (s)uspend, (h)ibernate, (S)hut off" = {
l = "exec --no-startup-id swaylock --color 000000, mode \"default\"";
e = "exec --no-startup-id swaymsg exit, mode \"default\"";
r = "exec --no-startup-id systemctl reboot, mode \"default\"";
s = "exec --no-startup-id systemctl suspend, mode \"default\"";
h = "exec --no-startup-id systemctl hibernate, mode \"default\"";
"Shift+s" = "exec --no-startup-id systemctl poweroff, mode \"default\"";
Escape = "mode default";
Return = "mode default";
};
resize = {
Escape = "mode default";
Return = "mode default";
h = "resize shrink width 10 px or 10 ppt";
j = "resize grow height 10 px or 10 ppt";
k = "resize shrink height 10 px or 10 ppt";
l = "resize grow width 10 px or 10 ppt";
R = "resize set 50 ppt 50 ppt";
};
};
inherit fonts;
colors = rec {
focused = {
background = ctp.base;
border = ctp.pink;
childBorder = ctp.pink;
indicator = ctp.pink;
inherit (ctp) text;
};
urgent = {
background = ctp.base;
border = ctp.red;
childBorder = ctp.red;
indicator = ctp.red;
inherit (ctp) text;
};
unfocused = {
background = ctp.base;
border = ctp.mauve;
childBorder = ctp.mauve;
indicator = ctp.mauve;
inherit (ctp) text;
};
focusedInactive = unfocused;
placeholder = unfocused;
};
window = {
titlebar = false;
hideEdgeBorders = "none";
border = 2;
};
gaps = {
inner = 5;
outer = 2;
};
bars = [
{
inherit fonts;
mode = "hide";
position = "top";
statusCommand = "${config.programs.i3status-rust.package}/bin/i3status-rs ~/.config/i3status-rust/config-top.toml";
}
];
}; };
keybindings = {
"${mod}+Shift+b" = "border none";
"${mod}+b" = "border pixel 2";
"${mod}+n" = "border normal";
# reload the configuration file
"${mod}+Shift+r" = "reload";
# kill focused window
"${mod}+Shift+q" = "kill";
# Start Applications
"${mod}+Shift+Return" = "exec ${terminal}";
"${mod}+e" = "exec --no-startup-id ${filebrowser}";
"${hyper}+p" = "exec --no-startup-id ${screenshot}";
extraConfig = '' # change focus
"${modFocus}+h" = "focus left";
"${modFocus}+j" = "focus down";
"${modFocus}+k" = "focus up";
"${modFocus}+l" = "focus right";
"${modFocus}+Left" = "focus left";
"${modFocus}+Down" = "focus down";
"${modFocus}+Up" = "focus up";
"${modFocus}+Right" = "focus right";
# move focus
"${modMove}+h" = "move left";
"${modMove}+j" = "move down";
"${modMove}+k" = "move up";
"${modMove}+l" = "move right";
"${modMove}+Left" = "move left";
"${modMove}+Down" = "move down";
"${modMove}+Up" = "move up";
"${modMove}+Right" = "move right";
# move workspaces across monitors
"${modMove}+greater" = "move workspace to output right";
"${modMove}+less" = "move workspace to output left";
# split orientation
"${mod}+q" = "split toggle";
# toggle fullscreen mode for the focused container
"${mod}+f" = "fullscreen toggle";
# change container layout (stacked, tabbed, toggle split)
"${mod}+s" = "layout toggle";
# toggle tiling / floating
"${mod}+Shift+d" = "floating toggle";
# change focus between tiling / floating windows
"${mod}+d" = "focus mode_toggle";
# toggle sticky
"${mod}+Shift+s" = "sticky toggle";
# focus the parent container
"${mod}+a" = "focus parent";
# move the currently focused window to the scratchpad
"${mod}+Shift+Tab" = "move scratchpad";
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
"${mod}+Tab" = "scratchpad show";
"${mod}+m" = "[class=\"discord\"] scratchpad show";
# switch to workspace
"${modFocus}+1" = "workspace 1";
"${modFocus}+2" = "workspace 2";
"${modFocus}+3" = "workspace 3";
"${modFocus}+4" = "workspace 4";
"${modFocus}+5" = "workspace 5";
"${modFocus}+6" = "workspace 6";
"${modFocus}+7" = "workspace 7";
"${modFocus}+8" = "workspace 8";
"${modFocus}+9" = "workspace 9";
"${modFocus}+0" = "workspace 10";
# Move to workspace with focused container
"${modMove}+1" = "move container to workspace 1; workspace 1";
"${modMove}+2" = "move container to workspace 2; workspace 2";
"${modMove}+3" = "move container to workspace 3; workspace 3";
"${modMove}+4" = "move container to workspace 4; workspace 4";
"${modMove}+5" = "move container to workspace 5; workspace 5";
"${modMove}+6" = "move container to workspace 6; workspace 6";
"${modMove}+7" = "move container to workspace 7; workspace 7";
"${modMove}+8" = "move container to workspace 8; workspace 8";
"${modMove}+9" = "move container to workspace 9; workspace 9";
"${modMove}+0" = "move container to workspace 10; workspace 10";
# rofi instead of drun
"${mod}+space" = "exec --no-startup-id ${menu} -show drun -dpi $dpi";
# 1password
"${mod}+Shift+space" = "exec ${lib.getExe pkgs._1password-gui} --quick-access";
# audio
"XF86AudioRaiseVolume" = "exec ${swayosd-client} --output-volume 5";
"XF86AudioLowerVolume" = "exec ${swayosd-client} --output-volume -5";
"XF86AudioMute" = "exec ${swayosd-client} --output-volume mute-toggle";
"XF86AudioNext" = "exec --no-startup-id ${playerctl} next";
"XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous";
"XF86AudioPlay" = "exec --no-startup-id ${playerctl} play-pause";
# modes
"${mod}+r" = "mode \"resize\"";
"${mod}+p" = "mode \"power: (l)ock, (e)xit, (r)eboot, (s)uspend, (h)ibernate, (S)hut off\"";
};
modes = {
"power: (l)ock, (e)xit, (r)eboot, (s)uspend, (h)ibernate, (S)hut off" = {
l = "exec --no-startup-id swaylock --color 000000, mode \"default\"";
e = "exec --no-startup-id swaymsg exit, mode \"default\"";
r = "exec --no-startup-id systemctl reboot, mode \"default\"";
s = "exec --no-startup-id systemctl suspend, mode \"default\"";
h = "exec --no-startup-id systemctl hibernate, mode \"default\"";
"Shift+s" = "exec --no-startup-id systemctl poweroff, mode \"default\"";
Escape = "mode default";
Return = "mode default";
};
resize = {
Escape = "mode default";
Return = "mode default";
h = "resize shrink width 10 px or 10 ppt";
j = "resize grow height 10 px or 10 ppt";
k = "resize shrink height 10 px or 10 ppt";
l = "resize grow width 10 px or 10 ppt";
R = "resize set 50 ppt 50 ppt";
};
};
inherit fonts;
colors = rec {
focused = {
background = ctp.base;
border = ctp.pink;
childBorder = ctp.pink;
indicator = ctp.pink;
inherit (ctp) text;
};
urgent = {
background = ctp.base;
border = ctp.red;
childBorder = ctp.red;
indicator = ctp.red;
inherit (ctp) text;
};
unfocused = {
background = ctp.base;
border = ctp.mauve;
childBorder = ctp.mauve;
indicator = ctp.mauve;
inherit (ctp) text;
};
focusedInactive = unfocused;
placeholder = unfocused;
};
window = {
titlebar = false;
hideEdgeBorders = "none";
border = 2;
};
gaps = lib.mkIf isSwayFx {
inner = 5;
outer = 2;
};
bars = [
{
inherit fonts;
position = "top";
statusCommand = "${lib.getExe config.programs.i3status-rust.package} ~/.config/i3status-rust/config-top.toml";
}
];
};
extraConfig =
''
for_window [floating] border pixel 2 for_window [floating] border pixel 2
# floating sticky # floating sticky
@ -305,10 +309,13 @@ in
# keep apps in scratchpad # keep apps in scratchpad
for_window [class="discord"] move scratchpad sticky for_window [class="discord"] move scratchpad sticky
# fullscreen apps inhibit idle
for_window [class=".*"] inhibit_idle fullscreen
set $mode_gaps Gaps: (o)uter, (i)nner set $mode_gaps Gaps: (o)uter, (i)nner
set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global) set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global) set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
bindsym ${modifier}+Shift+g mode "$mode_gaps" bindsym ${mod}+Shift+g mode "$mode_gaps"
mode "$mode_gaps" { mode "$mode_gaps" {
bindsym o mode "$mode_gaps_outer" bindsym o mode "$mode_gaps_outer"
@ -340,7 +347,8 @@ in
bindsym Return mode "$mode_gaps" bindsym Return mode "$mode_gaps"
bindsym Escape mode "default" bindsym Escape mode "default"
} }
''
+ lib.optionalString isSwayFx ''
shadows enable shadows enable
shadow_color #11111b99 shadow_color #11111b99
shadow_blur_radius 20 shadow_blur_radius 20
@ -351,13 +359,11 @@ in
blur enable blur enable
blur_passes 2 blur_passes 2
blur_radius 4 blur_radius 4
layer_effects "swaync-notification-window" blur enable; shadows enable; corner_radius 5;
''; '';
systemd = { systemd = {
enable = true; enable = true;
xdgAutostart = true; xdgAutostart = true;
};
}; };
};
}; };
} }

View file

@ -5,44 +5,28 @@
... ...
}: }:
let let
inherit (config.dotfiles) desktop;
condition = ( condition = (
builtins.elem config.dotfiles.desktop [ builtins.elem desktop [
"hyprland" "hyprland"
"sway" "sway"
"swayfx"
] ]
); );
binary =
{
swayfx = "sway";
sway = "sway";
hyprland = "hypr";
}
.${desktop} or (throw "greetd: desktop not supported");
in in
{ {
config = lib.mkIf condition { config = lib.mkIf condition {
programs.regreet = { services.greetd = {
enable = true; enable = true;
settings = { settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --cmd '${pkgs.dbus}/bin/dbus-run-session ${binary}'";
background = {
path = ../../../home/wallpapers/dhm_1610.png;
fit = "Cover";
};
GTK = {
cursor_theme_name = "macOS-Monterey";
font_name = "IBM Plex Sans 16";
icon_theme_name = "WhiteSur";
theme_name = "WhiteSur-Dark";
};
};
font.name = "IBM Plex Sans";
cursorTheme = {
name = "macOS-Monterey";
package = pkgs.apple-cursor;
};
iconTheme = {
name = "WhiteSur-Dark";
package = pkgs.whitesur-icon-theme;
};
theme = {
name = "WhiteSur-Dark";
package = pkgs.whitesur-gtk-theme;
};
}; };
services.gnome.gnome-keyring.enable = true; services.gnome.gnome-keyring.enable = true;
security.pam.services.greetd = { security.pam.services.greetd = {
enableGnomeKeyring = true; enableGnomeKeyring = true;

View file

@ -4,8 +4,17 @@
pkgs, pkgs,
... ...
}: }:
let
condition = (
builtins.elem config.dotfiles.desktop [
"hyprland"
"sway"
"swayfx"
]
);
in
{ {
config = lib.mkIf (config.dotfiles.desktop == "sway") { config = lib.mkIf condition {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# file management # file management
p7zip p7zip
@ -28,7 +37,7 @@
programs.sway = { programs.sway = {
enable = true; enable = true;
package = pkgs.swayfx; package = lib.mkIf (config.dotfiles.desktop == "swayfx") pkgs.swayfx;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
swaylock-effects swaylock-effects
swayidle swayidle
@ -61,8 +70,8 @@
"org.freedesktop.impl.portal.Settings" = [ "darkman" ]; "org.freedesktop.impl.portal.Settings" = [ "darkman" ];
}; };
extraPortals = with pkgs; [ extraPortals = with pkgs; [
darkman
xdg-desktop-portal-gtk xdg-desktop-portal-gtk
darkman
]; ];
wlr.enable = true; wlr.enable = true;
xdgOpenUsePortal = true; xdgOpenUsePortal = true;

View file

@ -74,6 +74,7 @@ rec {
"gnome" "gnome"
"hyprland" "hyprland"
"sway" "sway"
"swayfx"
] ]
); );
default = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null; default = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null;