From 2788dd7cd06e87b772f792f6f1d7331f15dd684d Mon Sep 17 00:00:00 2001 From: Ivan Dimitrov Date: Sun, 21 Apr 2024 16:51:49 +0300 Subject: [PATCH] config sway with nix --- modules/home/programs/sway/config | 142 ------------------------- modules/home/programs/sway/default.nix | 30 +++++- 2 files changed, 28 insertions(+), 144 deletions(-) delete mode 100644 modules/home/programs/sway/config diff --git a/modules/home/programs/sway/config b/modules/home/programs/sway/config deleted file mode 100644 index d9cac28..0000000 --- a/modules/home/programs/sway/config +++ /dev/null @@ -1,142 +0,0 @@ -set $mod Mod4 -set $left h -set $down j -set $up k -set $right l -set $term kitty -set $menu rofi -show run - -exec swaymsg "workspace 1; exec kitty" -exec swaymsg "workspace 2; exec firefox" - -# Start a terminal -bindsym $mod+Return exec $term - -# Kill focused window -bindsym $mod+Shift+c kill - -# Start your launcher -bindsym $mod+p exec $menu - -# Start rofi calc -bindsym $mod+r+c exec rofi -show calc - -# Resize windows with mod + mouse -floating_modifier $mod normal - -# Reload the configuration file -bindsym $mod+Shift+r reload - -# Take screenshot of area and screen respectively -bindsym $mod+Shift+a exec screenshot area -bindsym $mod+Shift+s exec screenshot - -# Lock screen -bindsym Alt+Shift+l exec swaylock - -# Toggle screen -bindsym Alt+Shift+t output "eDP-1" toggle - -# Exit sway (logs you out of your Wayland session) -bindsym $mod+Shift+q exec swaynag -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' -# -# Moving around: -# -bindsym $mod+$left focus left -bindsym $mod+$down focus down -bindsym $mod+$up focus up -bindsym $mod+$right focus right - -# Move the focused window with the same, but add Shift -bindsym $mod+Shift+$left move left -bindsym $mod+Shift+$down move down -bindsym $mod+Shift+$up move up -bindsym $mod+Shift+$right move right -# Ditto, with arrow keys -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right -# -# Workspaces: -# -# Switch to workspace -bindsym $mod+1 workspace number 1 -bindsym $mod+2 workspace number 2 -bindsym $mod+3 workspace number 3 -bindsym $mod+4 workspace number 4 -bindsym $mod+5 workspace number 5 -bindsym $mod+6 workspace number 6 -bindsym $mod+7 workspace number 7 -bindsym $mod+8 workspace number 8 -bindsym $mod+9 workspace number 9 -bindsym $mod+0 workspace number 10 -# Move focused container to workspace -bindsym $mod+Shift+1 move container to workspace number 1 -bindsym $mod+Shift+2 move container to workspace number 2 -bindsym $mod+Shift+3 move container to workspace number 3 -bindsym $mod+Shift+4 move container to workspace number 4 -bindsym $mod+Shift+5 move container to workspace number 5 -bindsym $mod+Shift+6 move container to workspace number 6 -bindsym $mod+Shift+7 move container to workspace number 7 -bindsym $mod+Shift+8 move container to workspace number 8 -bindsym $mod+Shift+9 move container to workspace number 9 -bindsym $mod+Shift+0 move container to workspace number 10 -# -# Layout stuff: -# -bindsym $mod+b splith -bindsym $mod+v splitv - -bindsym $mod+f fullscreen - -# Toggle the current focus between tiling and floating mode -bindsym $mod+Shift+t floating toggle - -# Swap focus between the tiling area and the floating area -bindsym $mod+t focus mode_toggle - -# Move focus to the parent container -bindsym $mod+a focus parent -# -# Scratchpad: -# -# Move the currently focused window to the scratchpad -bindsym $mod+Shift+minus move scratchpad - -# Show the next scratchpad window or hide the focused scratchpad window. -# If there are multiple scratchpad windows, this command cycles through them. -bindsym $mod+minus scratchpad show - -# -# Window styles: -# -# Focused window -client.focused #a6e3a1 #a6e3a1 #000000 #a6e3a1 - -# Focused but inactive window -client.focused_inactive #333333 #5f676a #ffffff #484e50 - -# Unfocused window -client.unfocused #333333 #222222 #888888 #292d2e - -# Urgent window -client.urgent #2f343a #900000 #ffffff #900000 - - -# Hide title bar -default_border none -default_floating_border none -titlebar_padding 1 -titlebar_border_thickness 0 - -input "*" -{ - xkb_layout us,bg - xkb_options grp:win_space_toggle - xkb_variant ,phonetic -} - -exec dbus-sway-environment - -include /etc/sway/config.d/* diff --git a/modules/home/programs/sway/default.nix b/modules/home/programs/sway/default.nix index 13b139c..2b0c305 100644 --- a/modules/home/programs/sway/default.nix +++ b/modules/home/programs/sway/default.nix @@ -2,7 +2,33 @@ wayland.windowManager.sway = { enable = true; systemd.enable = true; - config = null; - extraConfig = builtins.readFile ./config; + config = rec { + menu = "rofi -show run"; + terminal = "kitty"; + modifier = "Mod4"; + startup = [ + { command = "swaymsg 'workspace 1; exec kitty'"; } + { command = "swaymsg 'workspace 2; exec firefox'"; } + ]; + bars = [ ]; + window.titlebar = false; + keybindings = pkgs.lib.mkOptionDefault { + "${modifier}+p" = "exec ${menu}"; + "${modifier}+Shift+r" = "reload"; + "${modifier}+Shift+c" = "kill"; + "Alt+Shift+l" = "exec ${pkgs.swaylock}/bin/swaylock"; + "Alt+Shift+t" = "output 'eDP-1' toggle"; + }; + input = { + "*" = { + xkb_layout = "us,bg"; + xkb_options = "grp:win_space_toggle"; + xkb_variant = ",phonetic"; + }; + }; + }; + swaynag = { + enable = true; + }; }; }