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.

  • Which method are you using to launch the program at startup? (.config/autostart, startup applications etc?) – Wilf Feb 13 '17 at 12:07
  • 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
  • 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 – user47206 Feb 13 '17 at 13:51
  • 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. – clearkimura Feb 26 '17 at 8:26
1
+50

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.

  • 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 3:51
  • Here is an example that shows how. (ubuntu-mate.community/t/…) 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: elementarytips.blogspot.com/2013/03/… and unix.stackexchange.com/questions/215383/… – pauljohn32 Feb 24 '17 at 4: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? – user47206 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. – user47206 Feb 27 '17 at 8: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). – user47206 Feb 27 '17 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy