# Please see https://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4
set $LeftMonitor HDMI-0
set $RightMonitor DP-4

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8

workspace_auto_back_and_forth yes

# 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

# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status

bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause
bindsym XF86AudioNext exec --no-startup-id playerctl next
bindsym XF86AudioPrev exec --no-startup-id playerctl previous

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

# move tiling windows via drag & drop by left-clicking into the title bar,
# or left-clicking anywhere into the window while holding the floating modifier.
tiling_drag modifier titlebar

# start a terminal
bindsym $mod+q exec kitty
bindsym $mod+e exec thunar
#bindsym Print exec --no-startup-id maim --select | xclip -selection clipboard -t image/png

bindsym Print exec --no-startup-id flameshot gui
# kill focused window
bindsym $mod+c kill
# lock with wallpaper
bindsym $mod+Shift+l exec --no-startup-id loginctl lock-session

#####################################
# Application menu handled by rofi: #
#####################################

## rofi bindings fancy application menu ($mod+d /F9 optional disabled)

bindsym $mod+space exec --no-startup-id rofi -modi drun -show drun \
		-config ~/.config/rofi/rofidmenu.rasi 

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

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

bindsym $mod+a exec --no-startup-id rofi -show window \
		-config ~/.config/rofi/rofidmenu.rasi
bindsym $mod+period exec --no-startup-id rofimoji
#bindsym F10 exec --no-startup-id rofi -show window \
#		-config ~/.config/rofi/rofidmenu.rasi

## rofi bindings to manage clipboard (install rofi-greenclip from the AUR)

#exec --no-startup-id greenclip daemon>/dev/null
#bindsym $mod+c exec --no-startup-id rofi -modi "clipboard:greenclip print" -show clipboard \
#		-config ~/.config/rofi/rofidmenu.rasi


# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus 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

# switch between windows with alt tab
bindsym Mod1+Tab focus next

# 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

# 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+h split h

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

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+Shift+s layout stacking
bindsym $mod+Shift+w layout tabbed
bindsym $mod+Shift+e layout toggle split

# toggle tiling / floating
bindsym $mod+v 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

# 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:Discord"
set $ws10 "10:Firefox"

# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10

# 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-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 $mod+Shift+p exec --no-startup-id systemctl suspend
# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # 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

        # same bindings, but for the arrow keys
        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

        # 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 {
#        status_command i3status
#}

##############################
# extra options for windows: #
##############################
default_border pixel 1
# Set inner/outer gaps
gaps inner 2 
gaps outer 0 

# show window title bars (not officially supported with i3gaps)
#default_border normal
default_border pixel 2
# window title alignment
#title_align center

workspace $ws9 output $LeftMonitor
workspace $ws10 output $LeftMonitor

assign [class="discord"] $ws9

##############
# compositor #
##############

# transparency
# uncomment one of them to be used
# options could need changes, related to used GPU and drivers.
# to find the right setting consult the archwiki or ask at the forum.
#
# xcompmgr: https://wiki.archlinux.org/title/Xcompmgr
# manpage: https://man.archlinux.org/man/xcompmgr.1.en
# install xcompmgr package to use it (yay -S xcompmgr)
#exec --no-startup-id xcompmgr -C -n &
# or an more specialized config like this:
#exec --no-startup-id xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 &
#
# or:
#
# picom: https://wiki.archlinux.org/title/Picom
# manpage: https://man.archlinux.org/man/picom.1.en
# The default configuration is available in /etc/xdg/picom.conf 
# For modifications, it can be copied to ~/.config/picom/picom.conf or ~/.config/picom.conf
# install picom package (yay -S picom)
# start using default config 
#exec_always --no-startup-id picom -b
#
# for custom config:

#############################################
# autostart applications/services on login: #
#############################################

exec_always autotiling
#fix monitor layout
exec --no-startup-id "xrandr --output $LeftMonitor --left-of $RightMonitor && xrandr --output $RightMonitor --mode 2560x1440 --rate 165.00 --primary"

# Start XDG autostart .desktop files using dex. See also
# https://wiki.archlinux.org/index.php/XDG_Autostart
exec --no-startup-id dex --autostart --environment i3

# start picom compositor
#exec --no-startup-id picom --config  ~/.config/picom/picom.conf

#status bar
exec --no-startup-id ~/.config/i3/scripts/launch-polybar.sh

# network manager applet
exec --no-startup-id nm-applet


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

# set lock timeout to 20 minutes
exec_always --no-startup-id xset dpms 0 0 1200 &
exec --no-startup-id xss-lock --transfer-sleep-lock -- ~/.config/i3/scripts/lock.sh
# prevent screen locking, has xdg autostart
# exec --no-startup-id caffeine


# 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_always --no-startup-id nm-tray
#exec --no-startup-id nm-applet
#get auth work with polkit-gnome
#exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1

# dex execute .desktop files + apps using /etc/xdg/autostart.
# when second to i3 a DE is installed or mixed usage of i3 + xfce4 or GNOME
# in this cases better disable dex and use manual starting apps using xdg/autostart
# if enabled you should comment welcome app.
# https://github.com/jceb/dex
#exec --no-startup-id dex -a -s /etc/xdg/autostart/:~/.config/autostart/
#exec --no-startup-id dex --autostart --environment i3 
#exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
# start welcome app
#exec --no-startup-id sh /usr/share/endeavouros/scripts/welcome --startdelay=3 

