# KeY's I3 COnfig file

#########################################################################
# VARIABLES																#
#########################################################################
# SYSTEM #
##########
# Refreshes the I3 interface
set $refresh_i3status killall -SIGUSR1 i3status # Set MOD key do the windows Key : Mod4
# Sets mode key to windows key
set $mod Mod4

########
# USER #
########

set $usrBorderFocusColor				#282a36
set $usrBorderFocusLineColor			#ff79c6
set $usrBorderFocusTextColor			#50fa7b
set $usrBorderFocusedIndicatorColor		#ff79c6	
set $usrBorderFocusChildLineColor		#ff79c6

set $usrBorderUnFocusColor				#282a36C0
set $usrBorderUnFocusLineColor			#ff79c6C0
set $usrBorderUnFocusTextColor			#6272a4
set $usrBorderUnFocusedIndicatorColor	#ff79c6	
set $usrBorderUnFocusChildLineColor		#ff79c6

set $usrBorderGaps 5

# Default treminal to use
set $defTerm "alacritty -e fish"
set $defTermClass "Alacritty"
# Default web browser
set $defWebBrowser "firefox" 
set $defWebBrowserClass "Firefox-esr" 
# Default Music player
set $defMusicPlayer "spotify"
set $defMusicPlayerClass "Spotify"
#default Notes program. 
set $defNotes "QOwnNotes"
set $defNotesClass "QOwnNotes"
# Default mail program
set $defMail "evolution"
set $defMailClass "Evolution"
# Default Menu Launcher
set $defMenuLauncher "dmenu_run"
# Default Wallpaper MananSr : it will be automatically Launched At start
set $defWallpaperManager "feh --bg-fill --randomize $HOME/wallpaper/*" 
# Default Window compositor (fomr, rounded corners, tasparency and so on) :it will be automatically Launched At start 
set $defWindowCompositor "picom --experimental-backends --config ~/.config/picom/picom.conf"
# Default sleep time ! it is needed during to startup auto launches to wait for programs to launch on the given workspace 
# before switching to the other workspace
set $defSleep "sleep 5" 

# Define names for default workspaces for which we configure key bindings later on.
set $ws1 "1:DEV"
set $ws2 "2:TERM"
set $ws3 "3:WEB"
set $ws4 "4:NOTES"
set $ws5 "5:MAIL"
set $ws6 "6:PLAY"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"

############
# COMMANDS #
############
#https://community.spotify.com/t5/Desktop-Linux/Basic-controls-via-command-line/td-p/4295625
#Sets media key for music player
set $playerPause "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
set $playerPlayPause "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
set $playerPrevious "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
set $playerNext "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"

#set's media key for sound controls
set $audioVolumeUp --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
set $audioVolumeDown --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
set $audioMute --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
set $audioMuteMic --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status

# Sreen brightness controls
set $brightnessIncrease "xbacklight -inc 20"
set $brightnessDecrease "xbacklight -dec 20" 

#########################################################################
# LAUNCHERS USER DEFINED SHORCUTS TO LAUNCH PROGRAMMS OR ACTIONS		#
#########################################################################
# USER #
########
#Launch Terminal
bindsym $mod+Return exec $defTerm
#Kill current window
bindsym $mod+c kill
# Launch Menu Launcher
bindsym $mod+p exec --no-startup-id $defMenuLauncher
# Launch Note app 
bindsym $mod+n exec $defNotes
# Launch web Browser
bindsym $mod+i exec $defWebBrowser
# Launch Music Player
bindsym $mod+u exec $defMusicPLayer 
# Launch web Browser
bindsym $mod+m exec $defMail

# IMplment music player media butttons
bindsym XF86AudioPause exec $playerPause
bindsym XF86AudioPlay exec $playerPlayPause 
bindsym XF86AudioPrev exec $playerPrevious 
bindsym XF86AudioNext exec $playerNext

# Implment volume control buttons to work as intended
bindsym XF86AudioRaiseVolume exec $audioVolumeUp 
bindsym XF86AudioLowerVolume exec $audioVolumeDown 
bindsym XF86AudioMute exec $audioMute 
bindsym XF86AudioMicMute exec $audioMuteMic 

