Last active
August 14, 2020 20:19
-
-
Save Jerrylum/6d983bcf0c65d46a42e1fef19ad723ea to your computer and use it in GitHub Desktop.
A shell script that can help you execute a command [as the superuser | on a new GNOME terminal]
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
#!/usr/bin/bash | |
# Usage: | |
# curious [--sudo | -s | --terminal | -t] <command> | |
# | |
# For example: | |
# curious notify-send "hello world" | |
# curious -t notify-send "hello world" | |
# curious -s -t notify-send "hello world" | |
for ((i=1; i<=$#; i++)); | |
do | |
token=${!i} | |
if [ "$token" = '--sudo' ] || [ "$token" = '-s' ]; then | |
arg_sudo=1 | |
elif [ "$token" = '--terminal' ] || [ "$token" = '-t' ]; then | |
arg_terminal=1 | |
else | |
break | |
fi | |
done | |
cmd="${@:$i:$#}" | |
if [ -n "$arg_terminal" ]; then | |
if [ -n "$arg_sudo" ]; then | |
gnome-terminal -- sudo bash -c "$cmd" | |
else | |
gnome-terminal -- bash -c "$cmd" | |
fi | |
else | |
if [ -n "$arg_sudo" ]; then | |
echo $cmd | |
pkexec bash -c "$cmd" | |
else | |
bash -c "$cmd" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup:
git clone https://gist.github.com/6d983bcf0c65d46a42e1fef19ad723ea.git cd 6d983bcf0c65d46a42e1fef19ad723ea chmod +x curious sudo cp curious /usr/bin
Examples
I will give you some examples of how to use
Curious
1. Open a new terminal
This shortcut can open a new terminal to display Linux processes
First, create the shell script
Flag
-t
means open a terminal to execute the commandAfter that, you can find the script we just created on your desktop. Try to open it using your cursor or execute the script in the terminal.
2. Execute command(s) in the background as the superuser
For example, I want to change the lighting effects of my computer, the follow command requires root privilege:
Here are the steps:
Alt + F2
to open the "Run a command" promptcurious -s OpenRGB -d 3 -m Rainbow
Flag
-s
means execute the command as the superuserB4 you leave
You can also use
Curious
in .desktop files and other places.