# Default config for sway

# TODO: https://github.com/Crandel/home/blob/master/.config/sway/config

## monitor:
# wlr-randr --output eDP-1 --pos 0,2160 --output DP-1 --pos 0,0

# COLORS
# nord:  $nf #4c566a$TR
# nord:  $nb #2e3440$TR
# nord:  $sf #ebcb8b$TR
set {
  $TR CC
  $nf #a5adce$TR
  $nb #303446$TR
  $sf #ebcb8b$TR
  $bf $nf
  $sb $nb
  $uf $sf
  $db $nb
}
set {
  $mod Mod1
  $left h
  $down j
  $up k
  $right l

  $term foot
  $menu ~/.local/bin/dmenu_run | xargs swaymsg exec --
  $clipmenu clipman pick --tool=CUSTOM -T "$HOME/.local/bin/dmenu_sh -p 'Clip:' -l 10"

# Mocha
  $bmenu bemenu-run --fb $nb --ff $nf --nb $nb --nf $nf --tb "#1e1e2e" --hb "#1e1e2e" --tf "#f38ba8" --hf $nf --af "#cdd6f4" --ab "#1e1e2e"
  # $bmenu bemenu-run --fb "#1e1e2e" --ff "#cdd6f4" --nb "#1e1e2e" --nf "#cdd6f4" --tb "#1e1e2e" --hb "#1e1e2e" --tf "#f38ba8" --hf "#f9e2af" --af "#cdd6f4" --ab "#1e1e2e"

  $screenshot grim -g "$(slurp)" - | swappy -f -
# ~/.local/bin/screenshot

  # outputs
  $out0 eDP-1
  $out1 DP-1

  $maximize border none, move position center, resize set width 100 ppt height 100 ppt
}



output {
  $out0 background    ~/sync/data/wall2.webp fill
  $out1 background    ~/sync/data/wall2.webp fill

  $out0 adaptive_sync on
  $out1 adaptive_sync on

  $out0 pos 0 2170 res 1920x1080@60Hz
  $out1 pos 0 0    res 3840x2160@60Hz
}

# OPTS
# drag floating windows by holding down $mod and left mouse button.
floating_modifier $mod normal
focus_follows_mouse yes

# Key bindings
bindsym {
  $mod+p exec $menu
  $mod+Shift+P exec $bmenu
  $mod+Return exec $term
  # $mod+Shift+p exec $clipmenu
  $mod+Shift+s exec $screenshot
  $mod+q kill
  $mod+Shift+c reload
  $mod+Shift+r restart
  $mod+Shift+e exec swaynag -t warning -m 'Do you really want to exit sway?' -B 'Yes, exit sway' 'swaymsg exit'

  # $mod+Tab focus next window
  # $mod+Shift+Tab focus prev window

# focus hjkl
  $mod+$left focus left
  $mod+$right focus right
  $mod+$up focus up
  $mod+$down focus down
# move hjkl
  $mod+Shift+$left move left
  $mod+Shift+$right move right
  $mod+Shift+$up move up
  $mod+Shift+$down move down

# focus cursor keys
  $mod+Left focus left
  $mod+Down focus down
  $mod+Up focus up
  $mod+Right focus right
# move cursor keys
  $mod+Shift+Left move left
  $mod+Shift+Down move down
  $mod+Shift+Up move up
  $mod+Shift+Right move right

  $mod+i workspace back_and_forth
  $mod+Shift+b move container to workspace back_and_forth; workspace back_and_forth

# split orientation
  $mod+g split toggle

# toggle fullscreen mode for the focused container
# focus the parent container
  $mod+a focus parent
  $mod+s floating toggle
  # $mod+Shift+s sticky toggle
  $mod+f fullscreen toggle
  $mod+d layout stacking
  $mod+w layout tabbed
  $mod+e layout toggle split

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

  $mod+b bar mode toggle

# move the currently focused window to the scratchpad
  $mod+Shift+minus move scratchpad
  $mod+minus scratchpad show

#navigate workspaces next / previous
  $mod+Ctrl+Right workspace next
  $mod+Ctrl+Left workspace prev

  $mod+Shift+m floating enable; sticky enable; resize set 200 175; move position 865 20;

  XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%  && killall -USR1 i3status
  XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%  && killall -USR1 i3status
  XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle  && killall -USR1 i3status
  XF86AudioMicMute exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ 150% && killall -USR1 i3status
  XF86MonBrightnessUp exec --no-startup-id notify-send $(brightnessctl) && brightnessctl s +10% && killall -USR1 i3status
  XF86MonBrightnessDown exec --no-startup-id brightnessctl s 10%- && killall -USR1 i3status
}

# workspace back and forth (with/without active container)
workspace_auto_back_and_forth no

