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