-
Notifications
You must be signed in to change notification settings - Fork 4
/
hotkeys.sh
executable file
·53 lines (47 loc) · 1.62 KB
/
hotkeys.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#variable for current session environment
session="$(echo "$DESKTOP_SESSION" | cut -d '/' -f 5)"
#variables for determining which file to pull based on session identified
file1="$HOME/.config/xmonad/xmonad.hs"
file2="$HOME/.ratpoisonrc"
file3="$HOME/.config/i3/config"
file4="$HOME/.config/herbstluftwm/autostart"
program=$1
#requires figlet, this checks if figlet is installed and if not, it installs on arch or debian
#if not running arch or debian, prompts user to install figlet, but still finishes running script without heading
#if figlet already installed, this runs header
if command -v figlet &> /dev/null
then
figlet -f small "$session Keybindings"
else
if command -v pacman &> /dev/null
then
sudo pacman -S figlet
elif command -v apt &> /dev/null
then
sudo apt install figlet
else
printf "please install figlet"
fi
fi
#clear screen if figlet was installed via script
clear
#runs header if figlet was installed via script
figlet -f small "$session Keybindings"
#checks for desktop session and locates associated config file
#pulls only lines with keybindings and displays them
if [[ $session == xmonad ]]
then
grep "M-" "$file1" | awk '{ printf "%-20s%-30s%s%s%s%s\n",$2,$3,$4,$5,$6,$7 }' | grep "$program"
elif [[ $session == ratpoison ]]
then
grep "bind" "$file2" | cut -f1,2,3 -d " "
elif [[ $session == i3 ]]
then
grep "bindsym" "$file3" | cut -f2-7 -d " " | column -t -s' ' | grep "$program"
elif [[ $session == herbstluftwm ]]
then
grep "Mod-" "$file4" | cut -f3-9 -d " " | grep "$program"
else [[ $session == ? ]]
printf "session not found"
fi