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