##### i3-config / RESLOVED  #######################

##### GENERAL ##################################### 

set $mod Mod4

font pango:Iosevka 8

# APP VARIABLES
set $qute         qutebrowser --target window
set $firefox      firefox --new-window
set $surf         surf
set $term         alacritty

# Power Profiles menu switcher (rofi)
bindsym $mod+Shift+p exec ~/.config/i3/scripts/power-profiles

# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1:"
set $ws2 "2:"
set $ws3 "3:"
set $ws4 "4:"
set $ws5 "5:"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

#get auth work with polkit-gnome
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1

# set powersavings for display:
exec --no-startup-id xset s 480 dpms 600 600 600

# DIR VARIABLES
set $bin ~/bin

# RESIZE VARIABLES
set $center move absolute position center

# FLOATING
floating_modifier $mod

set $thick 2

# DEFAULT BORDER
for_window [class="^.*"] border pixel $thick
for_window [class=".*"] title_window_icon on

hide_edge_borders vertical

# APPLICATION BORDERS
#for_window [class="Emacs"] border pixel $thick
for_window [class="st"] border pixel $thick


#for_window [class="Surf"] floating enable
#for_window [class="Surf"] floating_maximum_size 800 x 550

# GAP VARIABLES
set $inner 6
set $outer 3

# SET GAPS
gaps inner $inner
gaps outer $outer

# set floating (nontiling) for apps needing it
for_window [class="Yad" instance="yad"] floating enable
for_window [class="Galculator" instance="galculator"] floating enable
for_window [class="Blueberry.py" instance="blueberry.py"] floating enable

# set floating (nontiling) for special apps
for_window [class="Xsane" instance="xsane"] floating enable
for_window [class="Pavucontrol" instance="pavucontrol"] floating enable
for_window [class="qt5ct" instance="qt5ct"] floating enable
for_window [class="Blueberry.py" instance="blueberry.py"] floating enable
for_window [class="Bluetooth-sendto" instance="bluetooth-sendto"] floating enable
for_window [class="Pamac-manager"] floating enable
for_window [window_role="About"] floating enable
for_window [class="Foliate"] floating enable
for_window [class="Foliate"] floating_maximum_size 400 x 800

# set border of floating window
for_window [class="urxvt"] border pixel 1

# Define colors variables:
set $darkbluetrans	#08052be6
set $darkblue		#08052b
set $lightblue		#5294e2
set $urgentred		#e53935
set $white		#ffffff
set $black		#000000
set $purple		#e345ff
set $darkgrey		#383c4a
set $grey		#b0b5bd
set $mediumgrey		#8b8b8b
set $yellowbrown	#e1b700

#class		        	border		bground		text		indicator	child_border
client.focused		    $lightblue	$darkblue	$white		$purple		$mediumgrey
client.unfocused	    $darkblue	$darkblue	$grey		$purple		$darkgrey
client.focused_inactive	$darkblue	$darkblue	$grey		$purple		$black
client.urgent		    $urgentred	$urgentred	$white		$purple		$yellowbrown

bar {
		font pango: Iosveka 8
		status_command i3blocks -c ~/.config/i3/i3blocks.conf
	    	position top
#	    	i3bar_command i3bar --transparency
# it could be that you have no primary display set: set one (xrandr --output <output> --primary)
# reference: https://i3wm.org/docs/userguide.html#_tray_output
		    tray_output primary
		    tray_padding 0

# When strip_workspace_numbers is set to yes,
# any workspace that has a name of the form
# “[n][:][NAME]” will display only the name.
strip_workspace_numbers yes
##strip_workspace_name no

		    colors {
		    separator          $purple
		    background         $darkgrey
		    statusline         $white
#                          		border 		        bg		txt		indicator
		focused_workspace	$mediumgrey	   	$grey		$darkgrey	$purple
		active_workspace	$lightblue      	$mediumgrey	$darkgrey	$purple
		inactive_workspace	$darkgrey   		$darkgrey	$grey		$purple
		urgent_workspace	$urgentred	    	$urgentred	$white		$purple
	}
}

# CUSTOM BINDINGS
#bindsym $mod+shift+m exec --no-startup-id surf https://15five-dev.atlassian.net/secure/Dashboard.jspa

