blob: 97ac8b2d0bb85aa6c2119c5986298c4d4c210829 [file] [log] [blame]
Copybara botca5ce642024-11-08 17:38:08 +01001# Read `man 5 sway` for a complete reference.
2
3### Variables
4#
5# Logo key. Use Mod1 for Alt.
6set $mod Mod4
7# Home row direction keys, like vim
8set $left h
9set $down j
10set $up k
11set $right l
12# Your preferred terminal emulator
13set $term foot
14# Your preferred application launcher
15# Note: pass the final command to swaymsg so that the resulting window can be opened
16# on the original workspace that the command was run on.
17#set $menu dmenu_path | wmenu | xargs swaymsg exec --
18set $menu rofi -show drun | xargs swaymsg exec --
19set $menuDrun rofi -show run | xargs swaymsg exec --
20set $menuSsh rofi -show ssh | xargs swaymsg exec --
21set $menuWindows rofi -show window | xargs swaymsg exec --
22set $menuPower rofi -show power-menu -modi power-menu:rofi-power-menu | xargs swaymsg exec --
23set $menuClipboard rofi -show clipboard -modi clipboard:~/bin/cliphist-rofi-img -show-icons | xargs swaymsg exec --
24
Adrià Vilanova Martínez04ad82a2024-11-19 20:43:24 +010025# See https://github.com/flameshot-org/flameshot/blob/14a136777cd82ab70f42c13b4bc9418c756d91d2/docs/Sway%20and%20wlroots%20support.md
26set $flameshotCmd SDL_VIDEODRIVER=wayland _JAVA_AWT_WM_NONREPARENTING=1 QT_QPA_PLATFORM=wayland XDG_CURRENT_DESKTOP=sway XDG_SESSION_DESKTOP=sway flameshot
27set $flameshotGuiCmd $flameshotCmd gui
28
Adrià Vilanova533fa8a2024-10-06 19:19:20 +020029{{ if eq .chezmoi.hostname "pixelbook" -}}
Copybara botca5ce642024-11-08 17:38:08 +010030set $internalScreen "Sharp Corporation LQ123P1JX32 Unknown"
Copybara botca5ce642024-11-08 17:38:08 +010031
32set $internalKeyboard "4012:2782:keyd_virtual_keyboard"
Adrià Vilanova533fa8a2024-10-06 19:19:20 +020033{{- end }}
34{{ if eq .env "work" -}}
35set $internalScreen "Chimei Innolux Corporation 0x143F Unknown"
36set $P12GRAN304Screen "Dell Inc. DELL P2214H 29C293AA1DRL"
37
38set $internalKeyboard "1:1:AT_Translated_Set_2_keyboard"
39{{- end }}
40
41set $auxScreen "LG Electronics LG Ultra HD 0x0000D4DC"
Adrià Vilanova Martínez45f04e12024-11-19 20:43:24 +010042set $portableScreen "GWD ARZOPA 000000000000"
43
Copybara botca5ce642024-11-08 17:38:08 +010044set $macKeyboard "1452:598:Apple_Wireless_Keyboard"
Copybara botca5ce642024-11-08 17:38:08 +010045
46### Output configuration
47#
48# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
49output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_2048x1536.png fill
50#
51# Example configuration:
52#
53# output HDMI-A-1 resolution 1920x1080 position 1920,0
54#
55# You can get the names of your outputs by running: swaymsg -t get_outputs
56
57{{ if eq .chezmoi.hostname "pixelbook" -}}
58output $internalScreen {
59 mode 2400x1600@59.982Hz
Adrià Vilanova Martínez45f04e12024-11-19 20:43:24 +010060 pos 0 165
61 scale 1.75
Copybara botca5ce642024-11-08 17:38:08 +010062}
63
64output $auxScreen {
65 mode 1920x1080@60.000Hz
Adrià Vilanova Martínez45f04e12024-11-19 20:43:24 +010066 pos 1372 0
67}
68
69output $portableScreen {
70 mode 1920x1080@60.000Hz
71 pos -1920 0
Copybara botca5ce642024-11-08 17:38:08 +010072}
73
74workspace 1 output $internalScreen
75workspace 10 output $auxScreen $internalScreen
76{{- end }}
77
Adrià Vilanova533fa8a2024-10-06 19:19:20 +020078{{ if eq .env "work" -}}
79output $internalScreen {
80 mode 1920x1200@60.003Hz
81 pos 1920 0
82}
83
84output $auxScreen {
85 mode 1920x1080@60.000Hz
86 pos 3840 0
87}
88
89output $P12GRAN304Screen {
90 mode 1920x1080@60.000Hz
91 pos 0 0
92}
93{{- end }}
94
Copybara botca5ce642024-11-08 17:38:08 +010095### Idle configuration
96#
97# Example configuration:
98#
99# exec swayidle -w \
100# timeout 300 'swaylock -f -c 000000' \
101# timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
102# before-sleep 'swaylock -f -c 000000'
103#
104# This will lock your screen after 300 seconds of inactivity, then turn off
105# your displays after another 300 seconds, and turn your screens back on when
106# resumed. It will also lock your screen before your computer goes to sleep.
107
108### Input configuration
109#
110# Example configuration:
111#
112# input "2:14:SynPS/2_Synaptics_TouchPad" {
113# dwt enabled
114# tap enabled
115# natural_scroll enabled
116# middle_emulation enabled
117# }
118#
119# You can get the names of your inputs by running: swaymsg -t get_inputs
120# Read `man 5 sway-input` for more information about this section.
121
122### Key bindings
123#
124# Basics:
125#
126 # Start a terminal
127 bindsym $mod+Return exec $term
128
129 # Kill focused window
130 bindsym $mod+Shift+q kill
131
132 # Start the launcher launcher
133 bindsym $mod+d exec $menu
134
135 # Other menus
136 bindsym $mod+Shift+d exec $menuDrun
137 bindsym $mod+g exec $menuSsh
138 bindsym $mod+Shift+g exec $menuWindows
139 bindsym $mod+c exec $menuClipboard
140 bindsym $mod+Shift+s exec $menuPower
141
142 # Drag floating windows by holding down $mod and left mouse button.
143 # Resize them with right mouse button + $mod.
144 # Despite the name, also works for non-floating windows.
145 # Change normal to inverse to use left mouse button for resizing and right
146 # mouse button for dragging.
147 floating_modifier $mod normal
148
149 # Reload the configuration file
150 bindsym $mod+Shift+c reload
151
152 # Exit sway (logs you out of your Wayland session)
153 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'
154#
155# Moving around:
156#
157 # Move your focus around
158 bindsym $mod+$left focus left
159 bindsym $mod+$down focus down
160 bindsym $mod+$up focus up
161 bindsym $mod+$right focus right
162 # Or use $mod+[up|down|left|right]
163 bindsym $mod+Left focus left
164 bindsym $mod+Down focus down
165 bindsym $mod+Up focus up
166 bindsym $mod+Right focus right
167
168 # Move the focused window with the same, but add Shift
169 bindsym $mod+Shift+$left move left
170 bindsym $mod+Shift+$down move down
171 bindsym $mod+Shift+$up move up
172 bindsym $mod+Shift+$right move right
173 # Ditto, with arrow keys
174 bindsym $mod+Shift+Left move left
175 bindsym $mod+Shift+Down move down
176 bindsym $mod+Shift+Up move up
177 bindsym $mod+Shift+Right move right
178#
179# Workspaces:
180#
181 # Switch to workspace
182 bindsym $mod+1 workspace number 1
183 bindsym $mod+2 workspace number 2
184 bindsym $mod+3 workspace number 3
185 bindsym $mod+4 workspace number 4
186 bindsym $mod+5 workspace number 5
187 bindsym $mod+6 workspace number 6
188 bindsym $mod+7 workspace number 7
189 bindsym $mod+8 workspace number 8
190 bindsym $mod+9 workspace number 9
191 bindsym $mod+0 workspace number 10
192 # Move focused container to workspace
193 bindsym $mod+Shift+1 move container to workspace number 1
194 bindsym $mod+Shift+2 move container to workspace number 2
195 bindsym $mod+Shift+3 move container to workspace number 3
196 bindsym $mod+Shift+4 move container to workspace number 4
197 bindsym $mod+Shift+5 move container to workspace number 5
198 bindsym $mod+Shift+6 move container to workspace number 6
199 bindsym $mod+Shift+7 move container to workspace number 7
200 bindsym $mod+Shift+8 move container to workspace number 8
201 bindsym $mod+Shift+9 move container to workspace number 9
202 bindsym $mod+Shift+0 move container to workspace number 10
Adrià Vilanova533fa8a2024-10-06 19:19:20 +0200203 # Move workspaces around outputs
204 bindsym $mod+Control+Shift+$right move workspace to output right
205 bindsym $mod+Control+Shift+$left move workspace to output left
206 bindsym $mod+Control+Shift+$down move workspace to output down
207 bindsym $mod+Control+Shift+$up move workspace to output up
208 bindsym $mod+Control+Shift+Right move workspace to output right
209 bindsym $mod+Control+Shift+Left move workspace to output left
210 bindsym $mod+Control+Shift+Down move workspace to output down
211 bindsym $mod+Control+Shift+Up move workspace to output up
Copybara botca5ce642024-11-08 17:38:08 +0100212 # Note: workspaces can have any name you want, not just numbers.
213 # We just use 1-10 as the default.
214#
215# Layout stuff:
216#
217 # You can "split" the current object of your focus with
218 # $mod+b or $mod+v, for horizontal and vertical splits
219 # respectively.
220 bindsym $mod+b splith
221 bindsym $mod+v splitv
222
223 # Switch the current container between different layout styles
224 bindsym $mod+s layout stacking
225 bindsym $mod+w layout tabbed
226 bindsym $mod+e layout toggle split
227
228 # Make the current focus fullscreen
229 bindsym $mod+f fullscreen
230
231 # Toggle the current focus between tiling and floating mode
232 bindsym $mod+Shift+space floating toggle
233
234 # Swap focus between the tiling area and the floating area
235 bindsym $mod+space focus mode_toggle
236
237 # Move focus to the parent container
238 bindsym $mod+a focus parent
239#
240# Scratchpad:
241#
242 # Sway has a "scratchpad", which is a bag of holding for windows.
243 # You can send windows there and get them back later.
244
245 # Move the currently focused window to the scratchpad
246 bindsym $mod+Shift+minus move scratchpad
247
248 # Show the next scratchpad window or hide the focused scratchpad window.
249 # If there are multiple scratchpad windows, this command cycles through them.
250 bindsym $mod+minus scratchpad show
251
252#
253# Custom keybindings:
254#
255 bindsym Control+Shift+Comma exec flatpak run it.mijorus.smile
256
257# Sound
258 bindsym XF86AudioRaiseVolume exec wpctl set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ 5%+
259 bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
260 bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
261 bindsym XF86AudioPlay exec playerctl play-pause
262 bindsym XF86AudioPause exec playerctl play-pause
263 bindsym XF86AudioNext exec playerctl next
264 bindsym XF86AudioPrev exec playerctl previous
265
266# Brightness
267 bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
268 bindsym XF86MonBrightnessUp exec brightnessctl set 5%+
269 bindsym Alt+XF86MonBrightnessDown exec brightnessctl --device='chromeos::kbd_backlight' set 5%-
270 bindsym Alt+XF86MonBrightnessUp exec brightnessctl --device='chromeos::kbd_backlight' set 5%+
271
272# Menu
273 bindsym XF86Tools exec $menu
274 bindsym XF86LaunchB exec $menu
275
276# Notifications
277 bindsym $mod+X exec makoctl dismiss
278 bindsym $mod+Shift+X exec makoctl restore
279 bindsym $mod+Z exec makoctl dismiss -a
280
Adrià Vilanova Martínez04ad82a2024-11-19 20:43:24 +0100281# Print screen
282 bindsym Print exec $flameshotGuiCmd
283 bindsym XF86LaunchA exec $flameshotGuiCmd
284 bindsym $mod+P exec $flameshotGuiCmd
285
Copybara botca5ce642024-11-08 17:38:08 +0100286#
287# Resizing containers:
288#
289mode "resize" {
290 # left will shrink the containers width
291 # right will grow the containers width
292 # up will shrink the containers height
293 # down will grow the containers height
294 bindsym $left resize shrink width 10px
295 bindsym $down resize grow height 10px
296 bindsym $up resize shrink height 10px
297 bindsym $right resize grow width 10px
298
299 # Ditto, with arrow keys
300 bindsym Left resize shrink width 10px
301 bindsym Down resize grow height 10px
302 bindsym Up resize shrink height 10px
303 bindsym Right resize grow width 10px
304
305 # Return to default mode
306 bindsym Return mode "default"
307 bindsym Escape mode "default"
308}
309bindsym $mod+r mode "resize"
310
311#
312# Status Bar:
313#
314# Read `man 5 sway-bar` for more information about this section.
315bar {
316 position top
317
318 status_command SCRIPT_DIR=~/.config/i3blocks i3blocks
319
320 colors {
321 statusline #ffffff
322 background #323232
323 inactive_workspace #32323200 #32323200 #5c5c5c
324 }
325}
326
327include /etc/sway/config.d/*
328
329input type:touchpad {
330 tap enabled
331 natural_scroll enabled
332}
333
334input type:pointer {
335 natural_scroll enabled
336}
337
Adrià Vilanova Martínez576508a2024-12-27 20:06:39 +0100338input type:keyboard {
339 xkb_layout es,us
Adrià Vilanova Martínez860b7402024-12-30 22:59:44 +0100340 xkb_options grp:rctrl_toggle
Adrià Vilanova Martínez576508a2024-12-27 20:06:39 +0100341}
342
Copybara botca5ce642024-11-08 17:38:08 +0100343{{ if eq .chezmoi.hostname "pixelbook" -}}
344input $internalKeyboard {
345 xkb_layout us,es
346 xkb_options grp:rctrl_toggle
347}
348
Copybara botca5ce642024-11-08 17:38:08 +0100349input type:tablet_tool {
350 map_to_output $internalScreen
351}
352
353input type:touch {
354 map_to_output $internalScreen
355}
356{{- end }}
Adrià Vilanova533fa8a2024-10-06 19:19:20 +0200357{{ if eq .env "work" -}}
Adrià Vilanova533fa8a2024-10-06 19:19:20 +0200358input $internalKeyboard {
359 xkb_layout es,us
360 xkb_options grp:alt_space_toggle
361}
362{{- end }}
363
364input $macKeyboard {
365 xkb_layout es,us
366 xkb_options grp:rwin_toggle
367}
Copybara botca5ce642024-11-08 17:38:08 +0100368
369font pango:monospace 10
370
371# @source: https://www.reddit.com/r/swaywm/comments/16nutle/comment/k1ig9b6/
372# @source: https://gitlab.com/that1communist/dotfiles/-/blob/master/.config/sway/modules/win-rules
373# NOTE: You can get app_id's with `swaymsg -t get_tree`
374for_window {
375 [window_role="pop-up"] floating enable
376 [window_role="About"] floating enable
377 [window_role="bubble"] floating enable
378 [window_role="dialog"] floating enable
379 [window_type="dialog"] floating enable
380
381 [title="(?:Open|Save) (?:File|Folder|As)"] floating enable, resize set width 1030 height 710
382
383 [app_id="org.gnome.Calculator"] floating enable
384 [app_id="it.mijorus.smile"] floating enable
385 # See https://wiki.archlinux.org/index.php?title=Flameshot&oldid=813985#Flameshot_does_not_work_on_all_monitors_of_a_multi-monitor_setup_in_Sway
Adrià Vilanova Martínez45f04e12024-11-19 20:43:24 +0100386{{ if eq .chezmoi.hostname "pixelbook" -}}
Copybara botca5ce642024-11-08 17:38:08 +0100387 [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
Adrià Vilanova Martínez45f04e12024-11-19 20:43:24 +0100388{{- else -}}
389 [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
390{{- end }}
Copybara botca5ce642024-11-08 17:38:08 +0100391
392 [title=".* is sharing your screen"] move window to scratchpad
393 [app_id="chrome-pjibgclleladliembfgfagdaldikeohf-.*"] move window to workspace 10; workspace 10
394 [app_id="chrome-aoocenepihlidnmnheodnngihilbadfo-.*"] move window to workspace 10; workspace 10
395}
396
397exec mako
398
399# See https://github.com/emersion/xdg-desktop-portal-wlr/blob/d9ada849aeca6137915de2df69beaef4e272cc1d/README.md#running
400exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
401
Adrià Vilanova Martínez04ad82a2024-11-19 20:43:24 +0100402exec $flameshotCmd
Copybara botca5ce642024-11-08 17:38:08 +0100403
Adrià Vilanova Martínezfccd64d2024-11-19 20:43:24 +0100404exec wl-paste --watch cliphist store -max-items 10
Copybara botca5ce642024-11-08 17:38:08 +0100405
Adrià Vilanova Martínez1ad86d02024-11-19 20:43:24 +0100406exec safeeyes
407
Copybara botca5ce642024-11-08 17:38:08 +0100408# See https://wiki.archlinux.org/title/Sway#Idle
409exec swayidle -w \
410 timeout 235 'swaymsg "output * power off"' \
411 resume 'swaymsg "output * power on"' \
412 timeout 240 'swaylock -f' \
413 timeout 300 'systemctl sleep' \
414 before-sleep 'playerctl pause; swaylock -f'