Creating a desktop shortcut for a shell script - linux

I have a bash script that to execute using Kali Linux i need to go to terminal, type cd shell-scripts and then ./try.sh
Is there a way i can create an executable desktop shortcut that would run the script by clicking on it?

This can be done very easily in LinuxMint 18.2 Cinnamon:
Rightclick on Desktop
Select 'Create a new launcher here'
Fill in the form with Name of the program and command + file path (e.g.: sh /opt/android-studio/studio.sh)
After that you can launch the program via doubleclick on the Desktop.

In Debian 11:
Right click the desktop
Create Launcher
Command: ./yourbashscriptname.sh
Working directory: Where it is located

Related

How to add "Open with Code" with right-click in Ubuntu or Pop OS?

In windows OS, when we install VS-Code, the option to add "open with code" is offered to us. But I couldn't find it in Ubuntu or Pop-OS!
Thus, I'd like to know, is there any way I can add "open with code" when I right-click within a folder to open the folder in VS-Code?
Although, we can use a terminal for opening the directory in VS-Code using "code ." but I'm looking for the right-click of the mouse.
You can run this command in the terminal
wget -qO- https://raw.githubusercontent.com/cra0zy/code-nautilus/master/install.sh | bash
After that you'll see on right click 'Open in Code'!
Works perfectly in Ubuntu 20.04
You could manually write down MIME types associated with vscode in ~/.local/share/applications/mimeapps.list like this
[Added Associations]
text/html=code.desktop
text/css=code.desktop
text/javascript=code.desktop
Assuming you have a proper Desktop Entry inside /usr/share/applications/
You can also try this Nautilus extension (if you use Nautilus)
https://github.com/harry-cpp/code-nautilus
This will install it if you use bash
wget -qO- https://raw.githubusercontent.com/harry-cpp/code-nautilus/master/install.sh | bash

How can I launch gitahed from terminal?

I enjoy using gitahed, and I would like to add a shortcut to lauch it, with github desktop I use github-desktop, but I can do the same with GA?
How can I launch gitahed from terminal?
GitAhead has a Terminal panel at Tools->Options. It has a button to install command line tools. It really just creates a symlink to the GitAhead binary in /usr/local/bin. If that doesn't work for some reason, you can create the symlink yourself or an alias. See command line options by running with the --help flag. There are only a few at the moment.

How do I create a shortcut for a command line command in Raspbian Stretch?

I am attempting to install RetroPie as an app on Raspbian Stretch and I am done except for creating a desktop shortcut for it. The problem is that the only way to open RetroPie seems to be running a command in the command line. I can’t do it in terminal because it gives me an error saying that it can’t initialize the window. Is there a way to run a command line command as a shortcut or am I going to have to find another way of doing this?
P.S. Here is the tutorial that I followed to install RetroPie:
https://www.makeuseof.com/tag/install-retropie-app-raspberry-pi/
Probably your shell (on the raspberry) is GNU bash. So read the manual of GNU bash.
You probably want (once) to edit some Bash startup file (such as ~/.bashrc) to define functions and aliases there, and you could add executable shell scripts somewhere in your $PATH. I recommend having a $HOME/bin/ directory containing your scripts and executables, and have $HOME/bin/ early in your $PATH.
I can’t do it in terminal because it gives me an error saying that it can’t initialize the window.
Perhaps you need some display server (such as Xorg or Wayland) running (with a desktop environment or a window manager). You could run Xorg on your PC (on which you could install Linux) and connect to the raspberry using ssh -X then remote applications running on your Raspberry are displayed on your PC. IF your Raspberry is directly connected to a screen (via HDMI) you might run some Xorg server on it.
Is there a way to run a command line command as a shortcut
Yes, by making a shell alias or shell function or shell script. You need to understand how they work and change or create some appropriate file using some source code editor (I recommend GNU emacs, but the choice is yours and you might use any other editor such as vim, gedit, etc...): functions and aliases could be defined in your ~/.bashrc; shell scripts would usually have their own file with a shebang under your $HOME/bin/...

How to add shortcut key by bash script

We are working on a kiosk mode in Linux Ubuntu. We would like to define a shortcut by command line (bash script). Is this possible? We would like to setup our kiosk mode automatically by a bash script. So creating a new shortcut via Compiz isn't possible.
Any ideas?
The shortcuts usually depend on the window manager you're using. If you're using Ubuntu you should have Gnome as default windomanager so you could use the Gnome Control Center to set the shortcuts you want.
Another way, is use a tool like Xbindkeys which is indipendent from the window manager and reads the key configuration from a simple text file usually ~/.xbindkeysrc.
So you could install Xbindkeys in your system with:
sudo apt-get install xbindkeys
Then in the bash script you could add a new entry in the ~/xbindkeysrc config file to add your shortcut.

making a clickable linux desktop shortcut to execute ant build script

In my ubuntu lucid linux system,I have some java code in ~/dev/java/mycode/src folder.I have an ant buildfile in ~/dev/java/mycode folder ,which compiles the java files and make a jar and finally execute the jar.I do this in a terminal as follows
cd ~/dev/java/mycode
ant -f mybuildfile.xml
I wanted to create a desktop shortcut ,clicking on which the above events will occur in a terminal.So I created a 'mylaunchfile' in /home/me/dev/java folder and gave it chmod +x .The contents are as follows
#!/bin/bash
ant -f /home/me/dev/java/mycode/mybuildfile.xml
When I open a terminal ,cd to /home/me/dev/java and run
>bash mylaunchfile
It executes ant properly and the java code is run.
Then ,I created a desktop launcher with command as
bash /home/me/dev/java/mylaunchfile
.Double Clicking on this shortcut doesn't bring up the terminal or run the bash command or do anything.
What do I need to get this clickable shortcut working?
You need to update you database before you can launch the command
sudo updatedb
should do the trick.

Resources