How to make a shotrtcut key to kill xdotool?

New to Puppy and have questions? Start here

Moderator: Forum moderators

Post Reply
User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

How to make a shotrtcut key to kill xdotool?

Post 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?

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

williwaw
Posts: 1869
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 167 times
Been thanked: 340 times

Re: Kill xdotool with a shotrtcut key?

Post by williwaw »

maybe Ctrl+F3 is assigned to a different function?

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

User avatar
rockedge
Site Admin
Posts: 6378
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2578 times
Been thanked: 2533 times
Contact:

Re: Kill xdotool with a shotrtcut key?

Post 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:

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

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

Post 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!

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

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

Post 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!

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

williwaw
Posts: 1869
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 167 times
Been thanked: 340 times

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

Post 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'

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

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

Post 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!

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

williwaw
Posts: 1869
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 167 times
Been thanked: 340 times

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

Post 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

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

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

Post 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

Last edited by theroar84 on Tue Jan 09, 2024 3:23 pm, edited 1 time in total.

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

User avatar
Keef
Posts: 260
Joined: Tue Dec 03, 2019 8:05 pm
Has thanked: 3 times
Been thanked: 73 times

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

Post 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.

williwaw
Posts: 1869
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 167 times
Been thanked: 340 times

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

Post 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

User avatar
MochiMoppel
Posts: 1196
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 20 times
Been thanked: 415 times

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

Post 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.

User avatar
theroar84
Posts: 80
Joined: Sat May 08, 2021 4:21 pm
Location: US
Has thanked: 33 times
Been thanked: 4 times
Contact:

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

Post 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.

Running Fossa64 9.5 Multiple PC's Frugal Installs on EXT4 hard drives. Multiple Frugals per PC too.

Post Reply

Return to “Beginners Help”