Reputation:
What we have here is a code that looks for the title
AAA
if it finds it, it activates it and then repositions it.
but the problem is, if the file is not open.. it will
open it just fine. however won't activate and reposition it.
a=`xdotool search --name "AAA"`
if [[ "$a" ]]; then
xdotool windowactivate --sync $a
xdotool windowmove --sync $a 377 153
else
leafpad '/media/1/AAA'
xdotool windowactivate --sync $a
xdotool windowmove --sync $a 377 153
fi
i suppose it doesn't have to activate it, given that it would be active when opened, but it can not reposition it.
Upvotes: 2
Views: 2902
Reputation: 23500
Not quite sure what the user is having issues with but here we go:
a=`xdotool search --name "AAA"`
if [[ "$a" ]]; then
xdotool windowactivate --sync $a
xdotool windowmove --sync $a 377 153
else
leafpad '/media/1/AAA'
sleep 5
a=`xdotool search --name "AAA"` # <-- You need this
xdotool windowactivate --sync $a # <-- Otherwise $a will be empty (think about it)
xdotool windowmove --sync $a 377 153
fi
The reason for the window not being re-positioned is because:
You search for 'leafpad' and place it in $a
, but if leafpad isn't started $a
will be empty when you go into the else
block. So you need to search and place leafpad in $a
after it's launched again in order to move it.
Upvotes: 2