#+title: Sway Configuration
* Variables
Use =super= as modifier key.
#+begin_src conf :tangle config
  set $mod Mod4
#+end_src

Use =vi= motions as directional inputs.
#+begin_src conf :tangle config
  set $left h
  set $down j
  set $up k
  set $right l
#+end_src

Use =foot= as default terminal.
#+begin_src conf :tangle config
  set $term foot
#+end_src

Use =wofi= as app launcher.
#+begin_src conf :tangle config
  set $menu wofi --show drun --allow-images
#+end_src

* Startup Application
Use =dbus= environment.
#+begin_src conf :tangle config
  exec --no-startup-id dbus-update-activation-environment --all
#+end_src

Use =mako= as notification daemon.
#+begin_src conf :tangle config
  exec mako
#+end_src

Launch PipeWire without =systemd=.
#+begin_src conf :tangle config
  exec gentoo-pipewire-launcher &
#+end_src

Launch =blueman-applet= as Bluetooth daemon.
#+begin_src conf :tangle config
  exec blueman-applet
#+end_src

Launch music player daemon.
#+begin_src conf :tangle config
  exec mpd
#+end_src

Launch =mpdscribble= as scrobbler daemon.
#+begin_src conf :tangle config
  exec mpdscribble
#+end_src

* Display
I use a vertical monitor on the left and horizontal monitor on the right.
#+begin_src conf :tangle config
  output HDMI-A-1 resolution 1920x1080 position 1080 140
  output HDMI-A-2 resolution 1920x1080 transform 90 position 0 0
#+end_src

Use the file at =~/.wallpaper= as my wallpaper.
#+begin_src conf :tangle config
  output * bg ~/.wallpaper fill
#+end_src

Remove borders from windows.
#+begin_src conf :tangle config
  default_border none
  default_floating_border none
  font pango:monospace 1
#+end_src

Use 10 pixel gaps.
#+begin_src conf :tangle config
  gaps inner 10
#+end_src

Use =waybar= as a top bar.
#+begin_src conf :tangle config
  bar {
      position top

      status_command waybar
      mode invisible
  }
#+end_src

* Input
Use pointer acceleration.
#+begin_src conf :tangle config
  input * {
      accel_profile "adaptive"
      pointer_accel -.5
  }
#+end_src

* Controls
Add ability to lock the screen with =swaylock=. Turn off the screen after 15 seconds on lock screen.
#+begin_src conf :tangle config
  bindsym $mod+Control+l exec swaylock --ignore-empty-password --show-failed-attempts --image ~/.wallpaper
  exec swayidle -w timeout 15 'if pgrep -x swaylock; then swaymsg "output * power off"; fi' resume 'swaymsg "output * power on"'
#+end_src

Add keybinding to open a terminal emulator.
#+begin_src conf :tangle config
  bindsym $mod+Return exec $term
#+end_src

Add keybinding for killing a window.
#+begin_src conf :tangle config
  bindsym $mod+Shift+q kill
#+end_src

Add keybinding for opening an app launcher.
#+begin_src conf :tangle config
  bindsym $mod+d exec $menu
#+end_src

Holding the modifier key allows moving a window.
#+begin_src conf :tangle config
  floating_modifier $mod normal
#+end_src

Add keybinding for reloading the configuration.
#+begin_src conf :tangle config
  bindsym $mod+Shift+c reload
#+end_src

Add keybinding to launch logout/power off/restart [[file:powerprompt.org][prompt]] which also activates with the power key.
#+begin_src conf :tangle config
  bindsym $mod+Shift+e exec bash ~/.config/sway/powerprompt
  bindsym XF86PowerOff exec bash ~/.config/sway/powerprompt
#+end_src

Change focus keybindings.
#+begin_src conf :tangle config
  bindsym $mod+$left focus left
  bindsym $mod+$down focus down
  bindsym $mod+$up focus up
  bindsym $mod+$right focus right

  bindsym $mod+Left focus left
  bindsym $mod+Down focus down
  bindsym $mod+Up focus up
  bindsym $mod+Right focus right
