LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-24-2019, 09:04 AM   #1
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Rep: Reputation: Disabled
Can I link a terminal command to an icon in the Panel?


I have a reboot command:

sudo grub-reboot 4 && sudo reboot?

I would like to create a icon on the Panel that I can click to lunch the command. Just adding it as is to "Command" box did not work. I tried with "Application" and "Application in terminal."

How to do this?

Last edited by jamesd1; 05-24-2019 at 09:08 AM.
 
Old 05-24-2019, 09:15 AM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Since this is a desktop-related command, you should let us know which desktop environment or window manager you're using.
 
Old 05-24-2019, 09:17 AM   #3
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
I'm in Desktop: MATE 1.20.1 Distro: Linux Mint 19.1 Tessa
 
Old 05-24-2019, 09:23 AM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Thanks. In that case, choose Application rather than Application in Terminal and try the following command:

Code:
mate-terminal -x sudo grub-reboot 4 && sudo reboot
(you would probably be better first testing it with a more anodyne terminal command than a reboot)
 
Old 05-24-2019, 09:33 AM   #5
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hydrurga View Post
Thanks. In that case, choose Application rather than Application in Terminal and try the following command:

Code:
mate-terminal -x sudo grub-reboot 4 && sudo reboot
(you would probably be better first testing it with a more anodyne terminal command than a reboot)
Thanks, but this did not work; the terminal blinked open a fraction of a second then closed.
 
Old 05-24-2019, 10:03 AM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Yes, the launcher appears to be having a problem with the multiple commands, even if separated by a &&.

In that case, create a .sh script somewhere in your home directory with the command in it, make that script file executable, and then have the launcher command as:

Code:
mate-terminal -x /home/path-to-script.../scriptname.sh
I've just tested it and it works fine here.
 
Old 05-24-2019, 10:08 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,344
Blog Entries: 3

Rep: Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754Reputation: 3754
You can make a .desktop file and then add that to your panel or menus. The contents would look something like this:

Code:
[Desktop Entry]
Version=1.0
Type=Application
Name=Rebooter
Comment=This icon reboots the machine
Exec=/usr/bin/mate-terminal --title="rebooting" --icon=/path/to/some/icon.svg --geometry 80x24 --execute /bin/sh -c "sudo grub-reboot 4 && sudo reboot || sleep 3"
Icon=/path/to/some/icon.svg
StartupNotify=false
 
Old 05-24-2019, 12:43 PM   #8
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
I have the file winboot.sh in what I think is /home/james/AA My Scripts/winboot.sh as that is what it shows in the properties for the file. In the Command box I have:

mate-terminal -x /home/james/AA My Scripts/winboot.sh

It says no such file or directory.
 
Old 05-24-2019, 12:58 PM   #9
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by jamesd1 View Post
I have the file winboot.sh in what I think is /home/james/AA My Scripts/winboot.sh as that is what it shows in the properties for the file. In the Command box I have:

mate-terminal -x /home/james/AA My Scripts/winboot.sh

It says no such file or directory.
Very probably due to your use of spaces in a directory name. When the command you've given is parsed, it will try to execute /home/james/AA. Either escape the spaces in the command or don't use them in the directory name.
 
Old 05-24-2019, 03:16 PM   #10
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
Thanks. I removed the spaces but now its just does the fast blink of the terminal and closes.

?
 
Old 05-24-2019, 03:21 PM   #11
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Did you ensure that the script file is executable? (did you use chmod +x on it?)
 
Old 05-24-2019, 04:11 PM   #12
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
I set it to allow execution in properties dialog.

Don't understand "1did you use chmod +x on it?"
 
Old 05-24-2019, 04:17 PM   #13
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by jamesd1 View Post
I set it to allow execution in properties dialog.

Don't understand "1did you use chmod +x on it?"
On the command line:

Code:
chmod +x /path/to/file.sh
Ok, let's check. Can you post the output from the following (change the path accordingly):

Code:
ls -l /home/james/.../winboot.sh

cat /home/james/.../winboot.sh
and the full command you used in your launcher.
 
Old 05-24-2019, 04:25 PM   #14
jamesd1
LQ Newbie
 
Registered: May 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
james@james-desktop:~/AAMyScripts$ ls -l winboot.sh
-rwxrwxr-x 1 james james 37 May 24 10:34 winboot.sh
james@james-desktop:~/AAMyScripts$

james@james-desktop:~/AAMyScripts$ cat winboot.sh
sudo grub-reboot 4 && sudo reboot
 
Old 05-24-2019, 04:31 PM   #15
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by jamesd1 View Post
james@james-desktop:~/AAMyScripts$ ls -l winboot.sh
-rwxrwxr-x 1 james james 37 May 24 10:34 winboot.sh
james@james-desktop:~/AAMyScripts$

james@james-desktop:~/AAMyScripts$ cat winboot.sh
sudo grub-reboot 4 && sudo reboot
And the full command you used in your launcher?
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mouse wheel VOLUME control icon , NETWORK control icon on MATE's desktop panel on CentOS 7 disappeared primorec Linux - Desktop 0 07-31-2018 05:45 PM
Physical link vs Relative link vs Symbolic link hack3rcon Linux - Newbie 13 01-13-2018 10:48 AM
openSUSE 11.4 - wired icon does not change to wireless icon in panel rusty2 Linux - Software 1 04-14-2011 04:46 AM
skge: eth0: Link is up... Link is down... Link is up.... sugar2 Linux - Hardware 5 07-03-2007 03:52 PM
How to change a GNOME panel icon from command line? General Programming 0 03-19-2007 06:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 09:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration