#!/bin/sh

coded_by='

In the name of Allah, the most Gracious, the most Merciful.

 ▓▓▓▓▓▓▓▓▓▓
░▓ Author ▓ Abdullah <https://abdullah.today>
░▓▓▓▓▓▓▓▓▓▓
░░░░░░░░░░

░█▀▀░█░█░█░█░█░█░█▀▄
░▀▀█░▄▀▄░█▀█░█▀▄░█░█
░▀▀▀░▀░▀░▀░▀░▀░▀░▀▀░
'

for_bspwm='
░█▀▄░█▀▀░█▀█░█░█░█▄█
░█▀▄░▀▀█░█▀▀░█▄█░█░█
░▀▀░░▀▀▀░▀░░░▀░▀░▀░▀
'

# Launch Quran

# alt + r 
#     "$HOME/.local/bin/Quran"

# Exit/restart bspwm

alt + shift + {q,r}
    bspc {quit,wm -r}

# Toggle touchpad
alt + e
    "$HOME/.local/bin/touchpad"

# alternate between the tiled and monocle layout

super + m
    bspc desktop -l next

# Swap the current node and the biggest node

super + g
    bspc node -s biggest.local || bspc node -s next.local

# Close/kill a window

super + {_,shift } + q
    bspc node -{c,k}

# Increase/Decrease window gaps

super + {minus,plus}
    bspc config window_gap {3,13}

# Push focused window to scratchpad (background), Un-Hide it

super + {_,shift } + i
    "$HOME"/.config/bspwm/scratchpad.sh {switch-app,toggle-flag}

# Move focus in given direction, and swap windows in given direction 

super + {h,j,k,l}
    win={west,south,north,east}; \
    bspc node -f $win || bspc monitor -f $win

super + shift + {h,j,k,l}
    bspc node -s {west,south,north,east}

# Resize nodes and preselections

alt + {_, shift + } {h,j,k,l}
    "$HOME"/.config/bspwm/{resize,presel} {west,south,north,east}

# Launch Browser(chrome). 

super + w
    bspc desktop -f 2 ; $BROWSER 

# change wallpaper

alt + w
   "$HOME"/.local/bin/gowall  "$HOME"/pix/wall/collection/dark

# Launch Browser(opera).

super + W
    opera

# Launch qutebrowser
super + alt + w
    qutebrowser

# Launch arch wiki offline

super + shift + alt + w
    google-chrome-stable /usr/share/doc/arch-wiki/html/en/ &

# Toggle full screen of focused window

super + f
    bspc node --state \~fullscreen

# Set the window state

super + {t,shift + t,s,f}
    bspc node -t {tiled,pseudo_tiled,floating,fullscreen}

# Set the node flags

super + alt + {m,x,y,z}
    bspc node -g {marked,locked,sticky,private}

# Send a focused window to presel

super + y
    bspc node $(bspc query -N -n) -n newest.\!automatic.local

# Move the floating windows 

super + alt + {h,j,k,l}
    bspc node -v {-20 0,0 20,0 -20,20 0}

# Focus the node for the given path jump

super + {p,b}
    bspc node -f @{parent,brother}

# Focus the next monitor

super + period
    bspc monitor -f next

# Focus the next/previous node in the current desktop

super + {_,shift + }c
    bspc node -f {next,prev}.local

# Focus the next/previous desktop in the current monitor

super + bracket{left,right}
    bspc desktop -f {prev,next}.local

# Focus the next node

super + Tab
    bspc node -f next

# Focus the next occupied desktop

super + semicolon
    bspc desktop next.occupied -f

# Focus the prev occupied desktop

super + apostrophe
    bspc desktop prev.occupied -f

# Focus the older or newer node in the focus history

super + {o,u}
    bspc wm -h off; \
    bspc node {older,newer} -f; \
    bspc wm -h on

# Focus or send to the given desktop

super + {_,shift + }{1-9,0}
    bspc {desktop -f,node -d} '^{1-9,10}'

# Move focused window to next workspace and switch there

alt + n
    id=$(bspc query --nodes --node); \
        bspc node --to-desktop {prev,next}; \
        bspc desktop --focus next; \
        bspc node --focus ${id}

# Toggle cmus

