This repository has no description
9.9 kB
291 lines
1{ config, lib, pkgs, ... }: let
2
3 term = "/run/current-system/sw/bin/alacritty";
4
5in {
6 imports = [
7 ../lib/wayland.nix
8 ];
9 programs.sway = {
10 enable = true;
11 wrapperFeatures.gtk = true;
12 };
13
14 environment.etc."sway/config".text = ''
15 # Default config for sway
16 #
17 # Copy this to ~/.config/sway/config and edit it to your liking.
18 #
19 # Read `man 5 sway` for a complete reference.
20
21 ### Variables
22 #
23 # Logo key. Use Mod1 for Alt.
24 set $mod Mod4
25 # Home row direction keys, like vim
26 set $left h
27 set $down j
28 set $up k
29 set $right l
30 # Your preferred terminal emulator
31 set $term ${term}
32 # Your preferred application launcher
33 # Note: pass the final command to swaymsg so that the resulting window can be opened
34 # on the original workspace that the command was run on.
35 set $menu ${pkgs.dmenu}/bin/dmenu_path | fzfmenu | xargs swaymsg exec --
36
37 ### Output configuration
38 #
39 # Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
40 # output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
41 #
42 # Example configuration:
43 #
44 # output HDMI-A-1 resolution 1920x1080 position 1920,0
45 #
46 # You can get the names of your outputs by running: swaymsg -t get_outputs
47
48 ### Idle configuration
49 #
50 # Example configuration:
51 #
52 # exec swayidle -w \
53 # timeout 300 'swaylock -f -c 000000' \
54 # timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
55 # before-sleep 'swaylock -f -c 000000'
56 #
57 # This will lock your screen after 300 seconds of inactivity, then turn off
58 # your displays after another 300 seconds, and turn your screens back on when
59 # resumed. It will also lock your screen before your computer goes to sleep.
60
61 ### Input configuration
62 #
63 # Example configuration:
64 #
65 # input "2:14:SynPS/2_Synaptics_TouchPad" {
66 # dwt enabled
67 # tap enabled
68 # natural_scroll enabled
69 # middle_emulation enabled
70 # }
71 #
72 # You can get the names of your inputs by running: swaymsg -t get_inputs
73 # Read `man 5 sway-input` for more information about this section.
74
75 ### Key bindings
76 #
77 # Basics:
78 #
79 # Start a terminal
80 bindsym $mod+Shift+Return exec $term
81
82 # Kill focused window
83 bindsym $mod+Shift+c kill
84
85 # Start your launcher
86 bindsym $mod+d exec $menu
87
88 # Drag floating windows by holding down $mod and left mouse button.
89 # Resize them with right mouse button + $mod.
90 # Despite the name, also works for non-floating windows.
91 # Change normal to inverse to use left mouse button for resizing and right
92 # mouse button for dragging.
93 floating_modifier $mod normal
94
95 # Reload the configuration file
96 bindsym $mod+Shift+r reload
97
98 # Exit sway (logs you out of your Wayland session)
99 bindsym $mod+Shift+e 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'
100 #
101 # Moving around:
102 #
103 # Move your focus around
104 bindsym $mod+Left focus left
105 bindsym $mod+Down focus down
106 bindsym $mod+Up focus up
107 bindsym $mod+Right focus right
108
109 # Move the focused window with the same, but add Shift
110 bindsym $mod+Shift+Left move left
111 bindsym $mod+Shift+Down move down
112 bindsym $mod+Shift+Up move up
113 bindsym $mod+Shift+Right move right
114 # Layout stuff:
115 #
116 # You can "split" the current object of your focus with
117 # $mod+b or $mod+v, for horizontal and vertical splits
118 # respectively.
119 bindsym $mod+b splith
120 bindsym $mod+v splitv
121
122 # Switch the current container between different layout styles
123 bindsym $mod+s layout stacking
124 bindsym $mod+w layout tabbed
125 bindsym $mod+e layout toggle split
126
127 # Make the current focus fullscreen
128 bindsym $mod+f fullscreen
129
130 # Toggle the current focus between tiling and floating mode
131 bindsym $mod+Shift+space floating toggle
132
133 # Swap focus between the tiling area and the floating area
134 bindsym $mod+space focus mode_toggle
135
136 # Move focus to the parent container
137 bindsym $mod+Shift+a focus parent
138 #
139 # Scratchpad:
140 #
141 # Sway has a "scratchpad", which is a bag of holding for windows.
142 # You can send windows there and get them back later.
143
144 # Move the currently focused window to the scratchpad
145 bindsym $mod+Shift+minus move scratchpad
146
147 # Show the next scratchpad window or hide the focused scratchpad window.
148 # If there are multiple scratchpad windows, this command cycles through them.
149 bindsym $mod+minus scratchpad show
150 #
151 # Resizing containers:
152 #
153 mode "resize" {
154 # left will shrink the containers width
155 # right will grow the containers width
156 # up will shrink the containers height
157 # down will grow the containers height
158 bindsym $left resize shrink width 10px
159 bindsym $down resize grow height 10px
160 bindsym $up resize shrink height 10px
161 bindsym $right resize grow width 10px
162
163 # Ditto, with arrow keys
164 bindsym Left resize shrink width 10px
165 bindsym Down resize grow height 10px
166 bindsym Up resize shrink height 10px
167 bindsym Right resize grow width 10px
168
169 # Return to default mode
170 bindsym Return mode "default"
171 bindsym Escape mode "default"
172 }
173 bindsym $mod+r mode "resize"
174
175 #
176 # Status Bar:
177 #
178 # Read `man 5 sway-bar` for more information about this section.
179 bar {
180 position top
181
182 # When the status_command prints a new line to stdout, swaybar updates.
183 # The default just shows the current date and time.
184 status_command while date +'%Y-%m-%d %H:%M:%S'; do sleep 1; done
185
186 colors {
187 statusline #ffffff
188 background #323232
189 inactive_workspace #32323200 #32323200 #5c5c5c
190 }
191 }
192
193 default_border pixel 1
194 default_floating_border none
195 smart_borders on
196
197 bindsym $mod+q exec ${pkgs.writers.writeDash "goto_workspace" ''
198 set -efux
199 unset TERM # we want fzfmenu to start a new terminal
200 CURRENT_OUTPUT=$(swaymsg -r -t get_outputs | jq '.[] | select(.focused == true).name')
201 FZFMENU_FZF_DEFAULT_OPTS="--select-1"
202 WS=$(swaymsg -r -t get_workspaces |
203 jq -r '.[].name' |
204 fzfmenu -p 'Workspace name: '
205 )
206 if [ -n "$WS" ]; then
207 swaymsg workspace "$WS"
208 swaymsg move workspace to output "$CURRENT_OUTPUT"
209 fi
210 ''}
211
212 bindsym $mod+Shift+q exec ${pkgs.writers.writeDash "moveto_workspace" ''
213 set -efux
214 unset TERM # we want fzfmenu to start a new terminal
215 FZFMENU_FZF_DEFAULT_OPTS="--select-1"
216 WS=$(swaymsg -r -t get_workspaces |
217 jq -r '.[].name' |
218 fzfmenu -p 'Workspace name: '
219 )
220 if [ -n "$WS" ]; then
221 swaymsg move container to workspace "$WS"
222 fi
223 ''}
224
225 bindsym $mod+x exec ${./starter} floating enable -- ${pkgs.alacritty}/bin/alacritty --config-file /var/theme/config/alacritty.yaml
226 bindsym $mod+y exec /run/current-system/sw/bin/switch-theme toggle
227
228 for_window [title="fzfmenu"] floating enable
229 bindsym $mod+Tab focus next
230 bindsym $mod+Escape workspace back_and_forth
231
232 bindsym $mod+p exec ${pkgs.writers.writeDash "passmenu" ''
233 set -efux
234 unset TERM # we want fzfmenu to start a new terminal
235 (cd $HOME/.password-store; find -type f -name '*.gpg') |
236 sed -e 's/\.gpg$//' |
237 fzfmenu -p 'Password: ' |
238 xargs -I{} pass show {} |
239 tr -d '\n' |
240 ${pkgs.wtype}/bin/wtype -s 1 -
241 ''}
242 bindsym $mod+Shift+p exec ${pkgs.writers.writeDash "otpmenu" ''
243 unset TERM
244 ${pkgs.otpmenu}/bin/otpmenu
245 ''}
246
247 # screenlock
248 bindsym $mod+F11 exec ${pkgs.swaylock}/bin/swaylock -f -c 000000
249
250 # media buttons
251 bindsym XF86AudioMute exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-mute @DEFAULT_SINK@ toggle
252 bindsym XF86AudioRaiseVolume exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ +4%
253 bindsym XF86AudioLowerVolume exec ${pkgs.pulseaudio.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ -4%
254 bindsym XF86MonBrightnessDown exec ${pkgs.acpilight}/bin/xbacklight -time 0 -dec 1
255 bindsym XF86MonBrightnessUp exec ${pkgs.acpilight}/bin/xbacklight -time 0 -inc 1
256
257 # background programs
258 exec ydotoold
259 exec_always pkill kanshi; exec ${pkgs.kanshi}/bin/kanshi
260
261 # theme and env specific stuff
262 exec_always ${pkgs.writers.writeDash "dbus-sway-environment" ''
263 set -efux
264 dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
265 systemctl --user stop xdg-desktop-portal xdg-desktop-portal-wlr
266 systemctl --user start xdg-desktop-portal xdg-desktop-portal-wlr
267 ''}
268
269 exec_always ${let
270 schema = pkgs.gsettings-desktop-schemas;
271 datadir = "${schema}/share/gsettings-schemas/${schema.name}";
272 in pkgs.writers.writeDash "gsettings" ''
273 set -efux
274 export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}:$XDG_DATA_DIRS
275 gnome_schema=org.gnome.desktop.interface
276 gsettings set $gnome_schema gtk-theme 'Dracula'
277 ''}
278
279 # keyboard
280 input type:keyboard {
281 xkb_layout us
282 xkb_variant altgr-intl
283 xkb_options caps:hyper
284 }
285
286 # flameshot
287 for_window [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
288 exec ${pkgs.flameshot}/bin/flameshot
289 '';
290
291}