Experimental way to add applications to ratpoison modd during I38 configuration. Removed transfer.sh because I think it's dead.
This commit is contained in:
191
i38.sh
191
i38.sh
@@ -176,6 +176,162 @@ yesno() {
|
||||
# Args: Question to user.
|
||||
dialog --clear --title "I38" --yesno "$*" -1 -1 --stdout
|
||||
echo $?
|
||||
}
|
||||
|
||||
# Custom application keybinding functions
|
||||
declare -A usedKeys
|
||||
declare -a customApps
|
||||
|
||||
showKeybindingHelp() {
|
||||
dialog --title "I38 Keybinding Help" --msgbox \
|
||||
"Keybinding Notation:
|
||||
Modifiers: ^ = Ctrl, ! = Alt, # = Super, m = your mod key
|
||||
Special keys: f1-f12, up/down/left/right, space, tab, return
|
||||
home/end/insert/delete/pageup/pagedown, print
|
||||
backspace, escape
|
||||
|
||||
Examples:
|
||||
c = just 'c' key
|
||||
^c = Ctrl+c
|
||||
!f1 = Alt+F1
|
||||
mspace = mod+Space
|
||||
^!up = Ctrl+Alt+Up
|
||||
#pagedown = Super+Page_Down
|
||||
|
||||
Uppercase letters imply Shift (e.g., C = Shift+c)" 0 0
|
||||
}
|
||||
|
||||
convertKeybinding() {
|
||||
local input="$1"
|
||||
local result=""
|
||||
local baseKey=""
|
||||
|
||||
# Handle modifiers
|
||||
if [[ "$input" == *"^"* ]]; then
|
||||
result+="Control+"
|
||||
input="${input//^/}"
|
||||
fi
|
||||
if [[ "$input" == *"!"* ]]; then
|
||||
result+="Mod1+"
|
||||
input="${input//!/}"
|
||||
fi
|
||||
if [[ "$input" == *"#"* ]]; then
|
||||
result+="Mod4+"
|
||||
input="${input//#/}"
|
||||
fi
|
||||
if [[ "$input" == *"m"* ]]; then
|
||||
result+="\$mod+"
|
||||
input="${input//m/}"
|
||||
fi
|
||||
|
||||
# Handle shift for uppercase letters
|
||||
if [[ "$input" =~ [A-Z] ]]; then
|
||||
result+="Shift+"
|
||||
input="${input,,}"
|
||||
fi
|
||||
|
||||
# Convert special keys
|
||||
case "$input" in
|
||||
f[1-9]|f1[0-2]) baseKey="F${input#f}" ;;
|
||||
up|down|left|right) baseKey="$input" ;;
|
||||
space) baseKey="space" ;;
|
||||
tab) baseKey="Tab" ;;
|
||||
return) baseKey="Return" ;;
|
||||
escape) baseKey="Escape" ;;
|
||||
backspace) baseKey="BackSpace" ;;
|
||||
print) baseKey="Print" ;;
|
||||
home) baseKey="Home" ;;
|
||||
end) baseKey="End" ;;
|
||||
insert) baseKey="Insert" ;;
|
||||
delete) baseKey="Delete" ;;
|
||||
pageup) baseKey="Page_Up" ;;
|
||||
pagedown) baseKey="Page_Down" ;;
|
||||
*) baseKey="$input" ;;
|
||||
esac
|
||||
|
||||
echo "${result}${baseKey}"
|
||||
}
|
||||
|
||||
populateUsedKeys() {
|
||||
# Populate with existing ratpoison mode bindings
|
||||
usedKeys["Shift+slash"]=1
|
||||
usedKeys["c"]=1
|
||||
usedKeys["e"]=1
|
||||
usedKeys["f"]=1
|
||||
usedKeys["\$mod+e"]=1
|
||||
usedKeys["w"]=1
|
||||
usedKeys["k"]=1
|
||||
usedKeys["m"]=1
|
||||
usedKeys["Print"]=1
|
||||
usedKeys["\$mod+r"]=1
|
||||
usedKeys["p"]=1
|
||||
usedKeys["\$mod+s"]=1
|
||||
usedKeys["Mod1+Shift+0"]=1
|
||||
usedKeys["Mod1+Shift+9"]=1
|
||||
usedKeys["Mod1+Shift+equal"]=1
|
||||
usedKeys["Mod1+Shift+minus"]=1
|
||||
usedKeys["Mod1+Shift+z"]=1
|
||||
usedKeys["Mod1+Shift+c"]=1
|
||||
usedKeys["Mod1+Shift+x"]=1
|
||||
usedKeys["Mod1+Shift+v"]=1
|
||||
usedKeys["Mod1+Shift+b"]=1
|
||||
usedKeys["Mod1+Shift+u"]=1
|
||||
usedKeys["Mod1+b"]=1
|
||||
usedKeys["g"]=1
|
||||
usedKeys["apostrophe"]=1
|
||||
usedKeys["Shift+c"]=1
|
||||
usedKeys["Shift+o"]=1
|
||||
usedKeys["Shift+t"]=1
|
||||
usedKeys["Control+semicolon"]=1
|
||||
usedKeys["Control+Shift+semicolon"]=1
|
||||
usedKeys["Shift+exclam"]=1
|
||||
usedKeys["Control+q"]=1
|
||||
usedKeys["Escape"]=1
|
||||
usedKeys["Control+g"]=1
|
||||
}
|
||||
|
||||
inputText() {
|
||||
# Args: prompt text
|
||||
dialog --title "I38" --inputbox "$1" 0 0 --stdout
|
||||
}
|
||||
|
||||
addCustomApplication() {
|
||||
local appName appCommand appFlags keybinding convertedKey
|
||||
|
||||
populateUsedKeys
|
||||
|
||||
while true; do
|
||||
appName="$(inputText "Custom Applications:\n\nEnter application name (or press enter when finished):")"
|
||||
[[ -z "$appName" ]] && break
|
||||
|
||||
appCommand="$(inputText "Enter execution path/command for $appName:")"
|
||||
[[ -z "$appCommand" ]] && continue
|
||||
|
||||
appFlags="$(inputText "Enter command line flags for $appName (optional):")"
|
||||
|
||||
while true; do
|
||||
keybinding="$(inputText "Enter keybinding for $appName (Examples: c, ^c, !f1, mspace, ^!up) or ? for help:")"
|
||||
|
||||
if [[ "$keybinding" == "?" ]]; then
|
||||
showKeybindingHelp
|
||||
continue
|
||||
fi
|
||||
|
||||
[[ -z "$keybinding" ]] && break
|
||||
|
||||
convertedKey="$(convertKeybinding "$keybinding")"
|
||||
|
||||
if [[ -n "${usedKeys[$convertedKey]}" ]]; then
|
||||
dialog --title "I38" --msgbox "Keybinding '$keybinding' ($convertedKey) is already in use. Please choose another." 0 0
|
||||
continue
|
||||
fi
|
||||
|
||||
# Add to arrays
|
||||
customApps+=("$appName|$appCommand|$appFlags|$convertedKey")
|
||||
usedKeys["$convertedKey"]=1
|
||||
break
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
help() {
|
||||
@@ -281,14 +437,13 @@ done
|
||||
# Mod2 and Mod3 not usually defined.
|
||||
|
||||
# Configuration questions
|
||||
export i3Mode=$(yesno "Would you like to use ratpoison mode? This behaves more like strychnine, with an escape key followed by keybindings. (Recommended)")
|
||||
# Ratpoison mode is enabled by default
|
||||
export i3Mode=0
|
||||
# Prevent setting ratpoison mode key to the same as default mode key
|
||||
while [[ "$escapeKey" == "$mod" ]]; do
|
||||
if [[ $i3Mode -eq 0 ]]; then
|
||||
escapeKey="$(menulist "Ratpoison mode key:" Control+t Control+z Control+Escape Alt+Escape Control+Space Super)"
|
||||
escapeKey="${escapeKey//Alt/Mod1}"
|
||||
escapeKey="${escapeKey//Super/Mod4}"
|
||||
fi
|
||||
escapeKey="$(menulist "Ratpoison mode key:" Control+t Control+z Control+Escape Alt+Escape Control+Space Super)"
|
||||
escapeKey="${escapeKey//Alt/Mod1}"
|
||||
escapeKey="${escapeKey//Super/Mod4}"
|
||||
mod="$(menulist "I3 mod key, for top level bindings:" Alt Control Super)"
|
||||
mod="${mod//Alt/Mod1}"
|
||||
mod="${mod//Super/Mod4}"
|
||||
@@ -412,11 +567,8 @@ brlapi=1
|
||||
brlapi=$(yesno "Do you want to use a braille display with ${screenReader##*/}?")
|
||||
sounds=1
|
||||
sounds=$(yesno "Do you want window event sounds?")
|
||||
# Play Login Sound
|
||||
loginSound=1
|
||||
if command -v canberra-gtk-play &> /dev/null ; then
|
||||
export loginSound=$(yesno "Would you like to play the default desktop-login sound according to your GTK sound theme upon login?")
|
||||
fi
|
||||
# Custom applications for ratpoison mode
|
||||
addCustomApplication
|
||||
|
||||
if [[ -d "${i3Path}" ]]; then
|
||||
yesno "This will replace your existing configuration at ${i3Path}. Do you want to continue?" || exit 0
|
||||
@@ -662,10 +814,6 @@ $(if command -v xrandr &> /dev/null ; then
|
||||
echo "# alt+s bound to brightness control"
|
||||
echo "bindsym \$mod+s exec --no-startup-id ${i3Path}/scripts/screen_controller.sh, mode \"default\""
|
||||
fi)
|
||||
$(if command -v transfersh &> /dev/null ; then
|
||||
echo "# t bound to share file with transfer.sh"
|
||||
echo 'bindsym t exec bash -c '"'"'fileName="$(yad --title "I38 Upload File" --file)" && url="$(transfersh "${fileName}" | tee >(yad --title "I38 - Uploading ${fileName##*/} ..." --progress --pulsate --auto-close))" && echo "${url#*saved at: }" | tee >(yad --title "I38 - Upload URL" --show-cursor --show-uri --button yad-close --sticky --text-info) >(xclip -selection clipboard)'"', mode \"default\""
|
||||
fi)
|
||||
|
||||
#Keyboard based volume Controls with pulseaudio
|
||||
bindsym Mod1+Shift+0 exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +${volumeJump}% & play -qnG synth 0.03 sin 440
|
||||
@@ -702,6 +850,16 @@ else
|
||||
echo "# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)"
|
||||
echo "bindsym Control+Shift+semicolon exec $i3msg -t run_command restart && spd-say -P important -Cw "I3 restarted.", mode "default""
|
||||
fi)
|
||||
# Custom applications
|
||||
$(for app in "${customApps[@]}"; do
|
||||
IFS='|' read -r appName appCommand appFlags appKey <<< "$app"
|
||||
echo "# $appName bound to $appKey"
|
||||
if [[ -n "$appFlags" ]]; then
|
||||
echo "bindsym $appKey exec $appCommand $appFlags, mode \"default\""
|
||||
else
|
||||
echo "bindsym $appKey exec $appCommand, mode \"default\""
|
||||
fi
|
||||
done)
|
||||
# Run dialog with exclamation
|
||||
bindsym Shift+exclam exec ${i3Path}/scripts/run_dialog.sh, mode "default"
|
||||
# exit i3 (logs you out of your X session)
|
||||
@@ -725,9 +883,6 @@ $(if [[ $sounds -eq 0 ]]; then
|
||||
echo "exec_always --no-startup-id ${i3Path}/scripts/sound.py"
|
||||
fi
|
||||
fi
|
||||
if [[ $loginSound -eq 0 ]]; then
|
||||
echo 'exec --no-startup-id canberra-gtk-play -i desktop-login'
|
||||
fi
|
||||
if [[ $brlapi -eq 0 ]]; then
|
||||
echo 'exec --no-startup-id xbrlapi --quiet'
|
||||
fi
|
||||
|
Reference in New Issue
Block a user