From a28cbc59ff06fd2d8720b5515b65cc39d95dcab2 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Fri, 24 Mar 2023 18:21:55 -0400 Subject: [PATCH] Replacement for grun, added custom I38 run dialog instead. --- scripts/run_dialog.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 scripts/run_dialog.sh diff --git a/scripts/run_dialog.sh b/scripts/run_dialog.sh new file mode 100755 index 0000000..d25a470 --- /dev/null +++ b/scripts/run_dialog.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + + +write_history(){ +oldHistory="$(grep -v "$txt" "${historyPath}/.history" | head -n 49)" +echo -e "$txt\n$oldHistory" | sed 's/^$//g' > "${historyPath}/.history" +} + + +historyPath="$(readlink -f $0)" +historyPath="${historyPath%/*}" +if ! [[ -d "$historyPath" ]]; then + mkdir -p "$historyPath" +fi + +if [[ -f "${historyPath}/.history" ]]; then + txt="$(yad --entry --editable --title "I38" --text "Execute program or enter file" --button "Open:0" --separator "\n" -- rest "${historyPath}/.history")" +else + txt="$(yad --entry --title "I38" --text "Execute program or enter file" --button "Open:0")" +fi +if [[ -z "$txt" ]]; then + exit 0 +fi +if [[ "$txt" =~ ^ftp://|http://|https://|www.* ]]; then + xdg-open $txt + write_history + exit 0 +fi +if [[ "$txt" =~ ^mailto://.* ]]; then + xdg-email $txt + write_history + exit 0 +fi +if [[ "$txt" =~ ^man://.* ]]; then + eval "${txt/:\/\// }" | yad --text-info --show-cursor --button "Close:0" --title "I38" - + write_history + exit 0 +fi +if command -v "$(echo "$txt" | cut -d " " -f1)" &> /dev/null ; then + eval $txt& +else + xdg-open $txt& +fi +write_history +exit 0