Fixed tabb argument handling (again) + help function + new bugs

This commit is contained in:
Alexis Jhon Gaspar 2024-07-09 16:56:31 +08:00
parent 48f0ec8cbd
commit ee9607e72c

View file

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# tabb for tabbed by Alexis. # tabb for tabbed by Alexis.
tabbed_id=$(tabbed -d -c)
main() { main() {
tabbed_id=$(tabbed -d -c)
while true; do while true; do
if [[ ! $(pgrep -x "tabbed") ]]; then if [[ ! $(pgrep -x "tabbed") ]]; then
echo "No Tabbed process found. Exiting..." echo "No Tabbed process found. Exiting..."
@ -31,25 +30,43 @@ main() {
xdotool windowreparent "$wid" "$tabbed_id" xdotool windowreparent "$wid" "$tabbed_id"
fi fi
done done
if [ "$automode" = false ]; then if [[ $automode = "false" ]]; then
exit 0 break
# exit
fi fi
done done
} }
case $flag in helpfunct(){
-e ) echo "tabb - Handler script for suckless tabbed"
echo ""
echo "by Alexis Jhon Gaspar (lucss21a) (c) 2023-2024"
echo ""
echo "Options:"
echo ""
echo "-e: Turn on auto-reparenting on all windows (default)"
echo "-d: Turn on auto-reprenting only on existing windows"
echo "-h: Show this message"
}
while getopts "edh" opt; do
case $opt in
e )
automode=true automode=true
main main
;; ;;
-d ) d )
automode=false automode=false
main main
;; ;;
h )
helpfunct
;;
esac esac
done
if [ $OPTIND -eq 1 ]; then if [ $OPTIND -eq 1 ]; then
shift $((OPTIND-1))
echo "No arguments passed, turning auto-reparenting on ALL windows..."
automode=true automode=true
main main
fi fi
shift $((OPTIND-1))