alt + v
    cmus-remote -u || if (  (/usr/bin/tmux has-session -t $USER) ); then \
        /usr/bin/tmux new-window cmus; \
    else; \
        /usr/bin/tmux new-session -d -s $USER cmus; \
    fi

# Rotate desktop

alt + space
    bspc node @/ --rotate {90,-90}

useful_programs_which_can_be_used_in_any_window_manager='

░█▀█░█▀▄░█▀█░█▀▀░█▀▄░█▀█░█▄█░█▀▀
░█▀▀░█▀▄░█░█░█░█░█▀▄░█▀█░█░█░▀▀█
░▀░░░▀░▀░▀▀▀░▀▀▀░▀░▀░▀░▀░▀░▀░▀▀▀
'

# Launch Terminal 
# make sure to set $TERMINAL env

super {_,shift} + Return
    {$TERMINAL,loc=$(slop -f "%x %y %w %h %g %i") || exit 1;\ 
       read -r x y w h g id < <(echo $loc);\
       bspc rule -a \* -o state=floating rectangle=$w"x"$h"+"$x"+"$y && $TERMINAL}

# Termite

alt {_, shift } + Return
    {kitty,xterm}

# Launch dmenu

super + d
    "$HOME"/.local/bin/dmenu_run

# Toggle mpd

alt + b
    music toggle

# Read The Quran

super + z
    zathura "$HOME/kit/pdf/Quran/Quran.pdf"

# Reload sxhkd

super + Escape
    pkill -USR1 -x sxhkd

soft_buttons='

░█▀▀░█▀█░█▀▀░▀█▀░░░█▀▄░█░█░▀█▀░▀█▀░█▀█░█▀█░█▀▀
░▀▀█░█░█░█▀▀░░█░░░░█▀▄░█░█░░█░░░█░░█░█░█░█░▀▀█
░▀▀▀░▀▀▀░▀░░░░▀░░░░▀▀░░▀▀▀░░▀░░░▀░░▀▀▀░▀░▀░▀▀▀
'
# Soft Launch button

XF86LaunchA
    mpc toggle

# Soft Brightness keys

XF86MonBrightness{Down,Up}
    light {-U 4,-A 4} && notify-send -u low -t 1500 -a light "Brightness"  "$(light -G | cut -d . -f 1)"

# Soft print combo for Screenshot

Print
    import -quality 100 -window root -resize 75% /tmp/foo.jpg; < /tmp/foo.jpg xclip -selection clipboard -t image/png

# Print and push to imgur, get URL in clipboard

alt + Print
    import -quality 100 -window root /tmp/foo.jpg && curl -F'file=@/tmp/foo.jpg' \
    http://0x0.st | tee /tmp/foo.txt | xclip && notify-send -t 3500 -i \
    "$HOME"/.local/share/icons/drops/imgur.png "Screenshot posted: $(cat /tmp/foo.txt)"

# Soft Explorer button for File Manager

XF86Explorer
    urxvtc -e ranger || urxvt -e ranger

# Music little backward/forward

alt + bracket{left,right}
    ~/.local/bin/music_seek {-15,+15}

# Music backward/forward

alt + shift + bracket{left,right}
    ~/.local/bin/music_seek {-100,+100}
 
# Lock the screen

super + x
    ~/.local/bin/i3lock

# Soft volume up/down buttons

XF86Audio{Lower,Raise}Volume
    notify-send -i $HOME/.local/share/icons/drops/volume.png \
    -u low -t 1500 -a ponymix "volume" "$(ponymix --max-volume \
    300 {decrease,increase} 3)"

# Soft mute button

XF86AudioMute
    ponymix --output toggle && notify-send -i \
    $HOME/.local/share/icons/drops/muted.png -u low -t 1500 -a ponymix "volume" \
    "output $(ponymix --output is-muted || echo 'un')muted"
 
# Mute/Unmute mic

ctrl + XF86AudioMute
    ponymix --input toggle && notify-send -i \
    $HOME/.local/share/icons/drops/muted.png -u low -t 1500 -a ponymix "volume" \
    "input $(ponymix --input is-muted || echo 'un')muted"

XF86Display
    systemctl suspend
# vim: ft=sh
