Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-06-06 07:03:11

gilgamesh
Member
Registered: 2023-06-06
Posts: 41

[SOLVED] keyboard shortcut command

I've created a keyboard shortcut to insert text in e-mails : sh -c 'sleep 0.5 ; xdotool type "text"' . It's working fine but to get it to work I had to do some research on the web because "my" command which was sleep 0.5 ; xdotool type "text" didn't work and I don't understand why . I tried /usr/bin/xdotool it didn't work either .

My question is : why do I have to use a child process or a subshell ( I am not too sure about which one is initiated by sh ) , or a script with "my" command in it ( when executed the script opens a subshell ) ?  What's wrong with "my" command ?  .

Edit : I found an interesting remark about this problem but I don't understand it either : what has the access to environment variables to do with this problem , except perhaps  PATH  and that's why I tried the absolute path for xdotool ?

The keyboard shortcuts field in Unity works in a similar manner to .desktop files, i.e. commands are executed without any form of subshell or variable expansion and can't access any environment variables.

I wasn't able to find an official specification regarding the keyboard shortcuts menu but I think it's save to assume that command execution follows similar guidelines to the Exec field in XDG .desktop files.

What this means, in practice, is that there are two ways you can make your custom command-line work with the shortcuts menu:

at https://askubuntu.com/questions/508401/ … -shortcuts

Last edited by gilgamesh (2023-06-08 06:35:33)

Offline

#2 2023-06-06 10:05:23

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [SOLVED] keyboard shortcut command

Hello and welcome.

gilgamesh wrote:

I've created a keyboard shortcut to insert text in e-mails : sh -c 'sleep 0.5 ; xdotool type "text"' . It's working fine but to get it to work I had to do some research on the web because "my" command which was sleep 0.5 ; xdotool type "text" didn't work and I don't understand why .

The Xfce command processor isn't a real shell of its own, so it doesn't know how to interpret the ";". So in that case, wrapping the command in a subshell makes it work.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2023-06-06 12:22:36

gilgamesh
Member
Registered: 2023-06-06
Posts: 41

Re: [SOLVED] keyboard shortcut command

ToZ wrote:

Hello and welcome.

The Xfce command processor isn't a real shell of its own, so it doesn't know how to interpret the ";". So in that case, wrapping the command in a subshell makes it work.

Hello ,

the fisrt command I tried was < xdotool type "text" > , there is no " ; " still it didn't work . So I think the problem must be somewhere else , may be the answer given on "Ask Ubuntu" ( see the link above ) is right , but unfortunately I am not learned enough to fully understand it .

Last edited by gilgamesh (2023-06-06 12:38:52)

Offline

#4 2023-06-06 23:15:07

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [SOLVED] keyboard shortcut command

I can't replicate your problem. For me it works fine.

Which distro and version of Xfce are you running?


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2023-06-07 04:35:14

gilgamesh
Member
Registered: 2023-06-06
Posts: 41

Re: [SOLVED] keyboard shortcut command

ToZ wrote:

I can't replicate your problem. For me it works fine.

Which distro and version of Xfce are you running?

I am running Debian 11 / Xfce 4.16  . I also tried Bookworm ( due to become Debian 12 ) / Xfce 4.18 :  the same problem occurred .

Last edited by gilgamesh (2023-06-07 04:52:51)

Offline

#6 2023-06-07 10:34:25

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [SOLVED] keyboard shortcut command

Hmmm. Just tested on Debian 11 and it still works:

Screenshot-2023-06-07-06-28-27.png

However, I do get this in ~/.xsession-errors when I open the keyboard settings app:

(xfce4-keyboard-settings:52077): Gtk-WARNING **: 06:25:47.356: Failed to set text 'sh -c 'sleep 0.5 && xdotool type "test"'' from markup due to error parsing markup: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity — escape ampersand as &amp;

I don't get this message on Arch with 4.18. Let me check Debian 12.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2023-06-07 11:08:37

gilgamesh
Member
Registered: 2023-06-06
Posts: 41

Re: [SOLVED] keyboard shortcut command

ToZ wrote:

Hmmm. Just tested on Debian 11 and it still works:
https://i.ibb.co/pPcZpHd/Screenshot-2023-06-07-06-28-27.png

what exactcly is "still working" ? Looking at your screenshot I don't see the command which doesn't work , i.e the command without <sh -c> .

Last edited by gilgamesh (2023-06-07 11:10:49)

Offline

#8 2023-06-07 11:16:18

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [SOLVED] keyboard shortcut command

The one highlighted works. If I press Ctrl+k the word "test" is printed out in the terminal window, mousepad, firefox, etc...

Perhaps there is some confusion here on my part - it won't work without wrapping it in a shell subscript because Xfce is not a shell and cannot process special characters.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2023-06-07 11:40:14

gilgamesh
Member
Registered: 2023-06-06
Posts: 41

Re: [SOLVED] keyboard shortcut command

ToZ wrote:

The one highlighted works. If I press Ctrl+k the word "test" is printed out in the terminal window, mousepad, firefox, etc...

Perhaps there is some confusion here on my part - it won't work without wrapping it in a shell subscript because Xfce is not a shell and cannot process special characters.

OK , I agree with that : if you wrap it in a subshell ( script or <sh -c> ) it works , if you don't do that it doesn't work . The question is : why do we need a subshell ? Is it because all the environment variables are there , in the subshell , and the command can be interpreted or is it because ......?

Last edited by gilgamesh (2023-06-07 11:41:20)

Offline

#10 2023-06-07 11:41:40

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [SOLVED] keyboard shortcut command

The built-in Xfce command interpreter is not a shell. Any complicated commands, especially those that use special characters, need to be embedded in a subshell.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#11 2023-06-07 11:47:42

gilgamesh
Member
Registered: 2023-06-06
Posts: 41

Re: [SOLVED] keyboard shortcut command

ToZ wrote:

The built-in Xfce command interpreter is not a shell. Any complicated commands, especially those that use special characters, need to be embedded in a subshell.

OK , I buy it . Solved .

Thanks for the help .

Last edited by gilgamesh (2023-06-07 11:48:47)

Offline

#12 2023-08-05 20:01:07

vinibali
Member
Registered: 2013-08-13
Posts: 2

Re: [SOLVED] keyboard shortcut command

That helped me too, thanks!

ToZ wrote:

Hmmm. Just tested on Debian 11 and it still works:

https://i.ibb.co/pPcZpHd/Screenshot-2023-06-07-06-28-27.png

However, I do get this in ~/.xsession-errors when I open the keyboard settings app:

(xfce4-keyboard-settings:52077): Gtk-WARNING **: 06:25:47.356: Failed to set text 'sh -c 'sleep 0.5 && xdotool type "test"'' from markup due to error parsing markup: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity — escape ampersand as &amp;

I don't get this message on Arch with 4.18. Let me check Debian 12.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.016 seconds, 7 queries executed - Memory usage: 588.68 KiB (Peak: 605.52 KiB) ]