### BITTE DIESE DATEI NUR MIT FOLGENDEM BEFEHL BEARBEITEN ###
# chezmoi edit .config/sway/config

set $mod Mod1

# https://man.archlinux.org/man/sway.5.en
# https://wiki.archlinux.org/title/Sway
# https://i3wm.org/docs/userguide.html
# https://github.com/swaywm/sway/wiki
# https://github.com/swayos/swayos.github.io/blob/main/home/.config/sway/config

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
#font pango:monospace 12
#font pango:Terminus (TTF) Bold 12
font pango:"Hack Nerd Font" 9

set $bg-color            #2f343f
set $inactive-bg-color   #2f343f
set $text-color          #f3f4f5
set $inactive-text-color #676E7D
set $urgent-bg-color     #E53935

# window colors
#                       border              background         text                 indicat>
client.focused          $bg-color           $bg-color          $text-color          #00ff00
client.unfocused        $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00
client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color #00ff00
client.urgent $urgent-bg-color $urgent-bg-color $text-color #00ff00

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# start a terminal
bindsym $mod+Return exec wezterm

# kill focused window
bindsym $mod+Shift+q kill

# Menu
bindsym $mod+d exec fuzzel
bindsym $mod+Shift+d exec j4-dmenu-desktop --dmenu="~/.config/sway/bemenu-run.sh -l 30" --term="wezterm" --no-generic
bindsym $mod+y exec clipman pick --tool=CUSTOM --tool-args="fuzzel -d"
bindsym $mod+Shift+y exec ~/.config/fuzzel/fuzzel-pass.sh

# Notification Menu
bindsym $mod+Shift+n exec swaync-client -t -sw

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+odiaeresis focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+odiaeresis move right

# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

bindsym --no-repeat $mod+1 workspace number 1; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+2 workspace number 2; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+3 workspace number 3; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+4 workspace number 4; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+5 workspace number 5; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+6 workspace number 6; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+7 workspace number 7; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+8 workspace number 8; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+9 workspace number 9; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+0 workspace number 10; exec "echo 1 > /tmp/sov"

bindsym --no-repeat $mod+Ctrl+1 workspace number 11; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+2 workspace number 12; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+3 workspace number 13; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+4 workspace number 14; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+5 workspace number 15; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+6 workspace number 16; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+7 workspace number 17; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+8 workspace number 18; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+9 workspace number 19; exec "echo 1 > /tmp/sov"
bindsym --no-repeat $mod+Ctrl+0 workspace number 20; exec "echo 1 > /tmp/sov"

bindsym --release $mod+1 exec "echo 0 > /tmp/sov"
bindsym --release $mod+2 exec "echo 0 > /tmp/sov"
bindsym --release $mod+3 exec "echo 0 > /tmp/sov"
bindsym --release $mod+4 exec "echo 0 > /tmp/sov"
bindsym --release $mod+5 exec "echo 0 > /tmp/sov"
bindsym --release $mod+6 exec "echo 0 > /tmp/sov"
bindsym --release $mod+7 exec "echo 0 > /tmp/sov"
bindsym --release $mod+8 exec "echo 0 > /tmp/sov"
bindsym --release $mod+9 exec "echo 0 > /tmp/sov"
bindsym --release $mod+0 exec "echo 0 > /tmp/sov"

bindsym --release $mod+Ctrl+1 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+2 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+3 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+4 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+5 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+6 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+7 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+8 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+9 exec "echo 0 > /tmp/sov"
bindsym --release $mod+Ctrl+0 exec "echo 0 > /tmp/sov"

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

# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r reload

bindsym $mod+r mode "resize"

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 Return mode "default"
    bindsym Escape mode "default"
}

input * {
      dwt enabled
      tap enabled
      natural_scroll disabled
      middle_emulation enabled

      # Flat (deactivated) or adaptative (activated)
      accel_profile adaptive

      # Between -1.0 and 1.0
      pointer_accel 0.4

      repeat_rate 100
      repeat_delay 250
      xkb_layout de
      xkb_variant nodeadkeys
      xkb_options grp:alt_space_toggle
}

bar {
    swaybar_command waybar
}

