Page 1 of 1

yrun - script to run apps

Posted: Wed Oct 11, 2023 8:43 pm
by don570

yrun - script to run apps
written by Ingemar Karlsson

https://yad-guide.ingk.se/examples/exam ... d_examples
yrun is a simple bash script to run an app from a pull down list.
I found that it will run an appimage if the full path is typed in.

yad-run-dropdown.png
yad-run-dropdown.png (11.43 KiB) Viewed 1275 times

Code: Select all

#!/bin/bash

XTERM="xterm"

export SCRIPT=$(readlink -f $0)
export PWD=$(dirname $SCRIPT)

# Create history file
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
export HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history

# Create history file
if [ ! -f $HISTFILE ]; then
  mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
  echo "\n" > $HISTFILE
fi

# Delete history file
Clear_History(){
  rm $HISTFILE
  yad --fixed \
    --title="History" \
    --window-icon="applications-system" \
    --text="\n        History Cleared        \n" \
    --timeout="1" \
    --no-buttons
  echo "\n" > $HISTFILE
  kill $YAD_PID
  exec $SCRIPT
}
export -f  Clear_History

# Create and run dialog
TITLE="Run command"
TEXT="\nEnter command to execute:\n"

rcmd=$(yad --entry \
  --width=500 \
  --center \
  --window-icon="gtk-execute" \
  --name="${0##/}" \
  --title="$TITLE" \
  --text="$TEXT" \
  --image="gtk-execute" \
  --editable \
  --rest $HISTFILE \
  --button="Clear History!gtk-clear:bash -c Clear_History" \
  --button="yad-cancel:1" \
  --button="yad-execute:0")

[ -z "$rcmd" ] && exit 0

# Run command
case $rcmd in
  http://*|https://*|ftp://*)
    xdg-open $rcmd &
  ;;
  mailto://*)
    xdg-email $rcmd &
  ;;
  man://*)
    eval $XTERM -e "man ${rcmd#man://}" &
  ;;
  telnet*|ssh*)
    eval $XTERM -e "$rcmd" &
  ;;
  *)
    eval $rcmd &
	;;
esac

# Add command to history
grep -q -F "$rcmd" $HISTFILE || sed -i "1 i $rcmd" $HISTFILE

exit 0

Re: yrun - script to run apps

Posted: Wed Dec 06, 2023 1:14 am
by slavvo67

I've been spending much too much of my time creating Docker containers and images. This seems like an interesting alternative to a full desktop in a CLI environment. Wish me luck as I go off and test this baby.

Slavvo67