### sway settings

# logo key. Use Mod1 for Alt.
set $mod Mod4

# home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l

set $term $TERMINAL
set $browser $BROWSER
set $editor $EDITOR
set $menu dmenu-wl_path | dmenu-wl | xargs swaymsg exec --

# wallpaper
output "*" background ~/.local/share/bg fill


### daemons


# autotype 
exec ydotoold

# display orientation
exec --no-startup-id kanshi

# input method
exec fcitx5

# night light
#exec sleep 3 && gammastep -l LAT:LON

# mpd (music player daemon)
exec mpd

# xresources (nsxiv theme, and other programs)
exec xrdb $HOME/.config/x11/xresources

#  Syncthing (sync daemon)
exec syncthing --no-browser

# polkit
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1

exec_always autotiling
exec systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway


# behavior
focus_follows_mouse no
hide_edge_borders smart
workspace_auto_back_and_forth no
show_marks yes

# looks
default_border pixel 2
default_floating_border pixel 2
gaps inner 5
gaps outer 5
#bindsym $mod+Shift+y border toggle

set $cl_high #F5C2E7
set $cl_indi #888888
set $cl_back #1E1D2F
set $cl_fore #d9d8d8
set $cl_urge #FF0000

client.focused      $cl_high $cl_high $cl_fore $cl_indi $cl_high
client.focused_inactive $cl_back $cl_back $cl_fore $cl_back $cl_back
client.unfocused    $cl_back $cl_back $cl_fore $cl_back $cl_back
client.urgent       $cl_urge $cl_urge $cl_fore $cl_urge $cl_urge

# You can get the names of your outputs by running: swaymsg -t get_outputs
output HDMI-A-1 pos 0 0 res 1366x768
output DVI-D-1 pos 1366 0 transform 0

### Idle configuration

# timeout
exec idle


### key bindings


# start a terminal
bindsym $mod+Return exec $term

# kill focused window
bindsym $mod+q kill

# start your launcher
bindsym $mod+d exec $menu
bindsym $mod+Shift+d exec wofi --show drun

# drag floating windows by holding down $mod and left mouse button.
# resize them with right mouse button + $mod.
# despite the name, also works for non-floating windows.
# change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal

# reload the configuration file
bindsym $mod+Shift+r reload

# exit sway (logs you out of your wayland session)
bindsym $mod+Shift+backspace exec prompt "Do you really wont to exit sway? This will end your Wayland session" "swaymsg exit"

# Prompts you options; shutdown, sleep, etc.
bindsym $mod+backspace exec sysact

# move your focus around
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right

# move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right

# screenshot 
bindsym Print exec grimshot save output $HOME/pictures/Screenshots/$(date +'%Y-%m-%d_%H.%M.%S_%Z').png
bindsym $mod+Print exec grimshot save active $HOME/pictures/Screenshots/$(date +'%Y-%m-%d_%H.%M.%S_%Z').png
bindsym $mod+Shift+Print exec grimshot save window $HOME/pictures/Screenshots/$(date +'%Y-%m-%d_%H.%M.%S_%Z').png


### programs

# sway config
bindsym $mod+F1 exec $term -e $editor ~/.config/sway/config

# browser
bindsym $mod+w exec $browser

# schedule
bindsym $mod+c exec $term -e sc-im $HOME/vimwiki/schedule.sc

# diary
bindsym $mod+Control+n exec $term -e nvim -c VimwikiMakeDiaryNote

# vimwiki (notebook)
bindsym $mod+n exec $term -e nvim -c VimwikiIndex

# newsboat (rss)
bindsym $mod+Shift+n exec $term -e newsboat

# notifications tab
bindsym $mod+Shift+t exec $term -e swaync-client -t

# file manager
bindsym $mod+r exec $term -e lf

# mail
bindsym $mod+e exec $term -e neomutt

# start tasks in dmenu
bindsym $mod+x exec start-tasks

# bookmarks
bindsym $mod+b exec $term -e nvim ~/notebook/bookmarks/bookmarks.md
bindsym $mod+shift+b exec bookmark
bindsym $mod+Insert exec ydotool type $(grep -v '^#' $home/notebook/bookmarks/bookmarks.md | dmenu -l 50 | cut -d' ' -f1)

# kaomiji?
#bindsym $mod+z exec dmenukaomoji

# keepass dmenu
bindsym $mod+shift+Insert exec keepmenu

# download script
bindsym $mod+Control+m exec musdl
#bindsym $mod+Shift+y exec $term ytfzf --detach -c youtube-url $(wl-paste)
#bindsym $mod+y exec io.freetubeapp.FreeTube $(wl-paste)
bindsym --no-repeat $mod+t exec todo-wp