seat seat0 xcursor_theme capitaine-cursors 16

#
# gaps
#
gaps inner 5
smart_gaps off

#
# Titlebars
#
font pango:"Hack Nerd Font" 9
default_border pixel 3
smart_borders on
default_floating_border normal
hide_edge_borders none
titlebar_border_thickness 0


#
# Below is SwayFX extensions
#

blur on
smart_corner_radius on
corner_radius 10
default_dim_inactive 0.2

# display resoulution

# machine-specific configuration
{{- if eq .chezmoi.hostname "SpectreOS" }}
output eDP-1 pos 0 0 res 1920x1080
{{- end }}

{{- if eq .chezmoi.hostname "SpectreOS-deck" }}
output eDP-1 mode 800x1200 transform 90
input 10248:4117:FTS3528:00_2808:1015 map_to_output eDP-1
exec opensdd
{{- end }}

set $gnome-schema org.gnome.desktop.interface
exec_always {
    gsettings set $gnome-schema cursor-theme capitaine-cursors
    gsettings set $gnome-schema gtk-theme Arc-Dark
    gsettings set $gnome-schema icon-theme Papirus-Dark
    gsettings set $gnome-schema font-name 'Cantarell 12'
    gsettings set org.gnome.desktop.wm.preferences theme "Arc-Dark"
    gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
    gsettings set org.gnome.desktop.default-applications.terminal exec wezterm
    gsettings set org.gnome.desktop.default-applications.terminal exec-arg start
}

# background
output "*" background ~/desktop-bilder/background.jpg fill

# You can get the names of your inputs by running: swaymsg -t get_inputs
# Read `man 5 sway-input` for more information about this section.


# Benutzerdefiniert

# Fenster zu einem Scratchpad
bindsym $mod+Shift+minus move scratchpad
# Zeige das scratcpad window
bindsym $mod+minus scratchpad show

# Starte Programme über Tastaurkombination

# Press $mod+o followed by either c to launch chromium,
# Escape or Return to the default mode, respectively.
set $mode_launcher Launch: [c]hromium [p]avucontrol [w]displays [f]ilemanager
bindsym $mod+o mode "$mode_launcher"

mode "$mode_launcher" {
    bindsym c exec chromium, mode "default"
    bindsym p exec pavucontrol-qt, mode "default"
    bindsym w exec wdisplays, mode "default"
    bindsym f exec pcmanfm-qt, mode "default"

    bindsym Escape mode "default"
    bindsym Return mode "default"
}

bindsym $mod+b exec chromium
bindsym $mod+t exec pcmanfm-qt
bindsym $mod+n exec wezterm start nmtui

# Einstellungen für spezielle Programme (exact match instead of substring)
# Remmina (swaymsg -t get_tree)

for_window [app_id="foot"] border pixel 1
for_window [app_id="iwgtk"] floating enable
for_window [app_id="blueman-manager"] floating enable
for_window [app_id="blueman-manager"] resize set 1000 600
for_window [app_id="org.gnome.Nautilus"] floating enable
for_window [app_id="gnome-system-monitor"] floating enable; resize shrink down 100px; resize shrink up 100px
for_window [app_id="wdisplays"] floating enable
for_window [app_id="wdisplays"] resize set 1000 600
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="pavucontrol"] resize set 1000 600
for_window [app_id="pavucontrol-qt"] floating enable
for_window [app_id="pavucontrol-qt"] resize set 1000 600
#for_window [app_id="pcmanfm"] floating enable
#for_window [app_id="pcmanfm"] resize set 1000 600
#for_window [app_id="pcmanfm-qt"] floating enable
#for_window [app_id="pcmanfm-qt"] resize set 1000 600
for_window [app_id="lxqt-archiver"] floating enable
for_window [app_id="lxqt-archiver"] resize set 1000 600
for_window [app_id="lxqt-policykit-agent"] floating enable
for_window [app_id="lxqt-policykit-agent"] resize set 1000 600
for_window [app_id="imv"] floating enable
for_window [app_id="pamac-manager"] floating enable
for_window [app_id="org.remmina.Remmina"] floating enable
for_window [app_id="org.remmina.Remmina"] resize set 1000 600
for_window [app_id="nm-applet"] floating enable
for_window [app_id="nm-applet"] resize set 1000 600
for_window [app_id="nm-connection-editor"] floating enable
for_window [app_id="nm-connection-editor"] resize set 1000 600

