#  startup {{{ # 
set $browser "chromium"
set $def_term "urxvt"
# set $runelite "java -jar ~/Downloads/RuneLite.jar"
set $swex "sudo ~/Downloads/swex.appimage"
# exec redshift -O 2000
exec redshift -O 3000 
# random bg
exec compton
exec wal -i "$HOME/Pictures/Backgrounds/dim"
exec imwheel
exec xmodmap ~/.Xmodmap
exec xrdb ~/.Xresources
exec --no-startup-id start-pulseaudio-x11
exec --no-startup-id i3-msg 'workspace $ws2; exec $def_term'
exec --no-startup-id i3-msg 'workspace $ws3; exec $browser'
# exec --no-startup-id i3-msg 'workspace $ws11; exec $swex'
exec_always --no-startup-id numlockx on
#  }}} startup # 

#  applications {{{ # 

set $mod Mod1
set $sch_dir "$HOME/Documents/School"

#  app shortcuts {{{ # 
bindsym Mod4+a exec studio
# bindsym Mod4+1 exec xdotool click --repeat 5 --delay 100 1
# bindsym Mod4+2 exec xdotool click --repeat 10 --delay 100 1
# bindsym Mod4+3 exec xdotool click --repeat 20 --delay 100 1
# bindsym $mod+control+Return exec i3-sensible-terminal
bindsym $mod+control+Return exec $def_term
bindsym Mod4+c exec $browser
bindsym Mod4+f exec firefox
bindsym Mod4+o exec okular
bindsym Mod4+m exec okular $sch_dir/calc-textbook.pdf
bindsym Mod4+n exec urxvt -e nvim
bindsym Mod4+p workspace $ws4; exec pgadmin3
# bindsym Mod4+p exec pycharm
bindsym Mod4+q exec qdirstat
bindsym Mod4+r exec urxvt -e ranger
# bindsym control+$mod+s exec systemctl suspend
bindsym control+$mod+s exec systemctl suspend
bindsym Mod4+t exec st
bindsym Mod4+x exec $swex
bindsym Print exec gscreenshot
#  }}} app shortcuts # 

#  redshift {{{ # 

bindsym $mod+Mod4+1 exec redshift -x && redshift -O 1000
bindsym $mod+Mod4+2 exec redshift -x && redshift -O 2000
bindsym $mod+Mod4+3 exec redshift -x && redshift -O 3000
bindsym $mod+Mod4+4 exec redshift -x && redshift -O 4000
bindsym $mod+Mod4+5 exec redshift -x && redshift -O 5000
bindsym $mod+Mod4+grave exec redshift -x

# old
# bindsym $mod+Mod4+1 exec redshift -x && redshift -O 1000
# bindsym $mod+Mod4+3 exec redshift -x && redshift -O 1500
# bindsym $mod+Mod4+3 exec redshift -x && redshift -O 2500

#  }}} redshift # 

#  backlight {{{ # 

bindsym Shift+F1 exec xbacklight -set 10
bindsym Shift+F2 exec xbacklight -set 20
bindsym Shift+F3 exec xbacklight -set 30
bindsym Shift+F4 exec xbacklight -set 40
bindsym Shift+F5 exec xbacklight -set 50
bindsym Shift+F6 exec xbacklight -set 60
bindsym Shift+F7 exec xbacklight -set 70
bindsym Shift+F8 exec xbacklight -set 80
bindsym Shift+F9 exec xbacklight -set 90
bindsym Shift+F0 exec xbacklight -set 100

#  }}} backlight #

#  menu {{{ # 
# start dmenu (a program launcher)
# bindsym Mod4+Return exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
#  }}} menu # 
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
#  }}} applications # 

#  changing/focusing/moving windows {{{ # 
# change focus
bindsym control+h focus left
bindsym control+j focus down
bindsym control+k focus up
bindsym control+l focus right

# move workspace to other monitor
bindsym $mod+minus move workspace to output left
bindsym $mod+plus move workspace to output 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 control+Shift+h move left
bindsym control+Shift+j move down
bindsym control+Shift+k move up
bindsym control+Shift+l 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+b split h

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

