# Antonio Sarosi
# https://youtube.com/c/antoniosarosi
# https://github.com/antoniosarosi/dotfiles

# Qtile keybindings

from libqtile.config import Key
from libqtile.command import lazy


mod = "mod4"

keys = [Key(key[0], key[1], *key[2:]) for key in [
    # ------------ Window Configs ------------

    # Switch between windows in current stack pane
    ([mod], "j", lazy.layout.down()),
    ([mod], "k", lazy.layout.up()),
    ([mod], "h", lazy.layout.left()),
    ([mod], "l", lazy.layout.right()),

    # Change window sizes (MonadTall)
    ([mod, "shift"], "l", lazy.layout.grow()),
    ([mod, "shift"], "h", lazy.layout.shrink()),

    # Toggle floating
    ([mod, "shift"], "f", lazy.window.toggle_floating()),

    # Move windows up or down in current stack
    ([mod, "shift"], "j", lazy.layout.shuffle_down()),
    ([mod, "shift"], "k", lazy.layout.shuffle_up()),

    # Toggle between different layouts as defined below
    ([mod], "Tab", lazy.next_layout()),
    ([mod, "shift"], "Tab", lazy.prev_layout()),

    # Kill window
    #([mod], "w", lazy.window.kill()),
    ([mod, "shift"], "q", lazy.window.kill()), 

    # Switch focus of monitors
    ([mod], "period", lazy.next_screen()),
    ([mod], "comma", lazy.prev_screen()),

    # Restart Qtile
    #([mod, "control"], "r", lazy.restart()),
    ([mod, "shift"], "r", lazy.restart()),

    ([mod, "control"], "q", lazy.shutdown()),
    ([mod], "r", lazy.spawncmd()),

    # ------------ App Configs ------------

    ([mod], "o", lazy.spawn("rofi -show drun")),
    ([mod], "p", lazy.spawn("rofi -show run")),
    ([mod, "shift"], "w", lazy.spawn("rofi -show")),
    ([mod], "b", lazy.spawn("firefox")),
    ([mod], "n", lazy.spawn("pcmanfm")),
    ([mod], "g", lazy.spawn("geany")),
    ([mod], "m", lazy.spawn("telegram")),
    ([mod], "z", lazy.spawn("nitrogen")),
    ([mod], "u", lazy.spawn("xterm")),
    ([mod], "t", lazy.spawn("rofi-theme-selector")),
    ([mod], "c", lazy.spawn("dmenu_run")),
    ([mod], "d", lazy.spawn("dmenu_run")),
    ([mod], "x", lazy.spawn("lxrandr")),
    ([mod], "i", lazy.spawn("lxappearance")),
    ([mod], "v", lazy.spawn("pavucontrol")),

    # Terminal
    ([mod], "Return", lazy.spawn("kitty")),

    # Redshift
    #([mod], "r", lazy.spawn("redshift -O 2400")),
    #([mod, "shift"], "r", lazy.spawn("redshift -x")),

    # Screenshot
    ([mod], "s", lazy.spawn("xfce4-screenshooter")),
    ([mod, "shift"], "s", lazy.spawn("scrot -s")),

    # ------------ Hardware Configs ------------

    # Volume
    ([], "XF86AudioLowerVolume", lazy.spawn(
        "pactl set-sink-volume @DEFAULT_SINK@ -5%"
    )),
    ([], "XF86AudioRaiseVolume", lazy.spawn(
        "pactl set-sink-volume @DEFAULT_SINK@ +5%"
    )),
    ([], "XF86AudioMute", lazy.spawn(
        "pactl set-sink-mute @DEFAULT_SINK@ toggle"
    )),

    # Brightness
    ([], "XF86MonBrightnessUp", lazy.spawn("brightnessctl set +10%")),
    ([], "XF86MonBrightnessDown", lazy.spawn("brightnessctl set 10%-")),
]]