# workspace names
set $wp1 1
set $wp2 2
set $wp3 3
set $wp4 4
set $wp5 5
set $wp6 6
set $wp7 7
set $wp8 8
set $wp9 9
set $wp10 10

# switch to workspace
bindsym $mod+1 workspace $wp1
bindsym $mod+2 workspace $wp2
bindsym $mod+3 workspace $wp3
bindsym $mod+4 workspace $wp4
bindsym $mod+5 workspace $wp5
bindsym $mod+6 workspace $wp6
bindsym $mod+7 workspace $wp7
bindsym $mod+8 workspace $wp8
bindsym $mod+9 workspace $wp9
bindsym $mod+0 workspace $wp10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $wp1
bindsym $mod+Shift+2 move container to workspace $wp2
bindsym $mod+Shift+3 move container to workspace $wp3
bindsym $mod+Shift+4 move container to workspace $wp4
bindsym $mod+Shift+5 move container to workspace $wp5
bindsym $mod+Shift+6 move container to workspace $wp6
bindsym $mod+Shift+7 move container to workspace $wp7
bindsym $mod+Shift+8 move container to workspace $wp8
bindsym $mod+Shift+9 move container to workspace $wp9
bindsym $mod+Shift+0 move container to workspace $wp10

# move focused container to workspace
# with comma/period (</>)
bindsym $mod+comma focus output left
bindsym $mod+period focus output right
bindsym $mod+Shift+comma move window to output left
bindsym $mod+Shift+period move window to output right
bindsym $mod+Alt+comma move workspace to output left
bindsym $mod+Alt+period move workspace to output right
# with directional pad (up/down/left/right)
bindsym $mod+left focus output left
bindsym $mod+right focus output right
bindsym $mod+up focus output up
bindsym $mod+down focus output down
bindsym $mod+Shift+left move window to output left
bindsym $mod+Shift+right move window to output right
bindsym $mod+Shift+up move window to output up
bindsym $mod+Shift+down move window to output down
bindsym $mod+Alt+left move workspace to output left
bindsym $mod+Alt+right move workspace to output right
bindsym $mod+Alt+up move workspace to output up
bindsym $mod+Alt+down move workspace to output down

# splits
# bindsym $mod+b splith
# bindsym $mod+v splitv

# switch the current container between different layout styles
# bindsym $mod+s layout stacking
# bindsym $mod+w layout tabbed
# bindsym $mod+e layout toggle split

# make the current focus fullscreen
bindsym $mod+f fullscreen

# toggle the current focus between tiling and floating mode
bindsym $mod+Shift+space floating toggle

# swap focus between the tiling area and the floating area
bindsym $mod+space focus mode_toggle

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

# move the currently focused window to the scratchpad
bindsym $mod+Shift+grave move scratchpad

# show the next scratchpad window or hide the focused scratchpad window.
# if there are multiple scratchpad windows, this command cycles through them.
bindsym $mod+grave scratchpad show

mode "resize" {
    # left will shrink the containers width
    # right will grow the containers width
    # up will shrink the containers height
    # down will grow the containers height
    bindsym $left resize shrink width 10px
    bindsym $down resize grow height 10px
    bindsym $up resize shrink height 10px
    bindsym $right resize grow width 10px

    # ditto, with arrow keys
    bindsym Left resize shrink width 10px
    bindsym Down resize grow height 10px
    bindsym Up resize shrink height 10px
    bindsym Right resize grow width 10px

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



# status bar
include $HOME/.config/sway/bar
#exec_always killall waybar
#exec_always sleep 2 && waybar


### special keys


# mute
# TODO mic mute and audio mute w/ wpctl
bindsym $mod+Shift+m exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle

# volume
bindsym $mod+minus exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindsym $mod+equal exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
bindsym $mod+Shift+minus exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 15%-
bindsym $mod+Shift+equal exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 15%+

# music controls
bindsym $mod+p exec mpc toggle
bindsym $mod+o exec mpc next
bindsym $mod+i exec mpc prev

# music seeking
bindsym $mod+bracketleft exec mpc seek -10
bindsym $mod+bracketright exec mpc seek +10
bindsym $mod+Shift+bracketleft exec mpc seek -60
bindsym $mod+Shift+bracketright exec mpc seek +60

# audio controller
bindsym $mod+Control+p exec $term -e pulsemixer

# music player
bindsym $mod+m exec $term -e ncmpcpp

#bindsym $mod+Shift+o exec mpc repeat
#bindsym $mod+Shift+i exec mpc seek 0%

include /etc/sway/config.d/*
include ~/syncthing/default/config.d/sway/