bindsym control+Shift+x kill
#  }}} changing/focusing/moving windows # 

#  container display {{{ # 
# backgrounds
# set $colors_sh "~/.cache/wal/colors.sh"
bindsym $mod+q exec wal -i "$HOME/Pictures/Backgrounds/vibrant"; exec ~/.cache/wal/colors.sh
bindsym $mod+w exec wal -i "$HOME/Pictures/Backgrounds/dim"; exec ~/.cache/wal/colors.sh
bindsym $mod+r exec wal -i "$HOME/Pictures/Backgrounds/"; exec ~/.cache/wal/colors.sh
bindsym $mod+z exec feh --bg-fill ~/Pictures/Backgrounds/dim/black.jpg

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

# focus the child container
#bindsym $mod+d focus child

#  change container colors from pywal {{{ # 

# Set colors from Xresources
# Change 'color7' and 'color2' to whatever colors you want i3 to use 
# from the generated scheme.
# NOTE: The '#f0f0f0' in the lines below is the color i3 will use if
# it fails to get colors from Xresources.
set_from_resource $fg i3wm.color7 #f0f0f0
set_from_resource $bg i3wm.color2 #f0f0f0

# class                 border  backgr. text indicator child_border
client.focused          $bg     $bg     $fg  $bg       $bg
# client.unfocused        $bg     $bg     $fg  $bg       $bg
# client.urgent           $bg     $bg     $fg  $bg       $bg
# client.placeholder      $bg     $bg     $fg  $bg       $bg
# client.background       $bg

# PROTIP: You can also dynamically set dmenu's colors this way:
bindsym Mod4+Return exec dmenu_run -nb "$fg" -nf "$bg" -sb "$bg" -sf "$fg"

#  }}} change container colors from pywal # 

#  }}} container display # 

#  workspace {{{ # 
#  ws names {{{ # 
set $samsung "DVI-I-1"
set $benq "HDMI-1"

set $ws1 "1 "
workspace $ws1 output $benq
bindsym $mod+F1 workspace $ws1; exec $def_term

set $ws2 "2 "
workspace $ws2 output $samsung
bindsym $mod+F2 workspace $ws2; exec $def_term

set $ws3 "3 "
workspace $ws3 output $benq
bindsym $mod+F3 workspace $ws3; exec $browser

set $ws4 "4 "
workspace $ws4 output $samsung
bindsym $mod+F4 workspace $ws4; exec $def_term

set $ws5 "5 "
# set $ws5 "5 🎥"
workspace $ws5 output $samsung
bindsym $mod+F5 workspace $ws5; exec $browser
bindsym Mod4+g workspace $ws5; layout stacking; exec steam

set $ws6 "6 "
workspace $ws6 output $samsung
assign [class="Slack"] $ws6
bindsym Mod4+d workspace $ws6; exec discord
bindsym Mod4+k workspace $ws6; exec slack

set $ws7 "7 "
# set $ws7 "7 📤"
workspace $ws7 output $samsung
bindsym $mod+F7 workspace $ws7; exec $def_term

set $ws8 "8 "
# set $ws8 "8 📊"
# assign [class="jetbrains-"] $ws8
workspace $ws8 output $samsung
bindsym $mod+F8 workspace $ws8; exec urxvt -e htop -s PERCENT_MEM 

set $ws9 "9 "
# set $ws9 "9 🔧"
workspace $ws9 output $samsung
bindsym $mod+F9 workspace $ws9; exec $def_term

set $ws10 "10 "
# set $ws10 "10 🎵"
assign [class="spotify"] $ws10
workspace $ws10 output $samsung
set $hp 2
bindsym Mod4+v workspace $ws10; exec urxvt -e alsamixer -c 0
bindsym Mod4+h workspace $ws10; exec urxvt -e alsamixer -c $hp
bindsym Mod4+s workspace $ws10; exec spotify