bindsym XF86MonBrightnessDown exec brightnessctl set 5%- | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > /tmp/wob
bindsym XF86MonBrightnessUp exec brightnessctl set +5% | sed -En 's/.*\(([0-9]+)%\).*/\1/p' > /tmp/wob

bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && pamixer --get-volume > /tmp/wob
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && pamixer --get-volume > /tmp/wob

bindsym $mod+XF86AudioPlay exec "echo 1 > /tmp/vmp"
bindsym $mod+XF86AudioNext exec "echo 2 > /tmp/vmp"
bindsym $mod+XF86AudioPrev exec "echo 3 > /tmp/vmp"

bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym XF86Search exec fuzzel

# monitor-picture
# 1. Capture a Selection
bindsym Print exec grim -g "$(slurp)" $(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S_grim.png')
# 2. Capture the actually Display
bindsym Shift+Print exec grim $(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S_grim.png')

bindsym $mod+p exec wlogout -p layer-shell
bindsym --no-repeat $mod+Shift+p exec "echo 2 > /tmp/wcp"

# swaylock
bindsym $mod+shift+x exec swaylock -c 000000

# exit sway (logs you out of your Wayland session)
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'

# Power control script - a useful replacement for the normal i3 exiting keybind.
# https://wiki.archlinux.org/index.php/i3#Shutdown.2C_reboot.2C_lock_screen
set $mode_system System (1) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (d) shutdown
mode "$mode_system" {
    bindsym 1 exec ~/.config/sway/swayexit lock, mode "default"
    bindsym e exec ~/.config/sway/swayexit logout, mode "default"
    bindsym s exec ~/.config/sway/swayexit suspend, mode "default"
    bindsym h exec ~/.config/sway/swayexit hibernate, mode "default"
    bindsym r exec ~/.config/sway/swayexit reboot, mode "default"
    bindsym d exec ~/.config/sway/swayexit shutdown, mode "default"
    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+x mode "$mode_system"

## Manual management of external displays
# Set the shortcuts and what they do
set $mode_display Ext Screen (v) eDP ON, (h) DP ON, (x) eDP OFF, (y) DP OFF
mode "$mode_display" {
    bindsym v exec swaymsg output eDP-1 enable && swaymsg output eDP-1 pos 1920 280 res 1920x1080, mode "default"
    bindsym h exec swaymsg output DP-1 enable && swaymsg output DP-1 pos 0 0 res 1920x1080, mode "default"
    bindsym x exec swaymsg output eDP-1 disable, mode "default"
    bindsym y exec swaymsg output DP-1 disable, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+m mode "$mode_display"

# For use a Virtual VNC Connection with wayvnc
#swaymsg create_output

# springen von Workspace zu workspace mit oder ohne container
workspace_auto_back_and_forth yes
bindsym $mod+z workspace back_and_forth
bindsym $mod+Shift+z move container to workspace back_and_forth; workspace back_and_forth

# Networkmanager
exec nm-applet

# Bluetooth
exec blueman-applet

# Start mako-notifyd Service
#exec "mako -c .config/mako/config"

# Start swaync notify Service
exec swaync

# authentication manager https://wiki.archlinux.org/title/Polkit
exec /usr/bin/lxqt-policykit-agent

# Clipboard Manager
exec wl-paste -t text --watch clipman store

exec swayidle -w \
         timeout 300 'swaylock -f' \
         timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f'

exec rm -f /tmp/wob && mkfifo /tmp/wob && tail -f /tmp/wob | wob
exec rm -f /tmp/sov && mkfifo /tmp/sov && tail -f /tmp/sov | sov -t 200
exec rm -f /tmp/wcp && mkfifo /tmp/wcp && tail -f /tmp/wcp | wcp -f 300x190 -m 20 -a rt

#xwayland disable

include /etc/sway/config.d/*

exec notify-send "loaded" "Welcome to sway."
