Xfce Forum

Sub domains
 

You are not logged in.

#1 2012-02-13 02:47:36

adisk
Member
Registered: 2012-02-13
Posts: 2

Applet request - Run script, show icon

I need simple applet.
- Run script.
- Script return 0 (ok) or 1 (fail)
- Show icon. If 0 - show first icon.
- It 1 - show second icon.

It applet will be places in panel.
Near other indicators.

Settings:
- script
- incos
a15c471f.png

Offline

#2 2012-02-13 07:15:03

Nick
Dev
From: ~
Registered: 2005-02-17
Posts: 1,144
Website

Re: Applet request - Run script, show icon

The xfce4-genmon-plugin can do this, but without the icons. With some clever scripting you can also do this with normal launchers (change the icon of the desktop file, use %k to get the uri to the file).

Offline

#3 2012-02-13 15:44:24

angstrom
Member
Registered: 2011-08-13
Posts: 267

Re: Applet request - Run script, show icon

I use launcher system to check mail.
- Create a launcher, make it run your script
- Go in ~/.config/xfce4/panel,  the last created directory "launcher-##" normally contain a .desktop file (look inside and verify that is the launcher that run your script by looking the "Exec=" property)
- Now your script :

#!/bin/bash

launcherDir=~/.config/xfce4/panel/launcher-##

##### Your code ####
...
##################

function gendesktop 
{
    cat <<EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=$1
Comment=
Icon=$2
Exec=/path/to/your/script
Path=
Terminal=false
StartupNotify=false
EOF
}

rm -f $launcherDir/*.desktop

if [ $res == 0 ]; then    
    gendesktop    "Tool tips that OK"     "path to your icon, or icon name from gtk cache icons"    > $launcherDir/$$.desktop
else
    gendesktop    "Tool tips that not ok"    "path to your second icon"    >   $launcherDir/$$.desktop
fi    

- There must be is a better way to force update the launcher's icon than creating a new .desktop file. Nick, is that what you are refering by using %k ?


Xfce is NOT Xubuntu. Bugs in Xubuntu don't mean that Xfce is buggy ...

Offline

#4 2012-02-13 17:21:20

Nick
Dev
From: ~
Registered: 2005-02-17
Posts: 1,144
Website

Re: Applet request - Run script, show icon

If you use %k in the command, it will be replaced with the desktop file uri. You can use that in the script to modify the launcher.

#!/bin/sh

filename=${1#file://}

desktop-file-edit --set-icon="face-tired" "$filename"
touch "$filename"

# Do stuff
sleep 5

desktop-file-edit --set-icon="face-smile" "$filename"
touch "$filename"

Only create a launcher with the following command "scriptname.sh %k"

Offline

#5 2012-02-13 17:26:07

Nick
Dev
From: ~
Registered: 2005-02-17
Posts: 1,144
Website

Re: Applet request - Run script, show icon

Offline

Board footer

Powered by FluxBB