Hi I am trying to refresh my Desktop, simulate "F5"/"ctrl+R" key pressing using xdotool.
I have tried to xdotool key F5 but I got
^[[15~jake#jake-PC ~ $ ~
and after pressing Enter:
bash: /home/jake: Is a directory
Then I have tried
xdotool search --classname Desktop
73400321
Got that id, then tried:
xdotool search --classname Desktop key F5
xdotool search --classname Desktop key ctrl+R
it didn't refresh my page.
Question: what can I do to refresh my desktop? By the way I am using Ubuntu 16.04. Thank you
You need to call with sync:
xdotool search --onlyvisible --classname Desktop windowactivate --sync key F5
also you can try xdotool script like this:
#!/usr/bin/env xdotool
keydown Ctrl
keydown super
sleep 0.1
key D
keyup Ctrl
keyup super
key F5
Another alternative you can use exec function on xdotool to call show desktop script (or create it)
Related
I want to read the content of a text file, copy it to the clipboard (if it is not empty) and then paste to the gedit window where the mouse cursor is positioned.
Here is my script:
while true
do
if [ -s textfile ]
then
cat textfile | xclip -selection clipboard
xdotool key --clearmodifiers Control_L+v
truncate -s 0 textfile
fi
done
All works except xdotool:
If i press manually CTRL+v it paste correctly.
If i run xev i can see that xdotool send the correct keyboard events, but nothing happen.
I have tried some other commands, like:
xdotool key ctrl+v
xdotool type $(xclip -selection clipboard -o)
xdotool getactivewindow type $(xclip -selection clipboard -o), that gives me the error XGetWindowProperty[_NET_ACTIVE_WINDOW] failed (code=1)
sleep 1 && xdotool key Control_L+v
No Luck.
Can someone help me?
This worked for me :
xdotool type "$(xclip -o)"
I solved, the problem was that Libx11-dev was missing. Once the library was installed, the script worked correctly.
I have opened a gnome terminal as a new different window terminal using the gnome command in Linux. Now what I want is that I want to close only that gnome terminal by giving a certain command in the other terminal.
I had tried a command as 'kill PID', but with that both the terminals are closed.
Can anyone help me with how to close only the gnome terminal by writing command in the other terminal??
Use "xdotool" to send alt+F4 to the target window. Replace zeros with your windowID:
xdotool windowactivate --sync 00000000 key --clearmodifiers alt+F4
You can use "xdotool search" to get the windowID. Insert between quotes the terminal title:
xdotool search --name "text_to_search"
Joining all commands:
xdotool windowactivate --sync $(xdotool search --name "text_to_search") key --clearmodifiers alt+F4
If you need, add "--delay 100" to get a better performance.
To install "xdotool" type:
sudo apt-get install xdotool
I've been making a script which makes you unable to exit the terminal, unless you enter "yes". I've used this command to disable the Alt key temporarily.
xdotool keyup Alt_L Alt_R
I am now unable to "release" the key and my Alt key doesn't work properly anymore.
I did try
xdotool keydown Alt_L Alt_R
which resulted in constant pressing of the Alt key.
I did find out, that uninstalling xdotool makes the Alt key working again.
Yet I still need the Xdotool. Therefore this is not a option for me.
Can you help me "release" the Alt key and neither make it pressed, nor permanently unpressed?
Some additional information:
I am using Linux Mint 18.
And my script is running with bash.
Okay you will hate me for this answer. My mistake was that I had "Save session" in the options restarting. This resulted in a forkbomb curl command loop and it didn't release the alt key. I will try this keydown command again and then see what happens. I am not sure if this is only on Linux mint 18, or on other Linux distros.
I try to run gedit from terminal and type some text in a file opened there, but have no success. I try to use gedit; sleep 2; xte -x display 'key k'; command but this one run gedit only(without typing the k char). Can some one chip in me?
Xdotool (no idea what happened to the webpage, here is its source) is great for that:
xdotool key k
And with gedit:
gedit & sleep 2; xdotool key k;
I would like to have xdotool detect if a right-click is on a particular window (I can capture window IDs without problem), and then run the appropriate shell command/function, if the click was on the desired window..
In real terms this means I want xdotool to get the window ID of a VLC video playback window, and then to run a specific command if I right click on that window.
I am using BASH 4.2.0(1)-release, and Xdotool 2.20101012.3049
EDIT: This is as close as I have got, but it does not work:
xdotool search --name "VLC" behave %# mouse-click exec 'myscript'
However, these commands DO work, but is not really what I need:
xdotool search --name "VLC" behave %# mouse-enter exec 'myscript'
xdotool search --name "VLC" behave %# mouse-leave exec 'myscript'
Cheers..
Something like following might work:
xdotool behave 18893317 mouse-click exec '/usr/bin/bash -c "echo hi"'
However xdotool doesn't work for arbitrary applications. You could try to read mouse events directly using: evdev.py
ls -l /dev/input/by-id/usb-062a_0000-event-mouse
lrwxrwxrwx 1 root root 9 2011-12-21 18:05 /dev/input/by-id/usb-062a_0000-event-mouse -> ../event4
evdev.py /dev/input/event4
When you get click you can use coordinates to determine if it's within VLC window (by comparing with coordinates returned by xdotool).
I realize this is a very old thread, but man xdotool SENDEVENT NOTES explains (implicitly) why 'mouse-click' may not work.
Alternatively, using 'focus' instead of 'mouse-click' does work for a user mouse click.
Note that the command
xdotool search --name "VLC" behave %# focus exec 'myscript'
may not terminate, but remain active. At least this is true for the way I am trying to use it, to set cropping locations in imagemagic, thus
xdotool search --name "imagemagic" behave %# focus getmouselocation