set $ws11 "11 "
# assign [class="Summoners War Exporter"] $ws11
workspace $ws11 output $samsung
bindsym $mod+F11 workspace $ws11; exec $def_term

set $ws12 "12 "
bindsym $mod+F12 workspace $ws12; exec $def_term

set $ws13 "13 "
bindsym Mod4+F3 workspace $ws13; exec $def_term

set $ws14 "14"
set $ws15 "15"

#  }}} ws names # 

#  ws bindings {{{ # 
# switch to workspace
bindsym $mod+h workspace prev
bindsym $mod+l workspace next

bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
bindsym Mod4+1 workspace $ws11
bindsym Mod4+2 workspace $ws12
bindsym Mod4+3 workspace $ws13
bindsym Mod4+4 workspace $ws14
bindsym Mod4+5 workspace $ws15
#  }}} ws bindings # 

#  move container to ws {{{ # 
# move focused container to workspace
# bindsym $mod+control+1 move container to workspace $ws1
bindsym $mod+control+1 move container to workspace $ws1; workspace $ws1
bindsym $mod+control+2 move container to workspace $ws2; workspace $ws2
bindsym $mod+control+3 move container to workspace $ws3; workspace $ws3
bindsym $mod+control+4 move container to workspace $ws4; workspace $ws4
bindsym $mod+control+5 move container to workspace $ws5; workspace $ws5
bindsym $mod+control+6 move container to workspace $ws6; workspace $ws6
bindsym $mod+control+7 move container to workspace $ws7; workspace $ws7
bindsym $mod+control+8 move container to workspace $ws8; workspace $ws8
bindsym $mod+control+9 move container to workspace $ws9; workspace $ws9
bindsym $mod+control+0 move container to workspace $ws10; workspace $ws10
bindsym $mod+Shift+1 move container to workspace $ws11; workspace $ws11
bindsym $mod+Shift+2 move container to workspace $ws12; workspace $ws12
bindsym $mod+Shift+3 move container to workspace $ws13; workspace $ws13
bindsym $mod+Shift+4 move container to workspace $ws14; workspace $ws14
bindsym $mod+Shift+5 move container to workspace $ws15; workspace $ws15
#  }}} move container to ws # 
#  }}} workspace # 

#  reload config/computer {{{ #

bindsym $mod+Shift+s exec systemctl suspend
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
# bindsym $mod+control+r exec ~/.cache/wal/colors.sh; restart
bindsym $mod+control+r exec i3-msg restart
# bindsym $mod+control+r exec $colors_sh && i3-msg restart

# reload the configuration file
bindsym $mod+Shift+c reload
# bindsym $mod+control+r reload
bindsym $mod+control+u exec xrdb ~/.Xresources

# exit i3 (logs you out of your X session)
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'"

#  }}} reload config # 

#  resizing windows {{{ # 
bindsym $mod+control+h resize grow width 3 px or 3 ppt
bindsym $mod+control+k resize grow height 3 px or 3 ppt
bindsym $mod+control+j resize shrink height 3 px or 3 ppt
bindsym $mod+control+l resize shrink width 3 px or 3 ppt
#  }}} resizing windows # 

#  gaps {{{ # 

# remove window titlebars
for_window [class="^.*"] border pixel 3
# for_window [class="^.*"] border pixel 1
set $inner_gaps 35
set $outer_gaps 0

# gaps inner $inner_gaps
# gaps outer $outer_gaps
# gaps bottom 0
gaps inner 0
gaps outer 0

#  other gaps {{{ # 

# gaps horizontal 20
# gaps vertical 10
# gaps top
# gaps left 20
# gaps right 20
# gaps bottom

#  }}} other gaps # 

bindsym control+shift+plus gaps inner all set $inner_gaps;gaps outer all set $outer_gaps
bindsym control+shift+0 gaps inner all set 0;gaps outer all set 0

#  }}} gaps # 

#  status bar {{{ # 
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
set $sb_font DejaVuSansMono Nerd Font Mono Bold
# set $sb_font Hack NF Bold
# set $sb_font EmojiOne
set $black #000000
set $white #ffffff

