### VARIABLES

set $mod Mod4

set $workspace1 workspace 1
set $workspace2 workspace 2
set $workspace3 workspace 3
set $workspace4 workspace 4
set $workspace5 workspace 5
set $workspace6 workspace 6
set $workspace7 workspace 7:Game
set $workspace8 workspace 8:Docs
set $workspace9 workspace 9:TS
set $workspace0 workspace 10:Msg

workspace "1" output HDMI-1
workspace "2" output HDMI-1
workspace "3" output HDMI-1
workspace "4" output HDMI-1
workspace "5" output HDMI-1
workspace "6" output HDMI-1
workspace "7:Game" output HDMI-1

workspace "8:Docs" output DVI-D-1
workspace "9:TS" output DVI-D-1
workspace "10:Msg" output DVI-D-1

set $Locker i3lock && sleep 1
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
set $mode_refresh_rate Refresh-Rate (h) high, (l) low

set $bg-color 	         #535353
set $inactive-bg-color   #131313
set $text-color          #f3f3f3
set $inactive-text-color #666666
set $urgent-bg-color     #e63535
set $indicator-color     #535353
set $separator-color     #535353

### SET MODIFIERS

floating_modifier $mod

assign [class="TeamSpeak 3"] $workspace9

assign [class="Evolution"] $workspace0
assign [class="TelegramDesktop"] $workspace0
assign [class="Riot"] $workspace0
assign [class="Signal"] $workspace0
# assign [class="Psi"] $workspace0
for_window [workspace="10:Msg"] layout tabbed

assign [class="Steam"] $workspace7

### WINDOW DESIGN
client.focused          $bg-color           $bg-color          $text-color          $indicator-color 
client.unfocused        $inactive-bg-color  $inactive-bg-color $inactive-text-color $indicator-color
client.focused_inactive $inactive-bg-color  $inactive-bg-color $inactive-text-color $indicator-color
client.urgent           $urgent-bg-color    $urgent-bg-color   $text-color          $indicator-color

default_border pixel
hide_edge_borders smart

font pango:monospace 12

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
#bar {
#    height 20
#    tray_output HDMI-1
#    colors {
#        background $bg-color
#        separator  $separator-color
#        #                  border             background         text
#        focused_workspace  $bg-color          $bg-color          $text-color
#        inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
#        urgent_workspace   $urgent-bg-color   $urgent-bg-color   $text-color
#    }
#    status_command i3blocks # i3status -c ~/.config/i3statusconfig
#}

### MODES

mode "resize" {
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

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

mode "$mode_system" {
    bindsym l exec --no-startup-id $Locker, mode "default"
    bindsym e exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id $Locker && systemctl suspend, mode "default"
    bindsym h exec --no-startup-id $Locker && systemctl hibernate, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default"  

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

mode "$mode_refresh_rate" {
    bindsym h exec --no-startup-id xrandr --output HDMI-1 --mode 2560x1440 --refresh 144, mode "default"
    bindsym l exec --no-startup-id xrandr --output HDMI-1 --mode 2560x1440 --refresh 60, mode "default"

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

### BINDINGS

bindsym $mod+Return exec alacritty
bindsym $mod+Shift+q kill
bindsym $mod+d exec --no-startup-id rofi -show
bindsym $mod+p exec --no-startup-id rofi-pass

bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus 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

bindsym $mod+h split h
bindsym $mod+v split v
bindsym $mod+f fullscreen toggle

bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

bindsym $mod+Shift+space floating toggle
bindsym $mod+space focus mode_toggle

bindsym $mod+1 $workspace1
bindsym $mod+2 $workspace2
bindsym $mod+3 $workspace3
bindsym $mod+4 $workspace4
bindsym $mod+5 $workspace5
bindsym $mod+6 $workspace6
bindsym $mod+7 $workspace7
bindsym $mod+8 $workspace8
bindsym $mod+9 $workspace9
bindsym $mod+0 $workspace0

bindsym $mod+Shift+1 move container to $workspace1
bindsym $mod+Shift+2 move container to $workspace2
bindsym $mod+Shift+3 move container to $workspace3
bindsym $mod+Shift+4 move container to $workspace4
bindsym $mod+Shift+5 move container to $workspace5
bindsym $mod+Shift+6 move container to $workspace6
bindsym $mod+Shift+7 move container to $workspace7
bindsym $mod+Shift+8 move container to $workspace8
bindsym $mod+Shift+9 move container to $workspace9
bindsym $mod+Shift+0 move container to $workspace0

bindsym $mod+a [urgent=latest] focus

bindsym $mod+KP_Subtract move scratchpad
bindsym $mod+KP_Add scratchpad show

bindsym $mod+period sticky toggle

bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

bindsym --release $mod+Print exec "import /tmp/screenshot.png && xclip -t image/png /tmp/screenshot.png -selection clipboard"

# Enter Mode
bindsym $mod+r mode "resize"
bindsym $mod+Pause mode "$mode_system"
bindsym $mod+m mode "$mode_refresh_rate"

bindsym XF86AudioPlay           exec --no-startup-id mpc toggle
bindsym XF86AudioPause          exec --no-startup-id mpc pause
bindsym XF86AudioNext           exec --no-startup-id mpc next
bindsym XF86AudioPrev           exec --no-startup-id mpc prev
bindsym XF86AudioRaiseVolume    exec --no-startup-id mpc volume +1
bindsym XF86AudioLowerVolume    exec --no-startup-id mpc volume -1
#bindsym XF86AudioMute           exec --no-startup-id mpc toggleoutput

### i3 gaps

smart_gaps on
gaps inner 10
gaps outer -10

### Launchers

exec_always hid_info=$(xinput -list | grep -i 'Arduino LLC Arduino Micro.*keyboard' | grep -o 'id=..');hid_info=${hid_info:3:4};setxkbmap -device "$hid_info" us;
exec_always setxkbmap de

exec sleep 8; env GTK_THEME=Adwaita:light firefox
exec sleep 8; teamspeak3

exec sleep 8; evolution
exec sleep 8; signal-desktop
exec sleep 8; riot-desktop
#exec sleep 8; psi

# Backgroud Services
exec ckb-next -b
exec steam-runtime -silent -tcp
exec transmission-gtk -m

# Eyecandy
exec_always --no-startup-id $HOME/.config/polybar/launch.sh
exec_always --no-startup-id feh --bg-fill ~/Pictures/wallpaper/active_wallpaper

exec conky --daemonize --config="$HOME/.config/conky/clock.conf"
exec conky --daemonize --config="$HOME/.config/conky/cpu_ram_storage.conf"