#+end_src

Move window keybindings.
#+begin_src conf :tangle config
  bindsym $mod+Shift+$left move left
  bindsym $mod+Shift+$down move down
  bindsym $mod+Shift+$up move up
  bindsym $mod+Shift+$right move right

  bindsym $mod+Shift+Left move left
  bindsym $mod+Shift+Down move down
  bindsym $mod+Shift+Up move up
  bindsym $mod+Shift+Right move right
#+end_src

Change workspace keybindings.
#+begin_src conf :tangle config
  bindsym $mod+1 workspace number 1
  bindsym $mod+2 workspace number 2
  bindsym $mod+3 workspace number 3
  bindsym $mod+4 workspace number 4
  bindsym $mod+5 workspace number 5
  bindsym $mod+6 workspace number 6
  bindsym $mod+7 workspace number 7
  bindsym $mod+8 workspace number 8
  bindsym $mod+9 workspace number 9
  bindsym $mod+0 workspace number 10
#+end_src

Move window to workspace keybindings.
#+begin_src conf :tangle config
  bindsym $mod+Shift+1 move container to workspace number 1
  bindsym $mod+Shift+2 move container to workspace number 2
  bindsym $mod+Shift+3 move container to workspace number 3
  bindsym $mod+Shift+4 move container to workspace number 4
  bindsym $mod+Shift+5 move container to workspace number 5
  bindsym $mod+Shift+6 move container to workspace number 6
  bindsym $mod+Shift+7 move container to workspace number 7
  bindsym $mod+Shift+8 move container to workspace number 8
  bindsym $mod+Shift+9 move container to workspace number 9
  bindsym $mod+Shift+0 move container to workspace number 10
#+end_src

Set split direction keybindings.
#+begin_src conf :tangle config
  bindsym $mod+v splith
  bindsym $mod+s splitv
#+end_src

Toggle layout keybindings.
#+begin_src conf :tangle config
  bindsym $mod+e layout toggle split
#+end_src

Define full screen keybinding.
#+begin_src conf :tangle config
  bindsym $mod+f fullscreen
#+end_src

Define toggle floating keybinding.
#+begin_src conf :tangle config
  bindsym $mod+Shift+space floating toggle
#+end_src

Move focus between floating and tiled layer keybinding.
#+begin_src conf :tangle config
  bindsym $mod+space focus mode_toggle
#+end_src

Focus on the parent window keybinding.
#+begin_src conf :tangle config
  bindsym $mod+a focus parent
#+end_src

Keybindings  to move a window to the scratchpad and back from it.
#+begin_src conf :tangle config
  bindsym $mod+Shift+minus move scratchpad
  bindsym $mod+minus scratchpad show
#+end_src

Add resize keybindings.
#+begin_src conf :tangle config
  mode "resize" {
      bindsym $left resize shrink width 10px
      bindsym $down resize grow height 10px
      bindsym $up resize shrink height 10px
      bindsym $right resize grow width 10px

      bindsym Left resize shrink width 10px
      bindsym Down resize grow height 10px
      bindsym Up resize shrink height 10px
      bindsym Right resize grow width 10px

      bindsym Return mode "default"
      bindsym Escape mode "default"
  }
  bindsym $mod+r mode "resize"
#+end_src

Add screenshot keybinding.
#+begin_src conf :tangle config
  bindsym $mod+Shift+s exec grim -g "$(slurp)" - | wl-copy
#+end_src

Add volume keybindings.
#+begin_src conf :tangle config
  bindsym XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
  bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
  bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
#+end_src

Add pause keybinding.
#+begin_src conf :tangle config
  bindsym XF86Eject exec mpc toggle
#+end_src

* Extras
Load extra configuration.
#+begin_src conf :tangle config
  include /etc/sway/config.d/*
#+end_src