Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-11-23 18:40:42

N00body
Member
Registered: 2021-11-23
Posts: 5

XFCE 4.16 - move custom launcher icons on the panel by command line

Hello,
I'm searching for a solution by a bash script to make simple custom launchers and move them through the xfce4 panel.

For the creation of custom launchers by command line I simply used:

xfce4-panel --add=launcher ./example.desktop

where example.desktop contains the following example content:

[Desktop Entry]
Version=1.0
Type=Application
Name=ExampleName
Comment=
Exec=ExampleCommand
Icon=/usr/share/icons/icon.svg
Path=
Terminal=true
Categories=Utility;X-XFCE;X-Xfce-Toplevel;
StartupNotify=true

and it goes to correctly fill the file

~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml

and

.config/xfce4/panel/launcher-<id>/

folder correctly.

Indeed I can see the icon on the panel on the extreme top-right position.

Is there a command or set of commands to move or to place directly the icon to the left position of the xfce panel (for example before the separator on the left part of the panel) to avoid to drag and drop the icon manually? Is there some property of the .desktop file to add or edit?

Thank you in advance!

Offline

#2 2021-11-23 19:03:50

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 8,300

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

Hello and welcome.

There is no "easy" way to do this. Although a little dated, this thread talks about the issue and offers some script options to manage the content on the panels. The information is still relevant.

Offline

#3 2021-11-23 19:51:11

N00body
Member
Registered: 2021-11-23
Posts: 5

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

ToZ wrote:

Hello and welcome.

There is no "easy" way to do this. Although a little dated, this thread talks about the issue and offers some script options to manage the content on the panels. The information is still relevant.

Hello T0Z, thank you for the answer.

During my previous research I read that thread you linked. I saw it has details related the position of the panel but cannot find anything related to the position of a single item/plugin on the panel.

Offline

#4 2021-11-23 20:37:35

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 8,300

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