# SCRATCHPAD
bindsym $mod+Ctrl+Return exec rofi -show ssh
bindsym $mod+Return exec $term
bindsym $mod+Shift+Return exec kitty
#bindsym $mod+Shift+BackSpace floating enable, move position 48 px 48 px, move scratchpad
#bindsym $mod+Ctrl+BackSpace exec $term -e tmux new-session -A -s scratch

# KILL
bindsym $mod+Shift+q      kill
bindsym $mod+Shift+x exec exit

# RELOAD 
bindsym $mod+Shift+BackSpace reload
# RESTART
bindsym $mod+Shift+r restart

bindsym $mod+w layout toggle split
bindsym $mod+Ctrl+w layout stacked
bindsym $mod+Shift+w layout tabbed
title_align center

##### MOVEMENT ####################################
# WORKSPACES
bindsym $mod+Ctrl+Shift+h move workspace to output left
bindsym $mod+Ctrl+Shift+l move workspace to output right
bindsym $mod+Ctrl+Shift+j move workspace to output down
bindsym $mod+Ctrl+Shift+k move workspace to output up

# FOCUS
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# MOVE
bindsym $mod+Ctrl+h move left
bindsym $mod+Ctrl+j move down
bindsym $mod+Ctrl+k move up
bindsym $mod+Ctrl+l move right

bindsym $mod+Ctrl+Left move left
bindsym $mod+Ctrl+Down move down
bindsym $mod+Ctrl+Up move up
bindsym $mod+Ctrl+Right move right

# RESIZE
bindsym $mod+Shift+h          resize shrink width  20px or 20 ppt
bindsym $mod+Shift+j          resize shrink height 20px or 20 ppt
bindsym $mod+Shift+k          resize grow height   20px or 20 ppt
bindsym $mod+Shift+l          resize grow width    20px or 20 ppt

bindsym $mod+Shift+Left       resize shrink width  10px or 10 ppt
bindsym $mod+Shift+Down       resize shrink height 10px or 10 ppt
bindsym $mod+Shift+Up         resize grow height   10px or 10 ppt
bindsym $mod+Shift+Right      resize grow width    10px or 10 ppt

# VERTICAL SPLIT
bindsym $mod+v split v

# HORIZONTAL SPLIT
bindsym $mod+b split h

# FULLSCREEN
bindsym $mod+f fullscreen toggle

# TOGGLE FLOATING
##bindsym $mod+escape floating toggle; $center

# MODE TOGGLE
bindsym $mod+Shift+space focus mode_toggle

# PAPER MODE
bindsym $mod+Ctrl+space floating toggle; resize set 780px 880px;

# Small PAPER MODE
bindsym $mod+Ctrl+p floating toggle; resize set 480px 580px;

# CENTER FLOATING
bindsym $mod+c $center

# DISPLAYS
bindsym $mod+F1 exec ~/.screenlayout/titan-one.sh
bindsym $mod+F2 exec ~/.screenlayout/titan-two.sh

# bind program to workspace and focus to them on startup:
assign [class="emacs"] $ws1
assign [class="(?i)firefox"] $ws3
assign [class="qutebrowser"] $ws4

##### WORKSPACES ##################################

# WORKSPACES
set $ws1 number 1
set $ws2 number 2
set $ws3 number 3
set $ws4 number 4
set $ws5 number 5
set $ws6 number 6
set $ws7 number 7
set $ws8 number 8
set $ws9 number 9

#assign [class="Firefox"] $ws1
#assign [class="emacs"] $ws2
#assign [class="^Zoom"] $ws5

# SWITCH TO WORKSPACE
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+Mod2+KP_1 workspace $ws1
bindsym $mod+Mod2+KP_2 workspace $ws2
bindsym $mod+Mod2+KP_3 workspace $ws3
bindsym $mod+Mod2+KP_4 workspace $ws4
bindsym $mod+Mod2+KP_5 workspace $ws5
bindsym $mod+Mod2+KP_6 workspace $ws6
bindsym $mod+Mod2+KP_7 workspace $ws7
bindsym $mod+Mod2+KP_8 workspace $ws8
bindsym $mod+Mod2+KP_9 workspace $ws9

# MOVE WINDOW TO WORKSPACE
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9