# Sreen brightness controls
bindsym XF86MonBrightnessUp exec $brightnessIncrease 
bindsym XF86MonBrightnessDown exec $brightnessDecrease 

# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+q exec i3-msg exit
#bindsym $mod+Shift+q 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'"

#########################################################################
# CUSTOMISATION															#
#########################################################################
# USER #
########
# Font for window titles. Will also be used by the bar unless a different font
font pango:monospace 14

# COLORO SCHEME
# class					border						backgr.					text							indicator							child_border
client.focused			$usrBorderFocusLineColor	$usrBorderFocusColor	$usrBorderFocusTextColor		$usrBorderFocusedIndicatorColor		$usrBorderFocusChildLineColor
client.focused_inactive $usrBorderUnFocusLineColor	$usrBorderUnFocusColor	$usrBorderUnFocusedTextColor	$usrBorderUnFocusedIndicatorColor	$usrBorderUnFocusChildLineColor
client.unfocused        #333333 #222222 #888888 #292d2e   #222222
client.urgent           #2f343a #900000 #ffffff #900000   #900000
client.placeholder      #000000 #0c0c0c #ffffff #000000   #0c0c0c
client.background       #F8F8F2

gaps inner $usrBorderGaps
gaps outer $usrBorderGaps

for_window [tiling_from="user"] border pixel 3
for_window [tiling_from="auto"] border pixel 3
for_window [floating_from="auto"] border pixel 5
for_window [floating_from="user"] border pixel 5

#########################################################################
# STARTUP																#
#########################################################################
# SYSTEM #
##########
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
# they are included here as an example. Modify as you see fit.
# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
# NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it.
exec --no-startup-id nm-applet
#Display
exec xrandr --output HDMI-0 --rotate right

########
# USER #
########

# Asing certain programms to certain workspaces.
assign [class=$defTermClass] $ws2
assign [class=$defWebBrowserClass] $ws3
assign [class=$defNotesClass] $ws4
assign [class=$defMailClass] $ws5
# This is special for spotify who has issue to to comply with the assign command
for_window [class=$defMusicPlayerClass] move to workspace $ws6

# Open web terminal
exec --no-startup-id i3-msg exec $defTerm 
# Open web browser
exec --no-startup-id i3-msg exec $defWebBrowser 
# Open note Taking app
exec --no-startup-id i3-msg exec $defNotes 
# Open Mail Client
exec --no-startup-id i3-msg exec $defMail 
# Open Music player
exec --no-startup-id i3-msg exec $defMusicPlayer 

#Switch to workspace 1 and ready for workflow
exec --no-startup-id i3-msg workspace $ws1

# Lauches Wallpaper engine
exec --no-startup-id $defWallpaperManager 
# Lauches Window Compositor (transparency and so on ...)
exec --no-startup-id $defWindowCompositor 

#########################################################################
# WINDOW ACTION 														#
#########################################################################
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

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

# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

# split in horizontal orientation
bindsym $mod+x split h

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

# 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+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+f floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent
#bindsym $mod+s focus child


# 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+0 workspace $ws10

# move focused container 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+Shift+0 move container to workspace $ws10


# Back anmd forth Workspace Switching Alt+Tab
bindsym Mod1+Tab workspace back_and_forth

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode
        # Pressing down will grow the window’s height.
        bindsym h resize shrink width 10 px or 10 ppt
        bindsym j resize grow height 10 px or 10 ppt
        bindsym k resize shrink height 10 px or 10 ppt
        bindsym l resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape or $mod+r
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
	position top
	status_command i3status
  colors {
    background #282A36
    statusline #F8F8F2
    separator  #44475A

    focused_workspace  #44475A #44475A #F8F8F2
    active_workspace   #282A36 #44475A #F8F8F2
    inactive_workspace #282A36 #282A36 #BFBFBF
    urgent_workspace   #FF5555 #FF5555 #F8F8F2
    binding_mode       #FF5555 #FF5555 #F8F8F2
  }
}