# num lock activated
#exec --no-startup-id numlockx on

# configure multiple keyboard layouts and hotkey to switch (Alt+CAPSLOCK in this example)
#exec --no-startup-id setxkbmap -layout 'us,sk' -variant altgr-intl,qwerty -option 'grp:alt_caps_toggle'

# start conky:
#exec_always --no-startup-id conky

# start a script to setup displays
# uncomment the next line, use arandr to setup displays and save the file as monitor:
#exec --no-startup-id ~/.screenlayout/monitor.sh

# set wallpaper
# exec --no-startup-id sleep 2 && nitrogen --restore
exec_always --no-startup-id sleep 1 && feh --bg-fill $HOME/.config/wallpapers/yuyukowallpaper.png

# set default microphone input
exec_always --no-startup-id sleep 5 && pactl list short sources | grep 'alsa_input.usb-Razer' | awk '{print $2}' | xargs pactl set-default-source 

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

# disable power saving (for example if using xscreensaver)
#exec --no-startup-id xset -dpms

#blur enable
#blur_xray enable
#blur_passes 2
#blur_radius 5

# use xautolock to use autosuspend rules for mobile devices
# https://wiki.archlinux.org/title/Session_lock#xautolock
#exec --no-startup-id xautolock -time 60 -locker "systemctl suspend"


# xscreensaver
# https://www.jwz.org/xscreensaver
#exec --no-startup-id xscreensaver --no-splash

# Desktop notifications
# dunst config used ~/.config/dunst/dunstrc
# set alternative config if needed:
#exec --no-startup-id /usr/bin/dunst --config ~/.config/dunst/dunstrc
# may need to run dbus-launch explicitly: 
#exec --no-startup-id dbus-launch /usr/bin/dunst
exec --no-startup-id /usr/bin/env dunst
# alternative if you installed aside with XFCE4:
# exec --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd &

# autotiling script
# https://github.com/nwg-piotr/autotiling
# `yay -S autotiling ;) (it is in AUR)
#exec_always --no-startup-id autotiling

# Autostart apps as you like
#exec --no-startup-id sleep 2 && xfce4-terminal
#exec --no-startup-id sleep 7 && firefox https://github.com/endeavouros-team/endeavouros-i3wm-setup/blob/main/force-knowledge.md
#exec --no-startup-id sleep 3 && thunar
exec --no-startup-id i3-msg workspace $ws9; exec discordcanary 
exec --no-startup-id i3-msg workspace $ws10; exec firefox

###############
# system tray #
###############
# if you do not use dex: exec --no-startup-id dex --autostart --environment i3
# you need to have tray apps started manually one by one:

# start blueberry app for managing bluetooth devices from tray:
#exec_always --no-startup-id blueberry-tray

# networkmanager-applet
# clipman-applet
#exec --no-startup-id xfce4-clipman


######################################
# color settings for bar and windows #
######################################

# Define colors variables:
set $darkbluetrans 	#313244	
set $darkblue		#b4befe 
set $lightblue	        #eba0ac	
#set $urgentred		#e53935

set $urgentred		#f38ba8	
set $white		#cdd6f4	
set $black		#1e1e2e  	
set $purple		#6870A1
set $darkgrey		#383c4a
set $grey		#b0b5bd
set $mediumgrey		#8b8b8b
set $yellowbrown	#e1b700

# define colors for windows:
#class		        	border		bground		text		indicator	child_border

client.focused		    	$darkblue       $black          $white		$darkblue	$darkblue 
client.unfocused	    	$purple	 	 $black   	$grey		$darkgrey		$darkgrey
client.focused_inactive		$black   	$black  	$grey		$darkgrey		$darkgrey
client.urgent		    	$urgentred	$urgentred	$white		$darkblue	$yellowbrown
############################################
# bar settings (input comes from i3blocks) #
############################################

# Start i3bar to display a workspace bar
# (plus the system information i3status finds out, if available)
#bar {
#id bar-primary
#mode dock 
#		font pango: FiraCode Nerd Font medium 11.3
#                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_output none
#tray_output none
## 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
#		    background	#1e1e2eD9
#		    statusline         $white
##                          		border 		        bg		txt	
#		focused_workspace	#1e1e2eD9		#1e1e2eD9	#b4befe 	
#		active_workspace	#1e1e2eD9	      	#1e1e2eD9 	#a6adc8		
#		inactive_workspace	#1e1e2eD9 		#1e1e2eD9	#7f849c		
#		urgent_workspace	#1e1e2eD9    		#1e1e2eD9  	#a6e3a1  	
#
#	}
#}
#
#bar {
#id bar-tray
#mode invisible 
#		font pango: FiraCode Nerd Font medium 11.3
#                status_command i3blocks -c ~/.config/i3/i3blocks.conf
#	    	position top 
##modifier none
##	    	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
#
## 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
#		    background	#1e1e2eD9 
#		    statusline         $white
##                          		border 		        bg		txt		
#		focused_workspace	#1e1e2eD9	   	#1e1e2eD9 	#cdd6f4 	
#		active_workspace	#1e1e2eD9 	      	#1e1e2eD9 	#a6adc8		
#		inactive_workspace	#1e1e2eD9   		#1e1e2eD9	#7f849c		
#		urgent_workspace	#1e1e2eD9	    	#1e1e2eD9  	#a6e3a1  	
#	}
#}
#bindsym $mod+p bar mode dock bar-tray; bar mode invisible bar-primary