bindsym $mod+Ctrl+Mod2+KP_1 move container to workspace $ws1
bindsym $mod+Ctrl+Mod2+KP_2 move container to workspace $ws2
bindsym $mod+Ctrl+Mod2+KP_3 move container to workspace $ws3
bindsym $mod+Ctrl+Mod2+KP_4 move container to workspace $ws4
bindsym $mod+Ctrl+Mod2+KP_5 move container to workspace $ws5
bindsym $mod+Ctrl+Mod2+KP_6 move container to workspace $ws6
bindsym $mod+Ctrl+Mod2+KP_7 move container to workspace $ws7
bindsym $mod+Ctrl+Mod2+KP_8 move container to workspace $ws8
bindsym $mod+Ctrl+Mod2+KP_9 move container to workspace $ws9

##=================================================##
# Assign Workspaces:
#assign [class="Emacs"] $ws1
#assign [class=$qute] $ws2
#assign [class=$term] $ws3
#assign [class="calibre"] $ws5
#assign [class="Foliate"] $ws5


##### COLORS #######################################

# XRESOURCES
set $fg "#FF00FF"
set $bg "#AAAAAA"
set $tx "#000000"
set $ltx "#000000"

# CLASS                 BORDER  BACK    TEXT    INDICATOR
client.focused          $fg     $fg     $tx     $fg
client.focused_inactive $bg     $bg     $tx     $fg
client.unfocused        $bg     $bg     $ltx     $bg
client.urgent           $bg     $bg     $bg     $bg 
client.placeholder      $bg     $bg     $bg     $bg 

##### TOOLS ########################################

# bindsym $mod+F11 exec --no-startup-id systemctl --user restart canon-webcam
# bindsym $mod+F12 exec --no-startup-id ffplay /dev/video5

# SCREENSHOT
set $shots ~/var/media/screenshots

bindsym $mod+Print exec maim --hidecursor $shots/$(date +%s).png
bindsym $mod+Ctrl+Print exec screencap
bindsym $mod+Shift+Print exec pkill ffmpeg

# CAST
set $casts ~/videos/casts

#bindsym $mod+Ctrl+F11  exec anypaste -x -s -p streamable $(last $casts)
#bindsym $mod+Shift+F11 exec ffplay -loop 0 $(last $casts)

# Sreen brightness controls
bindsym F5 exec ~/.bin/fade down
bindsym F6 exec ~/.bin/fade up
#bindsym XF86MonBrightnessUp exec ~/.bin/fade up
#bindsym XF86MonBrightnessDown exec ~/.bin/fade down

#bindsym XF86MonBrightnessUp exec ~/.config/i3/bright.sh -u # increase screen brightness
#bindsym XF86MonBrightnessDown exec ~/.config/i3/bright.sh -d # decrease screen brightness
#bindsym XF86Search exec ~/.config/i3/bright.sh 1 # decrease screen brightness
#bindsym F5 exec ~/.config/i3/bright.sh -d # decrease screen brightness
#bindsym F6 exec ~/.config/i3/bright.sh -u # increase screen brightness

# ROFI
bindsym $mod+space   exec rofi -show combi -display-window "W"
bindsym $mod+P       exec --no-startup-id ~/.config/rofi/rofi-pass.sh
bindsym $mod+o       exec --no-startup-id ~/.config/rofi/www.sh
bindsym $mod+Shift+o exec --no-startup-id ~/.config/rofi/www-incognito.sh
bindsym $mod+s       exec --no-startup-id ~/.config/rofi/web-search.sh
bindsym $mod+Shift+b exec --no-startup-id ~/.config/rofi/books-search.sh
bindsym $mod+Shift+s exec --no-startup-id ~/.config/rofi/slack.sh

# Lock with 
bindsym $mod+Shift+F12 exec --no-startup-id i3lock -i ~/var/media/backgrounds/astrobin/`ls -Ar ~/var/media/backgrounds/astrobin/ | tail -n 1` -t

# BACKGROUND
#exec hsetroot -cover ~/var/media/backgrounds/bing/`ls -A ~/var/media/backgrounds/bing | tail -n 1`

##### APP BINDS ###################################

bindsym $mod+n             exec $qute --target window
bindsym $mod+Shift+n       exec $qute --target private-window

