Reputation:
if leafpad is open.. and i close it via terminal
killall leafpad
then this xdotool code will work just fine.
it opens a file, waits 2 seconds, searches for the title, and then activates it and moves it around.
leafpad '/media/1/AAA'
sleep 2
a=`xdotool search --name "AAA"`
xdotool windowactivate --sync $a
xdotool windowmove --sync $a 377 153
but let's close leafpad manually without the 'killall leafpad' command.
now let's re-run this script.
nope, this time it is not working.
what is the solution so that this code can ALWAYS work even if leafpad was not closed via killall
command.
what is causing this ?
Upvotes: 0
Views: 502
Reputation: 10663
I am unable to reproduce your situation, but seems like there is a different problem.
leafpad '/media/1/AAA'
This will run leafpad and then WAIT until it is closed. You have to end this line with a & to make it move on:
leafpad '/media/1/AAA' &
Also, I'd refactor your code this way:
leafpad '/media/1/AAA' &
sleep 2
a=$(xdotool search --name 'AAA')
xdotool windowactivate --sync "$a"
xdotool windowmove --sync "$a" 377 153
It is just a good habit to surround parameters with variables inside with "", also `` are sometimes confused with '' so I prefer $() instead. And there's no reason to use "" if you don't have anything expandable inside.
Upvotes: 1