Skip to content

Instantly share code, notes, and snippets.

@ecodz
Created August 4, 2023 20:50
Show Gist options
  • Save ecodz/7304684ae8317b2580684e02b0be6e9c to your computer and use it in GitHub Desktop.
Save ecodz/7304684ae8317b2580684e02b0be6e9c to your computer and use it in GitHub Desktop.
kinda working windows run dialog for linux, made with yad
#!/bin/bash
export rpipe=$(mktemp -u --tmpdir run.XXXXXXXX)
mkfifo "$rpipe"
trap "rm -f $rpipe" EXIT
cmd=(yad
--form
--field "Open::T"
--button="OK"
--button="Cancel"
--button="Browse...":"bash -c browse"
--image=open-menu
--text="Type the name of a program, folder, document, or Internet \nresource, and Windows will open it for you."
--borders 10
--title="Run"
)
browse() {
eval yad --file >> "$rpipe"
}
exec 3<> $rpipe
export -f browse
rcmd=$("${cmd[@]}" <&3 | head -c -2)
unset browse
exec 3>&-
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
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment