Page 1 of 1

How to make a shotrtcut key to kill xdotool?

Posted: Fri Jan 05, 2024 2:51 pm
by theroar84

I am running Fossa64 with Frugal installs on ext4 hard drives. Multiple frugal installs per pc. I have whipped up some scrips for xdotool. Occasionally I mis click... I would
love to have a shortcut key that could terminate xdotool.

Initially, I thought I wanted t a terminate option in each script, but terminating xdotool is pretty nifty. I also create scripts for windows powerpro and they nudged me towards the shortcut to close PowerPro. It has been super slick as I can now hit Ctrl+F3 and everything halts.

I have made shortcut keys in JWM. I just tried making Ctrl+F3 do pkill -f xdotool but that did not stop my script I was testing.

Any tips as to where I am going wrong?


Re: Kill xdotool with a shotrtcut key?

Posted: Sat Jan 06, 2024 1:15 am
by williwaw

maybe Ctrl+F3 is assigned to a different function?

how do you run the script that runs xdotool? Kill the script instead?


Re: Kill xdotool with a shotrtcut key?

Posted: Sat Jan 06, 2024 1:32 am
by rockedge
theroar84 wrote:

I just tried making Ctrl+F3 do pkill -f xdotool but that did not stop my script I was testing.

How about replacing the pkill -f xdotool with killall xdotool :geek:


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 2:22 am
by theroar84

The script is started by clicking on it. I will do some looking to see if Ctrl+F3 is assigned elsewhere, but I thought it was clear.

Will give the killall a shot.

Thanks for both tips!


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 2:48 am
by theroar84

I did not get the killall to work. After a few attempts I started receiving an error (configuration file does not exist) when launching JWM and clicking the hotkey manager. Even after reboot that occurred so I will fiddle tomorrow.

I did launch the task manager and found that killing the .sh file I had launched from worked like a champ.

Is it possible to send a killall *.sh command? Or is there a different wild card I should use to wipe out any .sh processes I have running. I think my scripts are the only .sh items ever running.

I have noticed that the xdotool scripts can overlap and function fine. I have one that runs ever 7 min and it has coincided with my manual options at times.

Thanks again for all the tips!


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 4:50 am
by williwaw
theroar84 wrote: Mon Jan 08, 2024 2:22 am

The script is started by clicking on it.

stopping with a command or another clickable script would work. killall *.sh would work if there was no other .sh process running but why take a chance? the extra steps taken to run a second script or command to kill could be streamlined.

one possible way foreward might be to have the clickable script run as a child process in a terminal window? closing the window would then kill the script.
urxvt -hold -e myscript

if your script is a simple command, you can also
urxvt -e sh -c 'xdotool whatever'


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 2:07 pm
by theroar84

Thanks. I had just added my kill command as the shortcut key command... I had a hunch this morning that making the command a script might be smarter.

As far as killing all the .sh files... Puppy does not have any built in .sh commands that run... correct?

My scripts are really simple. Just xdotool mousemoves and clicks. I do have them in a loop now, so that is where being able to halt them would be great.

Will fiddle with the child process.

Not quite sure what this one is doing. Is the sh call for all sh files? -c is close I assume. I am not sure what the 'xdotool whatever' is about though. I will give it a go and maybe the result will set me straight when it runs.
urxvt -e sh -c 'xdotool whatever'

Sure do appreciate the time and effort!


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 5:36 pm
by williwaw
theroar84 wrote: Mon Jan 08, 2024 2:07 pm

As far as killing all the .sh files... Puppy does not have any built in .sh commands that run... correct?

dunno, but some app might

I am not sure what the 'xdotool whatever' is about though
My scripts are really simple.

without seeing the xdotool script, 'whatever' is just my guess for whatever it might contain


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 7:54 pm
by theroar84

This is the script code. Sorry I did not include that earlier. Currently it only loops 3x. When I have a system to halt it I will likely let it run longer.

This for loop prints the numbers from 1 to 3.

for i in {1..3}; do
xdotool mousemove 246 283
sleep 6
xdotool mousemove 246 561
sleep 6
xdotool mousemove 52 3
xdotool click --delay 1200 1
sleep 6
xdotool mousemove 791 659
sleep 2
xdotool click --delay 1200 1
xdotool mousemove 503 558
sleep 6
xdotool click --delay 1200 5
sleep 6
#echo $i;
if [ $i -eq 3]; then
break;
fi
done


Re: How to make a shotrtcut key to kill xdotool?

Posted: Mon Jan 08, 2024 10:44 pm
by Keef

You could run Htop, press F4 (filter) then enter .sh in the box. It will show any running process containing ".sh" in the name, which is likely to be at the end.


Re: How to make a shotrtcut key to kiill xdotool?

Posted: Mon Jan 08, 2024 11:21 pm
by williwaw
theroar84 wrote: Mon Jan 08, 2024 7:54 pm

This is the script code. Sorry I did not include that earlier. Currently it only looks 3x. When I have a system to halt it I will likely let it run longer.

This for loop prints the numbers from 1 to 3.

for i in {1..3}; do
xdotool mousemove 246 283
sleep 6
xdotool mousemove 246 561
sleep 6
xdotool mousemove 52 3
xdotool click --delay 1200 1
sleep 6
xdotool mousemove 791 659
sleep 2
xdotool click --delay 1200 1
xdotool mousemove 503 558
sleep 6
xdotool click --delay 1200 5
sleep 6
#echo $i;
if [ $i -eq 3]; then
break;
fi
done

if you are using urxvt:
the command urxvt -hold -e myscriptname could be placed in a second script.
your xdotool script would have to placed in the path.

the -sh -c works with a single command, and there is probally a way to enclose your entire code in the xdotool script in quotes such that all can be in the same script, but I havent fiddled with it enough to say

your terminal editor might have different options other than -hold used in urxvt to keep the window open


Re: How to make a shotrtcut key to kill xdotool?

Posted: Tue Jan 09, 2024 2:28 am
by MochiMoppel

@theroar84 Your script makes clear why it is useless to try to kill xdotool.
In your script xdotool runs for a split second over and over again. Even if you manage to kill one of the runs, the next one will follow.
So you need to kill the script, and the easiest way to do it is pkill -f scriptname, where scriptname is the name you gave your script. What is the name?
You don't have to give it a .sh extensions, but if you do and you - for whatever reasons - want to kill all running scripts with a .sh extension, you can do that with the command pkill -f "sh.*\.sh$",
Better keep it simple and more specific and use the exact name of your script.


Re: How to make a shotrtcut key to kill xdotool?

Posted: Fri Jan 19, 2024 1:59 am
by theroar84

Once again, thanks for all the tips. The terminal trick works fine. Thank you.

My only issue is that when the urxvt window launches it could be in the way of the clicks.

I am working now on using windowsize and windowmove to get it to a location of my choosing when it launches.