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