Created
April 27, 2022 14:22
-
-
Save dentex/e62801e16a601a90c81b8160ab260aa9 to your computer and use it in GitHub Desktop.
Simple personal scripts launcher, using Zenity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Scripts location directory | |
scr_dir="$HOME/bin/script-launcher.d" | |
# Search for executable files only in "$scr_dir" and store them in an array: | |
arr=( `find $scr_dir/* -type f -executable -printf '%f\n' | sort -n` ) | |
# Show `zenity` list dialog | |
scr=$(zenity --width 400 --height 520 --list --title "Scripts Launcher" --text "Select the script to be executed" --radiolist --column "" --column "scripts list" `for item in ${arr[*]}; do printf "%s\n" FALSE $item; done` 2>/dev/null) | |
zen_res=$? | |
# Look for the 'no-term' config line | |
head $scr_dir/$scr | grep '#Config-no-term' | |
if [ "$?" -eq 0 ]; then | |
no_term=True | |
fi | |
# Launch the script... | |
if [ "$zen_res" -eq 0 ] && [ -n "$scr" ]; then | |
# ...directly | |
if [ $no_term == True ]; then | |
$scr_dir/$scr | |
# ... or in a terminal window | |
else | |
gnome-terminal --geometry 175x55 -e $scr_dir/$scr > /dev/null 2>&1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment