Created
January 14, 2022 12:00
-
-
Save TonyWhite/9365df5b337ef449df59408da02badbe to your computer and use it in GitHub Desktop.
Detects whether the bash script is started from the GUI or the shell
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 | |
| # Start from GUI? | |
| GUI=false | |
| if [[ $(readlink -f /proc/$(ps -o ppid:1= -p $$)/exe) != $(readlink -f "$SHELL") ]]; then | |
| GUI=true | |
| fi | |
| # Show message | |
| if [[ $GUI == true ]]; then | |
| zenity --info --ellipsize --text="Script started from GUI" | |
| else | |
| echo "Script started from shell" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment