#########     Configuration    #########
###           the easy stuff         ###
    font pango: SF Pro Display 14

    # Key to do all the things (Mod1=Alt, Mod4=Super/Windows)
        set $mod Mod4

    # Home row direction keys, like vim
        set $left h
        set $down j
        set $up k
        set $right l

    # Default Terminal
        set $term urxvt

    # Autofocus on hover, also when switching workspaces
        focus_follows_mouse always

    # Rebind capslock to escape
        input "type:keyboard" { 
            xkb_options caps:escape
        }

    # Include scripts or configs
        include /etc/sway/config.d/*

    # Borders
        # Also removes all title bars
        for_window [class="^.*"] border pixel 4
        default_border pixel 4

        # Floating windows get no borders >:(
        default_floating_border pixel 4

        # Hide borders at the edge of the screen
        hide_edge_borders smart

        # Set colours various window states
        # Syntax: client.<class> <border> <background> <text> [<indicator> [<child_border>]]
        # The available classes are:
            # client.focused: The window that has focus.
            # client.focused_inactive: The most recently focused view within a container which is not focused.
            # client.placeholder: Ignored (present for i3 compatibility).
            # client.unfocused: A view that does not have focus.
            # client.urgent: A view with an urgency hint. Note: Native Wayland windows do not support urgency. Urgency only works for Xwayland windows.
        #The meaning of each color is:
            # border: The border around the title bar.
            # background: The background of the title bar.
            # text: The text color of the title bar.
            # indicator: The color used to indicate where a new view will open. In a tiled container, this would paint the right border of the current view if a new view would be opened to the right.
            # child_border: The border around the view itself.
        # The default colors are:
            # class	        border	background	text    indicator	child_border			
            # background	n/a	    #ffffff     n/a	    n/a	        n/a
            # focused	    #4c7899	#285577	    #ffffff	#2e9ef4	    #285577
            # focused_inactive	#333333	#5f676a	#ffffff	#484e50	    #5f676a
            # unfocused	    #333333	#222222	    #888888	#292d2e	    #222222
            # urgent	    #2f343a	#900000	    #ffffff	#900000	    #900000
            # placeholder	#000000	#0c0c0c	    #ffffff	#000000 	#0c0c0c
        client.focused           #343b58 #343b58 #c0caf5 #343b58   #343b58
        client.focused_inactive  #16161d #16161d #c0caf5 #16161d   #16161d
        client.unfocused         #16161d #16161d #c0caf5 #16161d   #16161d

    # Gaps
        # gaps inner|outer|horizontal|vertical|top|right|bottom|left <amount>
        # Sets default amount pixels of inner or outer gap
        # the inner affects spacing around each view
        # the outer affects the spacing around each workspace
        # To reduce or remove outer gaps, outer gaps can be set to a negative value.
        gaps inner 0
        gaps outer 0
        gaps top 0
        gaps bottom 0

        # Hide gaps when there is only 1 window
        smart_gaps on


#########       Launchers      #########
###         Menu for commands        ###

    # Program Launcher
        set $menu rofi -no-config -no-lazy-grab -show drun -modi drun -theme ~/.config/wofi/launcher.rasi
        bindsym $mod+d exec $menu

    # Power menu
        bindsym $mod+P exec /home/marco/.config/wofi/wofi-power.sh


######### Output Configuration #########
###          Monitors n shit         ###

    # Wallpaper
        #output * bg /home/marco/Pictures/bliss_windows_night.png fill
        output * bg #16161d solid_color

    # NOTE: We are using kanshi to automagically setup screens
    # See https://github.com/emersion/kanshi


#########    Key Bindindings   #########
###          (I use Arch BTW)        ###

    # Start a terminal
        bindsym $mod+Return exec $term

    # Switch workspace to another monitor
        bindsym $mod+Shift+h move workspace to output left
        bindsym $mod+Shift+Tab move workspace to output left
        bindsym $mod+Shift+j move workspace to output down
        bindsym $mod+Shift+k move workspace to output up
        bindsym $mod+Shift+l move workspace to output right
        bindsym $mod+Tab move workspace to output right

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

    # Resize/move (floating and tiled) windows with mouse
    # inverse: $mod+left click = resize    $mod + right click = move window
        floating_modifier $mod inverse

    # reload sway
        bindsym $mod+Shift+c reload

    # Exit sway 
        bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'

    #prev/next workspace. bind it to your mouse if you have a sticky keyboard
        bindsym $mod+Shift+o workspace prev_on_output
        bindsym $mod+Shift+p workspace next_on_output

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

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

    # Split direction
    # NOTE: we are using autotiling based on window dimensions
    # See https://github.com/nwg-piotr/autotiling
        bindsym $mod+b splith
        bindsym $mod+v splitv

    # Make the current focused window fullscreen
        bindsym $mod+f fullscreen

    # Toggle focused window tiled/floating
        bindsym $mod+Shift+t floating toggle

    # Swap focus between the tiling area and the floating area
        bindsym $mod+t focus mode_toggle

    # Move the currently focused window to the scratchpad
        bindsym $mod+Shift+s move scratchpad

    # Cycle through windows in the scratchpad
        bindsym $mod+s scratchpad show

    # Media keys
        bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10%
        bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10%
        bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
        bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle

    # Sreen brightness controls
        bindsym XF86MonBrightnessDown exec light -U 5
        bindsym XF86MonBrightnessUp exec light -A 5

    # Screenshot / share shortcuts
        bindsym Print exec "grim /home/marco/screenShares/Screenshot-$(date -Iseconds | cut -d'+' -f1).png"
        bindsym $mod+Print exec grim -g "$(slurp)" - | wl-copy
        bindsym $mod+Shift+Print exec "wf-recorder -a -o eDP-1 -f /home/marco/screenShares/Screenstream-$(date -Iseconds | cut -d'+' -f1).mp4"


#########  Resizing Containers #########
### $mod+mouseClick works better tho ###

    mode "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

        # 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

        # easier than quitting vim
            bindsym Return mode "default"
            bindsym Escape mode "default"
            bindsym $mod+r mode "default"
    }
    bindsym $mod+r mode "resize"


#########   Window Properties  #########
###   Floating/Tiling / Workspaces   ###

    # Wayland default floats
        for_window [app_id="gnome-(calendar|calculator|power-statistics|control-center)"] floating enable
        for_window [app_id="org.gnome.(Nautilus|Weather)"] floating enable
        for_window [app_id="(pavucontrol|psensor)"] floating enable
        for_window [app_id="evolution-alarm-notify"] floating enable
        for_window [app_id="nemo"] floating disable
        for_window [app_id="solaar"] floating enable
        for_window [app_id="evolution" title="Compose Message"] floating enable
        for_window [app_id="evolution" title="Re(.*)"] floating enable
        for_window [app_id="evolution" title="Fwd(.*)"] floating enable
        for_window [app_id="mpv"] floating enable
        for_window [app_id="mpv"] resize set 960 540
        for_window [app_id="mpv"] border pixel 0
        for_window [app_id="firefox" title="Firefox — Sharing Indicator"] floating enable
        for_window [app_id="firefox" title="Picture-in-Picture"] floating enable
        for_window [app_id="firefox" title="Pushbullet – Mozilla Firefox"] floating enable
        for_window [app_id="firefox" title="About Mozilla Firefox"] floating enable
        for_window [class="Gimp-2.10"] floating disable
        for_window [class="Gimp-2.10" title="New Image"] floating enable
        for_window [class="Gimp-2.10" title="Layer"] floating enable
        for_window [class="Gimp-2.10" title="Tool"] floating enable
        for_window [class="Gimp-2.10" title="Option"] floating enable
        for_window [class="Gimp-2.10" title="Change"] floating enable

    # Brave, chrome, chromium
        for_window [title="Picture-in-picture"] floating enable

    # XWayland default floats
        #for_window [class="[.]*"] floating enable

    # Assign programs to workspace
        assign [class="firefox"] → number 2
        assign [app_id="firefox"] → number 2
        assign [class="code"] → number 4
        assign [class="discord"] → number 5
        assign [class="Spotify"] → number 6
        assign [class="Audacity"] → number 6
        assign [class="Gmpc"] → number 6
        assign [app_id="ario"] → number 6
        assign [class="Thunderbird"] → number 8
        assign [class="Bitwarden"] → number 9
        # Some programs can be stubborn since they open a splash window before opening
        for_window [class="discord"] move to workspace number 5
        for_window [class="Spotify"] move to workspace number 6
        for_window [class="Gimp-2.10"] move to workspace number 7
        for_window [class="Gimp"] move to workspace number 7


#########   Launch Programs  #########
###        We need dis stuff       ###

# Notification thing
    exec mako 

# Applets
    exec nm-applet --indicator 
    exec blueman-applet 

# Arch update notifications
    exec kalu 

# Gnome Keyring
    exec eval $(gnome-keyring-daemon --start)
    exec export SSH_AUTH_SOCK

# Clipboard manager
    exec wl-paste -t text --watch clipman store

# fingerprint reader
    exec lxsession

# Auto set monitor properties
    exec_always pkill kanshi; exec kanshi

# Autotiling based on window dimensions
    exec autotiling

# start initial programs
    # TODO: We still need to something similar to i3 layouts
    exec firefox &
    exec code &
    exec discord &
    exec spotify &
    exec ario &
    exec gimp &
    exec bitwarden &
    exec thunderbird &

# Finally start waybar
    exec /home/marco/.config/waybar/launch.sh































































###### Bag of Holding ######
###     remove later     ###

    # Workaround for GTK apps hanging during init
    # See https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start
    # See https://github.com/swaywm/sway/issues/5732
    #exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
    #exec dbus-update-activation-environment 2>/dev/null && \
    #     dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
    # End of workaround

    ### Status Bar:
    #
    #bar {
    #    position top
    #
    #    # When the status_command prints a new line to stdout, swaybar updates.
    #    # The default just shows the Rcurrent date and time.
    #    status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done
    #
    #    colors {
    #        statusline #ffffff
    #        background #323232
    #        inactive_workspace #32323200 #32323200 #5c5c5c
    #    }
    #}

    # set $menu wofi --show=drun --lines=5 --prompt="" --hide-scroll --insensitive --columns=2
    # bindsym $mod+d exec /home/marco/.config/wofi/launch.sh

######