Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 3524  / 2 Years ago, sat, june 11, 2022, 5:14:48

I'm trying to launch a bash with a double click on it.


I made a simple script :


#!/usr/bin/env bash
echo Hello, who am I talking to?
read varname
echo "It's nice to meet you" $varname

and I also tried by putting #!/bin/bash but didn't change


I did


sudo chmod +x script_name 
dconf-editor

and set launch file on click in dconf-editor.


I also tried to add .sh extention to the file without success.


With all of this, the file is not running when i double click on it.
I'm using ubuntu 20.04, and I didn't find any helpfull post about this problem.
Maybe I didn't searched well or enough so feel free to send me


Additionnal intels :



  • The script work well when I launch it from terminal,

  • When I set "ask" in dconf-editor is ask me how I want to open it, but launch still don't work.

  • Using the "ask" option, and then click on "run in terminal" make it work. But I want it to work without the ask window, to make it more user friendly.

  • The post Bash script using `sudo` runs correctly from cli but not when clicked to run is not helping me since I don't have sudo commands inside my script.


expected behaviour:
A terminal is open saying "who am I talking about?"


Thanks a lot. And sry about my english level I'm not native.
Bouq


More From » bash

 Answers
6

Some will say: "move to another desktop environment".


In the Gnome desktop environment, used by Ubuntu, the ability to run any program by double-clicking on it in the file manager is deprecated. It is indeed handy in some use cases. In other use cases, it can be confusing for users and for sure, it can be a security nightmare. Which is probably an important reason why it is deprecated.


It actually remains possible to set that up, however, it is not anymore set up by default.



  • If you are a developer needing to run an application during development, open a terminal. Enter the name of the program once (use Tab for command completion. Then use arrow up to repeat the command.

  • If you are an end user needing to run some application, then install it properly. Install or link the executable in your ~/bin or ~/.local/bin directory. Run it from the terminal just by typing the name, or create a launcher to it in ~/.local/share/applications. Then, you can run it from the application overview, and even pin it to the dock for quick access.


Still, you could set up the ability to run files from the file manager by setting up a .desktop launcher that runs a file you provided as an argument. A .desktop launcher with the line Exec=gnome-terminal -- %f would open Gnome Terminal and (try to) run the file name provided, represented by the %f. If it is a script, you will see it running in the terminal. If it is a graphical application, Gnome terminal will briefly load, but disappear once the graphical application has started. A minimal .desktop launcher for this is:


[Desktop Entry]
Name=Generic application runner
Comment=Runs executable files
Exec=gnome-terminal -- %f
Type=Application

With the .desktop file installed in ~/.local/share/applications, you can run any program by right-clicking and selecting "Open with...". You can associate files with a specific extension, e.g. .sh for scripts, to that launcher so it runs upon double click.


Alternatively, you will need to at least switch to a file manager still supporting the feature, or switch to another desktop environmemt like Mate or Xfce.


[#955] Sunday, June 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pantkie

Total Points: 209
Total Questions: 112
Total Answers: 138

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
pantkie questions
Tue, Feb 14, 23, 07:17, 1 Year ago
Sat, May 8, 21, 05:13, 3 Years ago
Thu, Mar 10, 22, 12:32, 2 Years ago
Tue, Oct 25, 22, 05:41, 2 Years ago
;