### 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

font pango:monospace 8

floating_modifier $mod

assign [class="TeamSpeak 3"] $workspace9
assign [class="Evolution"] $workspace0
assign [class="TelegramDesktop"] $workspace0
assign [class="Riot"] $workspace0
# assign [class="Psi"] $workspace0

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

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
    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 i3status
}

hide_edge_borders smart

### 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 lxterminal
bindsym $mod+Shift+q kill
bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

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+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"

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

# Pulse Audio controls
#bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% #increase sound volume
#bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% #decrease sound volume
#bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound

# Media player controls
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

### Launchers

exec_always ln -sf /mnt/shome/tobias/* /home/tobias/
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; telegram-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
#exec obs --startreplaybuffer --minimize-to-tray

# Wallpaper
#exec_always feh --randomize --bg-fill ~/Pictures/Wallpaper/Cyberpunk/*
#exec_always feh --bg-fill ~/Pictures/Wallpaper/predator_2018_4k.jpg
exec_always feh --bg-fill ~/Pictures/Wallpaper/arch_hero.png

#exec_always killall conky
#exec_always sleep 1; conky --daemonize --config="/home/tobias/.config/conky/cpu_ram_storage.conf"
execconky --daemonize --config="/home/tobias/.config/conky/clock.conf"
execconky --daemonize --config="/home/tobias/.config/conky/cpu_ram_storage.conf"
#exec_always sleep 1; conky --daemonize --config="/home/tobias/.config/conky/clock.conf"