set {
  $ws1 1:
  $ws2 2:
  $ws3 3:3
  $ws4 4:4
  $ws5 5:5
  $ws6 6:6
  $ws7 7:7
  $ws8 8:8
  $ws9 9:9
}

workspace {
  $ws1 output $out0
  $ws2 output $out0
  $ws3 output $out0
  $ws4 output $out0
  $ws5 output $out0
  $ws6 output $out0
  $ws7 output $out1
  $ws9 output $out1
  $ws9 output $out1
}

# switch to workspace
bindsym {
  $mod+1 workspace $ws1
  $mod+2 workspace $ws2
  $mod+3 workspace $ws3
  $mod+4 workspace $ws4
  $mod+5 workspace $ws5
  $mod+6 workspace $ws6
  $mod+7 workspace $ws7
  $mod+8 workspace $ws8
  $mod+9 workspace $ws9

# Move focused container to workspace
  $mod+Shift+1 move container to workspace $ws1
  $mod+Shift+2 move container to workspace $ws2
  $mod+Shift+3 move container to workspace $ws3
  $mod+Shift+4 move container to workspace $ws4
  $mod+Shift+5 move container to workspace $ws5
  $mod+Shift+6 move container to workspace $ws6
  $mod+Shift+7 move container to workspace $ws7
  $mod+Shift+8 move container to workspace $ws8
  $mod+Shift+9 move container to workspace $ws9

# Move to workspace with focused container
  $mod+Ctrl+1 move container to workspace $ws1; workspace $ws1
  $mod+Ctrl+2 move container to workspace $ws2; workspace $ws2
  $mod+Ctrl+3 move container to workspace $ws3; workspace $ws3
  $mod+Ctrl+4 move container to workspace $ws4; workspace $ws4
  $mod+Ctrl+5 move container to workspace $ws5; workspace $ws5
  $mod+Ctrl+6 move container to workspace $ws6; workspace $ws6
  $mod+Ctrl+7 move container to workspace $ws7; workspace $ws7
  $mod+Ctrl+8 move container to workspace $ws8; workspace $ws8
  $mod+Ctrl+9 move container to workspace $ws9; workspace $ws9
}

# Open specific applications in floating mode
assign {
  [app_id="org.mozilla.firefox"] $ws1
  [app_id="org.remmina.Remmina"] $ws9
  # [app_id="org.telegram.desktop"] $ws6
  # [app_id="mpv"] $ws7
}

for_window {
  [app_id=".telegram."] flaoting enable
  [app_id="org.pulseaudio.pavucontrol"] floating enable
  # [app_id="mpv"] focus inhibit_idle
  [app_id="mpv"] floating enable, focus, inhibit_idle, sticky enable, resize set 400 400
  [app_id="firefox" title="Picture-in-Picture"] floating enable, resize set 400 400
  [urgent=latest] focus
  [window_type="dialog"] floating enable, resize set 700 800
  [app_id="remmina"] shortcuts_inhibitor enable
}

# Status Bar:
font Jetbrains Mono NL Light 9
default_border pixel 1
#smart both none
hide_edge_borders smart 

# focus_wrapping yes|no|force|workspace
# focus_wrapping yes


#class                  border backgr. text indicator child_border
client.focused_inactive $nf    $nb     $sf  $nf       $db
client.focused          $db    $nb     $sf  $uf       $bf
client.unfocused        $db    $nb     $nf  $db       $db
client.urgent           $nb    $nb     $uf  $uf       $nf

bar {
  position top
  status_padding 0
  # status_edge_padding 20
  tray_padding 7
  tray_output $out0
  separator_symbol " ⋮ "
  icon_theme locolor
  strip_workspace_numbers yes
  status_command i3status -c /home/dafu/.config/sway/i3status.conf
  workspace_min_width 50

  colors {
    #<colorclass>      <border> <background> <text> <indicator> <child_border>
    separator          $sf
    background         $nb
    statusline         $nf
    focused_workspace  $nb      $sf          $nb
    active_workspace   $nb      $nb          $sf
    inactive_workspace $nb      $nb          $nf
    urgent_workspace   $nb      $nb          $uf
    }
}

input type:touchpad events disabled
input type:keyboard {
    xkb_layout de
    xkb_variant nodeadkeys
    xkb_options ctrl:nocaps
}

# other config
include /etc/sway/config.d/*

# startup
exec --no-startup-id {
  lxpolkit
  /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
  eval $(gnome-keyring-daemon --start)
  export SSH_AUTH_SOCK
  /usr/libexec/polkit-gnome-authentication-agent-1
  wl-paste -t text --watch clipman store
  /home/dafu/.config/rc/bin/bat_alert.sh
# exec --no-startup-id nm-applet --sm-disable
}
