From ccbb89e372a603fd710e851f88c13a3c7ddcb9ab Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Mon, 27 Mar 2023 23:44:42 -0400 Subject: [PATCH] Added a help system. It is mod+shift+f1 or in ratpoison mode, ?. I tried to make it more readable, which took some doing, so if something is wrong with it please let me know. --- i38.sh | 9 +++++++++ scripts/i38-help.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 scripts/i38-help.sh diff --git a/i38.sh b/i38.sh index fa48561..c07fa04 100755 --- a/i38.sh +++ b/i38.sh @@ -273,6 +273,9 @@ focus_follows_mouse no # is used in the bar {} block below. font pango:monospace 8 +# I38 help +bindsym \$mod+Shift+F1 exec ${i3Path}/scripts/i38-help.sh + # Run dialog bindsym \$mod+F2 exec ${i3Path}/scripts/run_dialog.sh @@ -371,6 +374,8 @@ if [[ -n "${escapeKey}" ]]; then cat << EOF >> ${i3Path}/config bindsym $escapeKey mode "ratpoison" mode "ratpoison" { +# I38 help bound to ? +bindsym Shift+slash exec ${i3Path}/scripts/i38-help.sh, mode "default" # Terminal emulator bound to c bindsym c exec i3-sensible-terminal, mode "default" # Text editor bound to e @@ -380,16 +385,20 @@ bindsym f exec $fileBrowser, mode "default" # Web browser bound to w bindsym w exec $webBrowser, mode "default" $(if command -v mumble &> /dev/null ; then + # Mumble bound to m echo "bindsym m exec $(command -v mumble), mode \"default\"" fi) $(if command -v ocrdesktop &> /dev/null ; then + # OCR desktop bound to print screen alternative \$mod+r echo "bindsym Print exec $(command -v ocrdesktop) -b, mode \"default\"" echo "bindsym \$mod+r exec $(command -v ocrdesktop) -b, mode \"default\"" fi) $(if command -v pidgin &> /dev/null ; then + # p bound to pidgin echo "bindsym p exec $(command -v pidgin), mode \"default\"" fi) $(if command -v transfersh &> /dev/null ; then + # 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) diff --git a/scripts/i38-help.sh b/scripts/i38-help.sh new file mode 100755 index 0000000..5c5fabb --- /dev/null +++ b/scripts/i38-help.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + + +configPath="$(readlink -f $0)" +configPath="${configPath%/*/*}" + +if [[ -f "${configPath}/config" ]]; then + mod="$(grep 'set $mod ' "${configPath}/config" | cut -d ' ' -f3)" + mod="${mod//Mod1/Alt}" + mod="${mod//Mod4/Super}" + mapfile helpText < <(sed -e '/set \($mod\|mod\)/d' \ + -e '/set $ws/d' \ + -e 's/bindsym/Key:/g' \ + -e 's/Mod1/Alt/g' \ + -e 's/, mode "default"//g' \ + -e 's/--no-startup-id //g' \ + -e 's/$ws\([0-9]\)/\1/g' \ + -e 's/play \(.*\)& //g' \ + -e "s/\$mod/$mod/g" "${configPath}/config") +else + exit 1 +fi +for i in "${!helpText[@]}" ; do + helpText[$i]="${helpText[$i]//${configPath}\/scripts\//}" + helpText[$i]="${helpText[$i]/.sh/}" +done +helpText+=("End of text. Please press Control+Home to jump to the beginning of this document.") +echo "${helpText[@]}" | yad --text-info --show-cursor --title "I38 help" --button "Close:0" --listen + +exit 0