You are not logged in.
Pages: 1
Okay so let's say I'm running a Custom Action.
If I run:
xdotool key F5
...it hits F5 on whatever window is currently in focus, so it could be the correct window, but if I had to switch to a browser it might refresh the webpage that's showing in the browser. There's no guarantee the Thunar window gets refreshed.
So if the name (title) of the Thunar window is the folder name "Folder Name", judging by what I've read about "Command Chaining" as documented in `man xdotool' I should be able to refresh the Thunar windows with something like this:
#### the following attempts are not working
$ xdotool search "Folder Name" key --window %@ F5
$ xdotool search "Folder Name" -- key --window %@ F5
xdotool: Unknown command: --
$ xdotool search "Folder Name" key F5
$ xdotool search "Folder Name" -- key F5
$ xdotool search "Folder Name" key %@ F5
(symbol) No such key name '%@'. Ignoring it.
$ xdotool search "Folder Name" -- key %@ F5
$ xdotool search "Folder Name" -- key --clearmodifiers F5
#### etc.
... but nothing. No refresh.
Before someone asks, yes the *** xdotool search "Folder Name" *** does output Window ID numbers.
Can anyone see where I'm losing out?
Offline
Out of curiosity, why are trying to refresh the thunar window - doesn't it automatically refresh when changes are made?
Here are some important notes from the xdotool man page about sending key events to unfocused windows:
SENDEVENT NOTES
If you are trying to send key input to a specific window, and it does
not appear to be working, then it's likely your application is ignoring
the events xdotool is generating. This is fairly common.Sending keystrokes to a specific window uses a different API than
simply typing to the active window. If you specify 'xdotool type
--window 12345 hello' xdotool will generate key events and send them
directly to window 12345. However, X11 servers will set a special flag
on all events generated in this way (see XEvent.xany.send_event in
X11's manual). Many programs observe this flag and reject these events.It is important to note that for key and mouse events, we only use
XSendEvent when a specific window is targeted. Otherwise, we use XTEST.Some programs can be configured to accept events even if they are
generated by xdotool. Seek the documentation of your application for
help.Specific application notes (from the author's testing): * Firefox 3
seems to ignore all input when it does not have focus. * xterm can be
configured while running with ctrl+leftclick, 'Allow SendEvents' *
gnome-terminal appears to accept generated input by default.
It would appear that you would need to activate (windowactive) the thunar window first to send to key events.
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
Thanks Toz,
Using your 'windowactivate' tip did get me a step closer, but also partly pulling my hair out rn.
Out of curiosity, why are trying to refresh the thunar window - doesn't it automatically refresh when changes are made?
Emblem changes.
Re what you shared:
Some programs can be configured to accept events even if they are
generated by xdotool. Seek the documentation of your application for
help.
Can I do anything extra to help xdotool play nice with thunar?
Either I'm doing something wrong or xdotool is a bit buggy. In the below when I say buggy I mean that the mouse cursor would flicker between the normal mouse cursor and the busy cursor, especially when the mouse is hovering over Thunar. Also Thunar's top menu showed a busy spinner (partly flickering) in the top right corner. This bugginess would continue until a key was pressed.
sleep 1
#xdotool search "Folder Name" windowactivate -- key F5 # WORKED FROM TERMINAL but BUGGY... SOMETIMES WORKED WHEN FOCUS ELSEWHERE... NEVER WORKED DURING NORMAL OPERATION (after zenity box)
xdotool search --name "Folder Name" windowactivate key --delay 100 F5 # WORKED WHEN NO FOCUS BUT BUGGY... WORKED FROM TERMINAL BUT BUGGY... DID NOT WORK DURING NORMAL OPERATION (after zenity box)
#xdotool search --name "Folder Name" windowactivate -- key --clearmodifiers "F5" #WORKED FROM TERMINAL ONCE OF MANY ATTEMPTS BUT WAS ALSO BUGGY AND OUTPUTTED TILDES REPEATEDLY TO THE TERMINAL UNTIL I HIT ANY KEY
Offline
Another tool you could try using is xte (it uses the XTest extension) but I think you will run into the same issue if thunar is no longer focused.
I do something similar when mounting my gdrive through rclone (setting an emblem to indicate mounted), but I always wait for the action to complete before changing focus because of this.
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
UPDATE - yesterday I got it working like this and I feel dumb for not doing it in two lines sooner.
xdotool search --name "$FOLDER_NAME" windowactivate
xdotool key F5
The issue with it though that I found today, is the string given to 'search' is interpreted as a regex. I've not been able to get it to find Thunar windows (folders) with (') apostrophies, ($) dollar signs, '(){}[]' parentheses, (+) plus signs, (\) backslashes and (*) asterisks in them. Backslashes and asterisks I could care less about supporting but the others I do. The only tip I've been able to find was to use quotes in quotes (https://serverfault.com/questions/83129 … grep-regex)...
xdotool search --name \'"$FOLDER_NAME"\' windowactivate
... but it doesn't seem to work because it's a special (-P)erl form (see link for how they use this Perl form in `grep') so I'm a teensy bit lost.
ALMOST THERE THOUGH!
Offline
Hi Xfcellows,
I cobbled together this and it works like... always!!
# Refresh (F5) the Thunar window so all emblems show
for win in `wmctrl -lx | tr -s ' ' | grep -i "thunar" | grep --fixed-strings "$FOLDER_NAME" | cut -d' ' -f1`
do
wmctrl -i -a $win && xdotool key F5
done
WooHOOOO!!!
(By the way I've found another bug related to emblems (I think i might be the "emblem queen" lol). When you use for example a bash script to change the emblems in some way, then you hit the forward and/or back button in thunar, the emblems don't update. This is counter-intuitive. I've made a ticket in the gitlab at https://gitlab.xfce.org/xfce/thunar/-/issues/630 )
Offline
Pages: 1
[ Generated in 0.009 seconds, 8 queries executed - Memory usage: 552.14 KiB (Peak: 569.42 KiB) ]