### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4

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

# Your preferred terminal emulator
set $term foot
set $term_float footclient -a floating_shell
set $term_float_portrait footclient -a floating_shell_portrait

# wofi theme
set $wofi_theme "* {lightbg: $background-color; background: $background-color; lightfg: $accent-color;}"

# Your preferred application launcher
set $menu wofi --show drun --allow-images --allow-markup --hide-scroll --no-actions -theme-str $wofi_theme -lines 10 -width 35

# Add --to-code to bindsym, support for non-latin layouts
set $bindsym bindsym --to-code

# Onscreen bar (WOB)
set $onscreen_bar bash /usr/share/sway/scripts/wob.sh "$accent-colorFF" "$background-colorFF"

# brightness control
set $brightness_step bash -c 'echo $(( $(light -Mr) / 100 * 5 < 1 ? 1 : $(( $(light -Mr) / 100 * 5 )) ))'
set $brightness_up light -r -A $($brightness_step) && $onscreen_bar $(light -G | cut -d'.' -f1)
set $brightness_down light -r -U $($brightness_step) && $onscreen_bar $(light -G | cut -d'.' -f1)

# Volume controll
set $volume_down pulsemixer --change-volume -5 && $onscreen_bar $(pulsemixer --get-volume)
set $volume_up pulsemixer --change-volume +5 && $onscreen_bar $(pulsemixer --get-volume)
set $volume_mute pulsemixer --toggle-mute && $(pulsemixer --get-volume)

# clipboard history
set $clipboard cliphist list | wofi -dmenu -p "Select item to copy" -lines 10 -width 35 -theme-str $wofi_theme | cliphist decode | wl-copy
set $clipboard-del cliphist list | wofi -dmenu -p "Select item to delete" -lines 10 -width 35 -theme-str $wofi_theme | cliphist delete

### Idle configuration
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.
#
set $lock ~/.config/swaylock/lock.sh
set $idle_timeout 240
set $locking_timeout 300
set $screen_timeout 600
set $idle swayidle -w \
    timeout $idle_timeout 'light -G > /tmp/brightness && light -S 10' resume 'light -S $([ -f /tmp/brightness ] && cat /tmp/brightness || echo 100%)' \
    timeout $locking_timeout $lock \
    timeout $screen_timeout 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' \
    before-sleep 'playerctl pause' \
    before-sleep $lock & \
    lock $lock &

# Pulseaudo command
set $pulseaudio $term_float pulsemixer

# calendar application
set $calendar $term_float khal interactive

# help overlay
set $help /usr/share/sway/scripts/help.sh --toggle

# workspace names
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
set $ws10 number 10

# screenshot
set $grimshot /usr/bin/grimshot
set $screenshot_screen_clipboard $grimshot --notify copy output
set $screenshot_screen_file $grimshot --notify save output
set $screenshot_selection_clipboard $grimshot --notify copy window
set $screenshot_selection_file $grimshot --notify save window
set $screenshot_selection_active $grimshot --notify save active