bindsym $mod+Shift+c exec org-capture

bindsym $mod+Shift+y exec xfreerdp /u:powellc /p:mainroot /v:telesto.local /w:1200 /h:700
bindsym $mod+Ctrl+y exec pkill xfreerdp

bindsym Print exec --no-startup-id flameshot gui
bindsym $mod+F6 exec --no-startup-id $surf https://15five.slack.com

bindsym F7 exec --no-startup-id $qute https://15five-dev.atlassian.net/secure/Dashboard.jspa
bindsym $mod+F7 exec --no-startup-id $qute https://app.datadoghq.com/logs

bindsym F8 exec --no-startup-id $firefox https://15five.15five.com/report/current/
bindsym $mod+F8 exec --no-startup-id $firefox

bindsym F9 exec --no-startup-id $qute https://my.five.unbl.ink/
bindsym $mod+F9 exec --no-startup-id $qute https://my.five.unbl.ink/admin/dj/

bindsym F10 exec --no-startup-id $qute https://admin.cloud100.15five.com/admin/dj
bindsym $mod+F10 exec --no-startup-id $qute

bindsym F11 exec --no-startup-id $qute https://15five.my.salesforce.com
bindsym $mod+F11 exec --no-startup-id $qute https://15five--15fivesb.my.salesforce.com

bindsym F12 exec --no-startup-id $qute https://wx.unbl.ink
bindsym $mod+F12 exec --no-startup-id $qute https://podcasts.unbl.ink/

bindsym $mod+Insert exec --no-startup-id zathura ~/var/documents/15five/strengths.pdf

bindsym $mod+Home exec --no-startup-id snapclient -h mopidy2.local
bindsym $mod+Shift+Home exec --no-startup-id pkill snapclient

bindsym $mod+e       exec emacsclient -cnq
bindsym $mod+Shift+e exec emacs --daemon
bindsym $mod+Ctrl+e exec pkill emacs

##### LAUNCH ######################################

# STARTUP
exec --no-startup-id unclutter -grab
exec --no-startup-id nm-applet
exec --no-startup-id copyq

# RELOAD
exec --no-startup-id picom --config ~/.config/compton/compton.conf
exec --no-startup-id dunst
#exec --no-startup-id syncthing
exec xrdb --merge ~/.Xresoureces


# Set wallpaper and keyboard mappings
exec_always --no-startup-id changepaper
exec_always setxkbmap -model pc105 -layout us,ru -option grp:ctrls_toggle -option caps:escape -option compose:ralt

## Volume control
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks
bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks
bindsym XF86AudioMute exec amixer -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks
bindsym XF86AudioMicMute exec amixer -D pulse sset Capture toggle && pkill -RTMIN+1 i3blocks
bindsym F1 exec amixer -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks
bindsym F2 exec amixer -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks
bindsym F3 exec amixer -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks
bindsym F4 exec amixer -D pulse sset Capture toggle && pkill -RTMIN+1 i3blocks
bindsym $mod+z exec amixer -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks
bindsym $mod+x exec amixer -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks
bindsym $mod+a exec amixer -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks
#bindsym $mod+Home exec --no-startup-id cvlc https://stream.unbl.ink/mopidy
#bindsym $mod+Shift+Home exec --no-startup-idcvlc https://playerservices.streamtheworld.com/api/livestream-redirect/WMEAFM.mp3
bindsym $mod+End exec pkill vlc

# Iapetus central volume
#@bindsym $mod+. exec ssh iapetus.local down
#@bindsym $mod+Shift+. exec ssh iapetus.local up
#@bindsym $mod+Alt+. exec ssh iapetus.local playu
#@bindsym $mod+Ctrl+. exec ssh iapetus.local "pkill vlc"

bindsym $mod+d exec rofi -modi drun -show drun \
		-config ~/.config/rofi/rofidmenu.rasi

#bindsym F9 exec rofi -modi drun -show drun \
#		-config ~/.config/rofi/rofidmenu.rasi

## rofi bindings for window menu ($mod+t /F10 optional disabled)

bindsym $mod+t exec rofi -show window \
		-config ~/.config/rofi/rofidmenu.rasi
