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.
I would like it to run at startup and show in Plank my custom "temp.png" icon
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
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.
Best Answer
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.
Open a terminal, run
$ charmap
Notice the character map pop into the Plank?
Right click on the icon, choose "keep in dock".
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.
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.