#######################################
#  _____  ____                        #
# |_   _||___ \                       #
#   | |    __) |__      __ _ __ ___   #
#   | |   |__ < \ \ /\ / /| '_ ` _ \  #
#  _| |_  ___) | \ V  V / | | | | | | #
# |_____||____/   \_/\_/  |_| |_| |_| #
#                                     #
#######################################

#############################################
#         General configurations            #
#############################################

# font
#set $font "pango:DejaVu Sans Mono for Powerline 10"
#set $font "pango:Source Code Pro for Powerline 10"
set $font "pango:IBM Plex Mono, FontAwesome 6 Free 11"
font $font

# floating modifier
# mod1 = Alt (xmodmap to show)
# mod4 = Winkey (xmodmap to show)
set $mod mod4
floating_modifier $mod

# focus follows mouse
focus_follows_mouse no

# no window decorations
new_window pixel 1

# gaps
gaps inner 10
gaps outer 10

#############################################
#              Script Section               #
#############################################

#
# "xev" and "showkeys" can be usefull to determine the keycodes.
#

# display brightness management (laptop)
bindsym XF86MonBrightnessUp     exec --no-startup-id "xbacklight +10"
bindsym XF86MonBrightnessDown   exec --no-startup-id "xbacklight -10"
# webcam
bindsym XF86WebCam              exec --no-startup-id "cheese"
# screenshot
bindsym $mod+F4                 exec --no-startup-id "gnome-screenshot -w"
# start dmenu-launcher
bindsym $mod+d                  exec --no-startup-id rofi -show drun -theme gruvbox-dark-soft -font "mono 10"
# lock i3 with i3lock
bindsym $mod+Shift+x            exec --no-startup-id i3lock -c 000000

#############################################
#                  Keymaps                  #
#############################################

# start terminal
#bindsym $mod+Return             exec --no-startup-id kitty
bindsym $mod+Return             exec --no-startup-id alacritty

# kill focused window
bindsym $mod+Shift+q            kill

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

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

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

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

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

# 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+space        floating toggle

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

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

# reload the configuration file
bindsym $mod+Shift+c            reload

# restart i3 inplace
bindsym $mod+Shift+r            restart

# exit i3
bindsym $mod+Shift+e            exec "i3-nagbar -t warning -m 'Exit i3?' -b 'Yes' 'i3-msg exit'"

# enter the resize mode
bindsym $mod+r                  mode "resize"

# scratchpad
bindsym $mod+y                  scratchpad show
bindsym $mod+x                  move scratchpad

# Use pactl to adjust volume in PulseAudio.
bindsym XF86AudioRaiseVolume    exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +1%
bindsym XF86AudioLowerVolume    exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -1%
bindsym XF86AudioMute           exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute        exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle

#############################################
#             Workspace & Tags              #
#############################################

# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

#############################################
#             Resize handling               #
#############################################

mode "resize" {
    # bindings to resize
    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
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

#############################################
#                 Colors                    #
#############################################

# primary gruvbox colorscheme
set $bg       #282828
set $bg0      #282828
set $bg1      #3c3836
set $bg2      #504945
set $bg3      #665c54
set $bg4      #7c6f64
set $fg       #ebdbb2
set $red      #cc241d
set $green    #98971a
set $yellow   #d79921
set $blue     #458588
set $purple   #b16286
set $aqua     #689d68
set $grey     #a89984
set $darkgrey #1d2021
set $white    #000000

# workspace config
# class                  border    backgr    text   indicator child_border
client.focused           $bg2      $bg2      $bg    $bg4      $bg2
client.focused_inactive  $darkgrey $darkgrey $bg2   $bg       $darkgrey
client.unfocused         $darkgrey $darkgrey $bg2   $bg       $darkgrey
client.urgent            $red      $bg2      $red   $bg       $red

#############################################
#                 i3-bar                    #
#############################################

bar {
    font $font
    position top
    status_command i3status-rs ~/.config/i3status-rust/config.toml
    colors {
        background #222439 # -> BG of Wallpaper for fake transparency
        statusline $yellow
        # class              border     backgr    text
        focused_workspace    $darkgrey  $grey     $darkgrey
        inactive_workspace   $darkgrey  $darkgrey $grey
        active_workspace     $darkgrey  $darkgrey $grey
        urgent_workspace     $red       $darkgrey $red
    }
}

#############################################
#            specific windows               #
#############################################

# always floating
for_window [class="Gedit"]          floating enable
for_window [class="Teamspeak3"]     floating enable

# 0px Border
for_window [class="chrome"]         border none
for_window [class="firefox"]        border none

#############################################
#            auto start with i3             #
#############################################

# composite manager
exec --no-startup-id picom -b --config ~/.config/picom.conf
# less eye pain
exec --no-startup-id redshift -l 46.95:7.45 -t 6500:3000
# start notification daemon
exec --no-startup-id dunst -config ~/.config/dunstrc
# no beep!
exec --no-startup-id xset b off
# wallpaper
exec --no-startup-id feh --bg-fill ~/.config/wallpapers/gentoo.jpg
# syncthing
exec --no-startup-id syncthing --no-browser
# use lockscreen as screensaver (needs xss-lock installed)
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -c000000 --nofork