#  inactive vars {{{ # 

# set $inactive_ws_bg $white
set $inactive_ws_bg #444c52

# set $inactive_ws_text #bcccd7
# set $inactive_ws_text #838e96
set $inactive_ws_text #cbe4ff
# set $inactive_ws_text $bg

# set $inactive_ws_trans c8
# set $inactive_ws_trans 96
set $inactive_ws_trans 00

#  }}} inactive # 

#  active vars {{{ # 

set $active_ws_bg #444c52
# set $active_ws_bg #566066

# set $active_ws_trans c8
set $active_ws_trans 91

#  }}} active # 

# set $focused_ws_text $white
set $focused_ws_text #ffffff

#  benq bar {{{ # 

# set $bar_trans 64
set $bar_trans 00
set $benq_ws_trans aa
bar {
	i3bar_command i3bar -t 
	font pango:$sb_font 21
	# font pango:$sb_font 14
	colors {
		# 0 (transparent) -> 255 (opaque) in hex
		background $black$bar_trans
		# border, bg, text color
		focused_workspace $inactive_ws_bg $bg $focused_ws_text 
		# active = focused on other screen
		active_workspace $inactive_ws_bg $active_ws_bg$active_ws_trans $focused_ws_text
		inactive_workspace $inactive_ws_bg $inactive_ws_bg$inactive_ws_trans $inactive_ws_text
	}
	tray_output none
	# status_command i3blocks -c ~/.config/i3blocks/i3blocks.conf
	status_command 2>/tmp/i3blocks.err i3blocks -vvv -c ~/.config/i3blocks/i3blocks.conf | tee /tmp/i3blocks.out
	output $benq
	wheel_up_cmd nop
	wheel_down_cmd nop
}

#  }}} benq bar # 

#  sam bar {{{ #

bar {
	output $samsung
	font pango:$sb_font 25
	# font pango:$sb_font 15
	# output $benq
	i3bar_command i3bar -t
	colors {
		background $black$bar_trans
		# border, bg, text color
		focused_workspace $inactive_ws_bg $bg $focused_ws_text 
		active_workspace $inactive_ws_bg $active_ws_bg$active_ws_trans $focused_ws_text
		inactive_workspace $inactive_ws_bg $inactive_ws_bg$inactive_ws_trans $inactive_ws_text
	}
	status_command i3blocks -c ~/.config/sam-i3blocks/sam-i3blocks.conf
	tray_output none
	wheel_up_cmd nop
	wheel_down_cmd nop
}

#  }}} samsung bar #

# # #  display {{{ #

# bar {
	# i3bar_command i3bar -t
	# font pango:$sb_font 23
	# tray_output none
	# status_command i3blocks -c ~/.config/i3blocks/i3blocks-display.conf
	# output $samsung
	# wheel_up_cmd nop
	# wheel_down_cmd nop
# }

# #  }}}  display #

#  }}} status bar #

#  mod key/font {{{ # 
set $mod Mod1

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
# font pango:Hack 11
# font pango:$sb_font 8
font pango:$sb_font 11
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8

# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesn’t scale on retina/hidpi displays.
#  }}} mod key/font # 

#  media keys {{{ # 
bindsym $mod+d exec ~/linux-config/scripts/change-sink dac1
bindsym $mod+shift+d exec ~/linux-config/scripts/change-sink dac2
bindsym $mod+o exec ~/linux-config/scripts/change-sink line-out

bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -c 0 sset Master 3+
bindsym XF86AudioLowerVolume exec --no-startup-id amixer -c 0 sset Master 3-
bindsym control+$mod+plus exec --no-startup-id amixer -c 2 sset PCM 3+
bindsym control+$mod+minus exec --no-startup-id amixer -c 2 sset PCM 3-
bindsym XF86AudioMute exec --no-startup-id amixer -D pulse set Master 0+ toggle

# Media player controls
bindsym XF86AudioPlay exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
bindsym XF86AudioStop exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
bindsym XF86AudioPrev exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
bindsym XF86AudioNext exec "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
#  }}} media keys #