6

I want to run the script temp-throttle (https://github.com/Sepero/temp-throttle) at startup and show a custom Plank icon.

The script will throttle CPU frequency at 79 celsius if run like so

sudo ./temp_throttle.sh 79

As it needs the temperature to be specified as above after cd in the path of the script, a second script is needed.

#!/bin/bash

cd "path-to-the-folder//temp-throttle-stable"
terminator -e 'sudo ./temp_throttle.sh 79' --geometry=300x80 -p hold 

I have called that temp-throttle and put it in $HOME/bin, as indicated here.

In order to have some info on the situation, I have integrated the command in a terminal command and added -p hold that sets a terminal profile to keep terminal window open.

If I add that script to startup applications list, the icon used in Plank is that of the terminal.

enter image description here

I would like it to run at startup and show in Plank my custom "temp.png" icon

enter image description here

For that, I have created the file ~/.local/share/applications/temp-throttle.desktop with the following lines:

[Desktop Entry]
Type=Application
Name=temp-throttle
Icon=temp
Categories=System;Monitor;
Exec=temp-throtle

enter image description here

Executing that directly (double-click) it shows the terminal icon in Plank.

I can make the dock use the custom "temp" icon by executing the .desktop file from the applications search&launch tool (e.g. Slingshot) or with the command gtk-launch temp-throttle (as suggested here).

After that, the custom Plank icon can of course be pinned to the dock (right-click, "Keep in Dock"). That creates the file /home/cipeos/.config/plank/dock1/launchers/temp-throttle.dockitem with the lines

[PlankDockItemPreferences]
Launcher=file:///home/cipeos/.local/share/applications/temp-throttle.desktop

as suggested in the pauljohn32's answer. He also seems to suggest in a comment that the important thing here is to have the exact same names for all files involved: all my file are called temp-throttle.

The problem is how to run a .desktop file at startup: if I simply add the desktop file at startup it will not run at all. If I add the startup command gtk-launch temp-throttle.desktop it will still use the terminator icon.


This question is close to this: Apply icons to bash scripts, but different, as the answers under that (use a .desktop file) will not work if the command/script/desktop-file is run at startup.

It seems that at startup the final command/script is run without taking into account the Icon= line in the .desktop file, no matter the method used to run the .desktop launcher.

I have tested many answers under this question (Running a .desktop file in the terminal) but they will not keep the icon specified in the .desktop file if that is run at startup.


THIS answer provides a solution for Unity, but it doesn't work as such for Plank.

derHugo
  • 3,356
  • 5
  • 31
  • 51
  • Which method are you using to launch the program at startup? (.config/autostart, startup applications etc?) – Wilf Feb 13 '17 at 12:07
  • @Wilf - It's startup applications, gnome-session-properties. But will use any other method if it would amount to an answer. –  Feb 13 '17 at 12:10
  • 1
    Will you edit your message and add the content (content example) of the script that will be running as well as the expected output. This better help me to understand the objective. – L. D. James Feb 13 '17 at 12:33
  • Hi @cipricus if the dupe link is not exactly what you are looking for, please mention. – Jacob Vlijm Feb 13 '17 at 13:22
  • @JacobVlijm - I am trying to use the showicon script as it seems to be what I want, but it doesn't work for me at the moment. I still get the terminal icon . --- Is your answer under the other question Unity-specific? I need it to work with Plank. –  Feb 13 '17 at 13:47
  • 1
    @cipricus thanks for mentioning! You might want to add to the question it is for plank :) reopening... – Jacob Vlijm Feb 13 '17 at 13:49
  • 1
    @JacobVlijm - added Plank in title and tag –  Feb 13 '17 at 13:51
  • @L.D.James - I think I have posted details here: http://unix.stackexchange.com/q/344629/32012, it's a script that needs to run in terminal, and for that I have added another script to startup. When it starts at boot it displays the terminal icon in Plank. Using a desktop file with icon with the latter script isn't providing the dock icon if used at atartup . See the elementaryos link too: http://elementaryos.stackexchange.com/q/10696/170 –  Feb 13 '17 at 14:01
  • 1
    +1 Finally understood this issue; so far not possible for me. While .dockitem method allows to pin .desktop file to Plank, the custom icon will only be used when run from the dock. Terminal icon will always be used when run otherwise i.e. application menu, launcher and startup. –  Feb 26 '17 at 08:26
  • I think that is because your launcher and startup are NOT using the new desktop / script names. If you can run from terminal and get custom icon in the way I describe, that proves it works. Now make sure the new desktop and plank files are using program name that is launched from menu. See what I mean? Plank is using default icon "terminal" because it does not know better because from the startup you are not launching your special script (one named in custom desktop). – pauljohn32 Feb 27 '17 at 03:01
  • @clearkimura - see my newly edited question –  Feb 27 '17 at 11:20

1 Answers1

1

configure a new renamed desktop file that does what you want. Change session manager to launch that one instead of other. Only difference b/t config file will be icon selection.

Here is a concrete example.

  1. Open a terminal, run

    $ charmap

Notice the character map pop into the Plank?

  1. Right click on the icon, choose "keep in dock".

  2. In terminal, cd to ~/.config/plank/dock1/launchers

You should see "gucharmap.dockitem". Edit that file, change the name of the desktop file it is using.

  1. You better go create that desktop file you referred to in step 3, or else, well, this whole thing is no fun ;). I had some fun, for example, by changing the icon for gucharmap in my dock to look exactly like firefox! The top of my desktop file:
[Desktop Entry]
Name=Character Map
Comment=Insert special characters into documents
Keywords=font;unicode;
Exec=gucharmap
Icon=firefox

All I did was replace the icon with firefox, and now my plank looks twice as awesome. I think I might make all of the icons look like firefox.

Now, about your custom script, it is important to get the Exec line correct, or else Plank won't find your script and associate it correctly. But I think you can get this done.

pauljohn32
  • 3,743
  • I'll double check for an example. I've done this in Window Maker's dock, ten years ago. I think we can make same work with Plank. The key element here is that we need the command line strategy to launch a thing into the dock. To me it is an interesting question. – pauljohn32 Feb 24 '17 at 03:51
  • Here is an example that shows how. (https://ubuntu-mate.community/t/make-yourself-a-swank-show-desktop-applet-for-plank/363) Name your script, put in a dockitem file under ~./config/plank/dock/launchers, that points at your preferred dekstop file,which controls the icon. Same basic idea here: http://elementarytips.blogspot.com/2013/03/how-to-add-wine-programs-to-plank.html and http://unix.stackexchange.com/questions/215383/how-to-add-custom-script-to-plank-dock-in-elementary-os-freya – pauljohn32 Feb 24 '17 at 04:01
  • What you suggested initially is what I already know and mentioned in relation with the askubuntu question Apply icons to bash scripts. But how to do the same thing at startup? –  Feb 24 '17 at 18:27
  • @ clearkimura - the dock icon can be added without the need for text editing by creating the desktop in ~/.local/share/applications, running it from the programs search/launcher and then pinning it (Keep in dock) to Plank. –  Feb 27 '17 at 08:39
  • I have radically edited my question to make it much more specific, with all details and use of the script. I think all your indications are followed. I cannot avoid a second script (to specify the temperature at which the main CPU-throttle script should be executed): temperature cannot be directly set in the desktop file. - Adding the .desktop path to startup list will not work at all. Adding gtk-launch <.desktop> to startup will only follow the Exec= line (the script is executed), but not the Icon= line of that .desktop file (the terminal icon is seen in Plank). –  Feb 27 '17 at 11:17