Unfortunately, there is no built-in way to do this. Consider the following:

  • Return the list of plugin ids for panel-1:

    $ xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -n +3
    1
    15
    8
    4
    3
    9
    10
    5
    6
    2
  • Lets identify plugin #8:

    $ xfconf-query -c xfce4-panel -lv | grep plugin-8
    /plugins/plugin-8                         genmon
  • Lets move plugin #8 to the end:

    $ xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids -s 1 -s 15 -s 4 -s 3 -s 9 -s 10 -s 5 -s 6 -s 2 -s 8
  • The panel needs to be restarted for the change to take effect:

    xfce4-panel -r
  • Now show the new plugin ids (with #8 at the end):

    $ xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -n +3
    1
    15
    4
    3
    9
    10
    5
    6
    2
    8

There are a number of considerations that need to be taken into account.
- identifying the plugin that you want moved (or adding in the option to create and move all in one)
- reading in the array of plugin-ids (multiple panels will have multiple panel arrays) from the correct panel
- re-ordering the array
- writing it back

It is possible to write a wrapper script to do this, maybe re-using some of the code from the previous link, to add functionality to positionally add a new plugin in the correct location on the correct panel, I just haven't seen anyone do it yet.

The other option would be to create an enhancement request to see if a developer will enhance xfconf-query itself with this functionality.

Offline

#5 2021-11-24 01:03:33

N00body
Member
Registered: 2021-11-23
Posts: 5

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

ToZ wrote:

Unfortunately, there is no built-in way to do this. Consider the following:

  • Return the list of plugin ids for panel-1:

    $ xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -n +3
    1
    15
    8
    4
    3
    9
    10
    5
    6
    2
  • Lets identify plugin #8:

    $ xfconf-query -c xfce4-panel -lv | grep plugin-8
    /plugins/plugin-8                         genmon
  • Lets move plugin #8 to the end:

    $ xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids -s 1 -s 15 -s 4 -s 3 -s 9 -s 10 -s 5 -s 6 -s 2 -s 8
  • The panel needs to be restarted for the change to take effect:

    xfce4-panel -r
  • Now show the new plugin ids (with #8 at the end):

    $ xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -n +3
    1
    15
    4
    3
    9
    10
    5
    6
    2
    8

There are a number of considerations that need to be taken into account.
- identifying the plugin that you want moved (or adding in the option to create and move all in one)
- reading in the array of plugin-ids (multiple panels will have multiple panel arrays) from the correct panel
- re-ordering the array
- writing it back

It is possible to write a wrapper script to do this, maybe re-using some of the code from the previous link, to add functionality to positionally add a new plugin in the correct location on the correct panel, I just haven't seen anyone do it yet.

The other option would be to create an enhancement request to see if a developer will enhance xfconf-query itself with this functionality.

I think this approach is what I need. The only concern is being able to detect what is the plugin_id of my custom launcher. For doing this, I read one your answer in another thread that can help me to specify prior the plugin ID so I can use it for my custom launcher.

The thread is the following: https://forum.xfce.org/viewtopic.php?id=11713

The only issue is: when I apply the four commands you wrote in the thread, the plugin is created correctly with a new ID but from the list of the plugins, I don't see the /plugins/plugin-<id>/items folder, indeed on my panel the icon of the launcher appears but totally empty, despite the filename.desktop is placed correctly in the ~/.config/xfce4/panel/launcher-<id> folder.

I also tried to reset the panel by xfce4-panel -r but with no luck.

Specifically, what I did was:

xfce4-panel --add=launcher
plugin_id_powershell=$(xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -1)
mkdir ~/.config/xfce4/panel/launcher-$plugin_id_powershell

cat <<EOF | tee ~/.config/xfce4/panel/launcher-$plugin_id_powershell/powershell.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=PowerShell
Comment=
Exec=pswh
Icon=/usr/share/icons/shell/powershell.svg
Path=
Terminal=true
Categories=Utility;X-XFCE;X-Xfce-Toplevel;
StartupNotify=true
EOF

The output of xfconf-query -c xfce4-panel -p /plugins -lv is:

/plugins/plugin-1                             whiskermenu
/plugins/plugin-10                            systray
/plugins/plugin-10/known-legacy-items         <<UNSUPPORTED>>
/plugins/plugin-11                            pulseaudio
/plugins/plugin-11/enable-keyboard-shortcuts  false
/plugins/plugin-11/enable-multimedia-keys     false
/plugins/plugin-12                            genmon
/plugins/plugin-14                            launcher
/plugins/plugin-2                             showdesktop
/plugins/plugin-3                             pager
/plugins/plugin-4                             separator
/plugins/plugin-4/expand                      true
/plugins/plugin-4/style                       0
/plugins/plugin-5                             launcher
/plugins/plugin-5/items                       <<UNSUPPORTED>>
/plugins/plugin-6                             launcher
/plugins/plugin-6/items                       <<UNSUPPORTED>>
/plugins/plugin-7                             launcher
/plugins/plugin-7/disable-tooltips            false
/plugins/plugin-7/items                       <<UNSUPPORTED>>
/plugins/plugin-7/show-label                  false
/plugins/plugin-8                             tasklist
/plugins/plugin-9                             clock
/plugins/plugin-9/digital-format              %T
/plugins/plugin-9/mode                        2

where our plugin is the /plugins/plugin-14 and inside ~/.config/xfce4/panel/launcher-14 I have the correct powershell.desktop file as defined above.

But on the panel I have the default icon of launcher with no data inside, so it does not work.

Is there some miss on my side?

Last edited by N00body (2021-11-24 01:14:06)

Offline

#6 2021-11-24 01:28:27

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 8,300

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

You need to create the launcher first. Here is the process I used to create a mousepad launcher and move it to the second position on the panel:

# add the launcher
xfce4-panel --add=launcher /usr/share/applications/org.xfce.mousepad.desktop

# find the plugin id (it's "7")
fgrep -ri mousepad ~/.config/xfce4/panel | awk -F"/" '{print $7}' | uniq | awk -F"-" '{print $2}'

# get the list of existing plugin IDs
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -n +3

# save the new order
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids -s 1 -s 7 -s 2 -s 3 -s 4 -s 5 -s 6 -s 8 -s 9 -s 10 -s 11 -s 12 -s 13 -s 14

# restart the panel
xfce4-panel -r

# launcher re-locates to new location on plugin

Offline

#7 2021-11-24 02:11:09

N00body
Member
Registered: 2021-11-23
Posts: 5

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

ToZ wrote:

You need to create the launcher first. Here is the process I used to create a mousepad launcher and move it to the second position on the panel:

# add the launcher
xfce4-panel --add=launcher /usr/share/applications/org.xfce.mousepad.desktop

# find the plugin id (it's "7")
fgrep -ri mousepad ~/.config/xfce4/panel | awk -F"/" '{print $7}' | uniq | awk -F"-" '{print $2}'

# get the list of existing plugin IDs
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids | tail -n +3

# save the new order
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids -s 1 -s 7 -s 2 -s 3 -s 4 -s 5 -s 6 -s 8 -s 9 -s 10 -s 11 -s 12 -s 13 -s 14

# restart the panel
xfce4-panel -r

# launcher re-locates to new location on plugin

Thank you ToZ! It worked as expected.

I have two last simple questions about the plugins:

When I type

xfconf-query -c xfce4-panel -p /plugins -lv

I get the list of the plugins where some of them are specified in "~/.config/xfce4/panel/" folder and other ones no (i.e., whiskermenu, systray, pulseaudio, and so on). In which folder these items are specified?

About the labelling, with the command above, my custom launchers are all labelled with "launcher". Is it possible to set a custom label by a command as I can see for whiskermenu, systray, pulseaudio?

UPDATE:

I think I can use the following command, example:

xfconf-query -c xfce4-panel -p /plugins/plugin-13 -s labelname -t string

The issue is that, when I type xfce4-panel -r, the icon disappears from the panel.

Last edited by N00body (2021-11-24 02:29:01)

Offline

#8 2021-11-24 02:41:00

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 8,300

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

N00body wrote:

When I type

xfconf-query -c xfce4-panel -p /plugins -lv

I get the list of the plugins where some of them are specified in "~/.config/xfce4/panel/" folder and other ones no (i.e., whiskermenu, systray, pulseaudio, and so on). In which folder these items are specified?

Unfortunately, there is no consistency here - although a move is afoot to migrate all settings to xfconf. The whiskermenu.rc file is located in the panel folder, and both systray and pulseaudio plugins store their data in the xfconf database (the xml files in ~/.config/xfce4/xfconf/xfce-perchannel-xml/ - these files should not be manually edited as long as xfconfd is running - xfconf-query, or the xfce4-settings-editor are the methods to be used to change settings on the fly).

About the labelling, with the command above, my custom launchers are all labelled with "launcher". Is it possible to set a custom label by a command as I can see for whiskermenu, systray, pulseaudio?

UPDATE:

I think I can use the following command, example:

xfconf-query -c xfce4-panel -p /plugins/plugin-13 -s labelname -t string

The issue is that, when I type xfce4-panel -r, the icon disappears from the panel.

I don't believe labelname is a valid setting. All launchers will be named "launcher-" - only the prefix (the plugin ID) will change.

Offline

#9 2021-11-24 03:13:34

N00body
Member
Registered: 2021-11-23
Posts: 5

Re: XFCE 4.16 - move custom launcher icons on the panel by command line

Thank you for all the answer!

It was all I needed ^^

And thank you also for your availability.

Offline

Board footer

Powered by FluxBB