Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] Dekstop shortcut to terminal command

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
Mikelos
Posts: 9
Joined: 2018-02-28 13:57

[SOLVED] Dekstop shortcut to terminal command

#1 Post by Mikelos »

Hello,

I'm using Debian Stretch with Xfce. I have sudo enabled.

I'll describe my problem by showing what I'm doing.

1) Open Mousepad
2) Write in Mousepad:

Code: Select all

[Desktop Entry]
Name=Update
Exec=sudo apt update && sudo apt dist-upgrade && sudo snap refresh
Terminal=true
Type=Application
3) Save it as Update.desktop on desktop
4) Open terminal within desktop's location and execute:

Code: Select all

chmod +x Update.desktop
When I click on this newly created shortcut Xfce terminal appears and sudo asks me for password. After giving sudo correct password Xfce terminal disappears.

My goal: I want to see the terminal working while those commands are being executed. I don't know how to achieve this by creating proper desktop shortcut. The Terminal=true doesn't solve my problem.
Last edited by Mikelos on 2018-05-04 05:03, edited 1 time in total.

Wheelerof4te
Posts: 1454
Joined: 2015-08-30 20:14

Re: Dekstop shortcut to terminal command

#2 Post by Wheelerof4te »

Mikelos wrote:sudo apt dist-upgrade
Not needed until mid 2019th when Buster releases.
*buntu-bozo style:

Code: Select all

sudo apt update && sudo apt upgrade && sudo snap refresh
Would be easy to run once every 7 days without all that sudoing.
Like this:

Code: Select all

su
apt update && apt upgrade && flatpak update
exit
:D

Mikelos
Posts: 9
Joined: 2018-02-28 13:57

Re: Dekstop shortcut to terminal command

#3 Post by Mikelos »

I quitted Xubuntu and installed Debian with Xfce, smoother experience for me. I left root password empty during installation, consequently Debian configured sudo automatically. Sudoing is just my old habit. :D

I can execute it using su, no problem, but my question is how to do it via desktop shortcut while seing the terminal giving me information what my computer is doing - just like when I'm ordinarily typing commands into the terminal.

Wheelerof4te
Posts: 1454
Joined: 2015-08-30 20:14

Re: Dekstop shortcut to terminal command

#4 Post by Wheelerof4te »

Guys over at MX Linux have created something similar, stevepusser might help you out with it.

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: Dekstop shortcut to terminal command

#5 Post by Dai_trying »

It is quite simple if you use a bash script instead of trying to run the commands directly, just put your commands into a script like

Code: Select all

#!/bin/bash
sudo apt-get update
sudo apt-get dist-upgrade
sudo snap refresh
and then your desktop file should look something like this

Code: Select all

[Desktop Entry]
Name=Update
Exec=/home/dai/bin/updater.sh
Terminal=true
Type=Application
and then it will show you the text while running. The terminal will close automatically when finished but as it is running a script you can easily add a command to change that.
Last edited by Dai_trying on 2018-05-04 06:00, edited 1 time in total.

Mikelos
Posts: 9
Joined: 2018-02-28 13:57

Re: Dekstop shortcut to terminal command

#6 Post by Mikelos »

Thank you. I wouldn't be able to do it without your help.

I'll describe what I was doing.

1) Write in Mousepad:

Code: Select all

#!/bin/bash
sudo apt-get update
sudo apt-get dist-upgrade
sudo snap refresh
read line
2) Save it is as updater.sh in /home/user/bin
3) chmod +x it
4) Write in Mousepad:

Code: Select all

[Desktop Entry]
Name=Update
Exec=bash /home/user/bin/updater.sh
Terminal=true
Type=Application
5) Save it as Update.desktop on desktop
6) chmod +x it

When I click on the shortcut the terminal opens, sudo asks me for password, after giving sudo password I see terminal's rock 'n' roll and when this rock 'n' roll ends I press enter and terminal disappears (the effect of read line).

Again, thank you. I'm going to mark the thread as solved, but If I've done something wrong or if there are other solutions to my problem, please point it out.

EDIT:

Just for clarification. The following code in Update.desktop is obviously enough:

Code: Select all

[Desktop Entry]
Name=Update
Exec=/home/user/bin/updater.sh
Terminal=true
Type=Application
I've added bash, but it seems that it's unnecessary, however unharmful. I've added bash and rewritten Exec line from scratch, but now I realised that I had just mistyped Exec line. Consequently, adding bash was a superfluum. Only the typo in Exec line caused the error in executing commands written in updater.sh.

EDIT 2:

I even noticed that #!/bin/bash is also a superfluum. The following code in updater.sh is enough:

Code: Select all

sudo apt-get update
sudo apt-get dist-upgrade
sudo snap refresh
read line
It still does its job.

Post Reply