The time now is Sat 25 May 2013, 09:43
All times are UTC - 4 |
| Author |
Message |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Mon 11 Mar 2013, 15:15 Post subject:
|
|
| SFR wrote: | Basically it's a nice looking one-liner, which multiplies itself (or rather its own process) ad infinitum, what makes system completely freezed.
Sadly, Puppy isn't immune for that kind of attack..! | It's very handy for me to know that I need to take care to avoid such risks. I'm always keen to tinker and "have a bash" so I would've dived in and locked up my system for sure... Wiki suggests this as a means of prevention: | Quote: | | As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own. | I wonder if this might be possible on Puppy.
BTW - My reason for wanting these scripts to help with mouse movement is to allow an inexperienced or physically challenged user to easily select between a limited number of mousepointer_position_choices. That way they can have some degree of functionality by having a "mouseclick" button, but no actual ability to move the mouse anywhere I don't want it to go.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Mon 11 Mar 2013, 15:55 Post subject:
|
|
| greengeek wrote: | | SFR wrote: | infinite loop, but deprived of deadly "fork" mechanism) can be utilized as well:
| Code: | | :(){ echo "Loop..."; sleep 1; :; };: |
But of course this is not a good idea to have something like that in your code, so consider this as a "tip of the day". | Do you mean that it's not a good idea because it's so easy to get it wrong (and include a recursive fork by mistake)? |
That too, but primarily, because 'while...' or 'until...' are most simple/common/readable methods.
But it may be useful, for example, if you'd like to deliberately obfuscate the code.
| greengeek wrote: | Wiki suggests this as a means of prevention:
| Quote: | | As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own. |
I wonder if this might be possible on Puppy. |
Hard to say...
| Quote: | # ulimit -a | grep "max user processes"
max user processes (-u) 30948
# |
shows that max. number of processes is limited, but it doesn't seem to work (maybe it doesn't affect root account?).
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Mon 11 Mar 2013, 17:30 Post subject:
|
|
| greengeek wrote: | | BTW - My reason for wanting these scripts to help with mouse movement is to allow an inexperienced or physically challenged user to easily select between a limited number of mousepointer_position_choices. That way they can have some degree of functionality by having a "mouseclick" button, but no actual ability to move the mouse anywhere I don't want it to go. |
I saw that thread.
Been thinking a while about that and about how you want to employ xdotool and came up with this; perhaps it will help you a bit with the task, somehow..?
First, using xbindkeys (it's OOTB in Slacko) bind, for example, "pause/break" key (OP has mentioned about this key) with echo true > /tmp/button_press_signal command (see screenshot, I also use xbindkeys-config GUI).
And the script works this way:
1. It moves cursor right until pause/break key is pressed.
2. Then stops for a while (0.5s) and starts moving cursor down until pause/break key is pressed.
3. Then "left-click" signal is sent and cursor stays in place until pause/break key is pressed again - and the loop continues.
Maybe this description is a bit fuzzy, but when you see how it works everything will be clear.
BTW, launch this script from a terminal window to have fast and easy way to terminate it (CTRL+C).
| Code: | #!/bin/bash
# Req.: xdotool and xbindkeys
# Note: bind a dead key, for exmample 'pause/break' with the following command:
# echo true > /tmp/button_press_signal
# -----------------------------------------------------------------------------
STEP=5 # X/Y leap
SPEED=0.1 # speed (0.1s)
# -----------------------------------------------------------------------------
# Temporary file for inter-communication
PRESS=/tmp/button_press_signal
# Make this file empty initially
: > $PRESS
# Read current screen resolution
read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'`
# Infinite loop
while :; do
X=0
Y=10
# Loop: If tempfile is empty - move cursor right
until [ -s $PRESS ]; do
X=$(($X+$STEP)); [ "$X" -ge "$MAXX" ] && X=0 # increase X coordinate
xdotool mousemove $X $Y
sleep $SPEED
done
: > $PRESS # reset tempfile
sleep 0.5
# Loop: If tempfile is empty - move cursor down
until [ -s $PRESS ]; do
Y=$(($Y+$STEP)); [ "$Y" -ge "$MAXY" ] && Y=10 # increase Y coordinate
xdotool mousemove $X $Y
sleep $SPEED
done
: > $PRESS # reset tempfile
Y=$(($Y-$STEP)) # needed to refine coordinates
xdotool click 1 # left-click
# If tempfile is empty - do nothing
until [ -s $PRESS ]; do
sleep $SPEED
done
: > $PRESS # reset tempfile
done |
PS. Of course you can modify initial coordinates, max. range and step, to limit the mouse movement to given area.
Greetings!
| Description |
|
| Filesize |
71.57 KB |
| Viewed |
256 Time(s) |

|
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Mon 11 Mar 2013, 22:14 Post subject:
|
|
oooooh, that looks tasty! Thanks for that. It's a different way of achieving what I had in mind, but probably more useful than the way I'm currently going about it.
I will get my teeth into your script at some stage and see how I can graft it into my proposed system. Thanks!
EDIT: | SFR wrote: | | BTW, launch this script from a terminal window to have fast and easy way to terminate it (CTRL+C). | Good idea. I'm getting tired of having to try and launch Htop to identify and kill my mousebouncing script while my mouse is bouncing up and down
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Tue 12 Mar 2013, 11:04 Post subject:
|
|
| SFR wrote: | | Code: | | read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'` |
| I see you've been honing your scripting 5|<I|_|_2 - nice work
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Tue 12 Mar 2013, 14:40 Post subject:
|
|
| technosaurus wrote: | | SFR wrote: | | Code: | | read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'` |
| I see you've been honing your scripting 5|<I|_|_2 - nice work |
I'm trying indeed, thanks for noticing that!
6R3372
@ Greengeek
Just another idea that you may find useful.
I just saw this video and wondered if it would be possible to implemet something similar (I'm talking about cursor movement) in Bash/Gtkdialog.
This crude script only moves cursor and does nothing more, but it shows that it's possible indeed.
Usage:
1. Wait for desired direction and press Pause/Break
2. Cursor will be moving until you press Pause/Break again and we're going back to 1.
| Code: | #!/bin/bash
# Req.: Gtkdialog >= 0.8.0, xdotool, xbindkeys, xwininfo, getcurpos, bc, awk
# Note: bind a dead key, for exmample 'pause/break' with the following command:
# echo true > /tmp/button_press_signal
TEMPDIR=/dev/shm/one_switch_temp
mkdir $TEMPDIR
# Delete tempdir or exit
trap 'rm -rf $TEMPDIR' EXIT
PRESS=/tmp/button_press_signal
: > $PRESS
export PIC=$TEMPDIR/cursor_pic
export ROTATION=$TEMPDIR/cursor_rotate
echo 0 > $ROTATION
rotate_line () {
read DEG < $ROTATION
RAD="`echo 'scale=2; '$DEG' * 3.14 / 180' | bc -l`"
LX="`echo 'scale=2; 32 + 24 * c('$RAD')' | bc -l`"
LY="`echo 'scale=2; 32 + 24 * s('$RAD')' | bc -l`"
DEG=$(($DEG+5))
[ "$DEG" -ge 360 ] && DEG=0
echo $DEG > $ROTATION
# Create svg pic
echo '<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="32" cy="32" r="24" stroke="red" fill="none" stroke-width="3" />
<line x1="32" y1="32" x2="'$LX'" y2="'$LY'" stroke="black" stroke-width="3" />
</svg>' > $PIC
}
export -f rotate_line
# First call just to make a picture
rotate_line
# Read current screen resolution
read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'`
# Gtkdialog window
export PREVIEW='
<window decorated="false" skip-pager-hint="true" skip-taskbar-hint="true" resizable="false">
<pixmap>
<variable>PICTURE</variable>
<input file>'"$PIC"'</input>
</pixmap>
<timer visible="false" milliseconds="true" interval="100">
<action>rotate_line</action>
<action>refresh:PICTURE</action>
</timer>
</window>
'
# Infinite loop
while :; do
# Current cursor position
read CX CY <<< `getcurpos`
CX=$(($CX-32)); [ $CX -lt 0 ] && CX=0
CY=$(($CY-32)); [ $CY -lt 0 ] && CY=0
# Show window
gtkdialog -G 64x64+$CX+$CY -p PREVIEW & GTKPID=$!
# Wait for switch signal
until [ -s $PRESS ]; do
sleep 0.1
done
# Kill Gtkdialog window
kill $GTKPID
: > $PRESS
read DEG < $ROTATION
DEG=$(($DEG+85))
# Move cursor until switch signal will appear again
until [ -s $PRESS ]; do
xdotool mousemove_relative --polar $DEG 5
sleep 0.1
done
: > $PRESS
done |
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Tue 12 Mar 2013, 15:30 Post subject:
|
|
EDIT : I was posting this when you made your newer post... I am referring here to your first script...
| SFR wrote: | | And the script works this way:.. |
I think this has a lot of potential. Do you think it would be possible to modify that script so that it has a coarse mode and a fine mode? By this I mean it would scroll quite fast initially ("coarse mode") in order to pinpoint the general area of the screen you wanted to click on, then drop immediately into "fine" mode where the scroll speed would be much slower, and limited to, say, a 2cm square around the "coarse select" point?
(My thinking is that your script would be the "default mode" that the PC would drop back to every time there was no "mouseclick" input for, say, 20 seconds - which would then allow the user to zone in on any part of the screen (not just the onscreen keyboard) and begin whatever task they wanted. The onscreen keyboard would then be only one of several input modes available to the user, all controlled by your SFRmouse script as the default)
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Tue 12 Mar 2013, 15:40 Post subject:
|
|
Yeah, that Tilvus line cursor is a good idea. Not necessary to have a line though - although that obviously does help clarity (and their nudge function is well thought out..).
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Tue 12 Mar 2013, 16:19 Post subject:
|
|
| greengeek wrote: | EDIT : I was posting this when you made your newer post... I am referring here to your first script...
| SFR wrote: | | And the script works this way:.. |
I think this has a lot of potential. Do you think it would be possible to modify that script so that it has a coarse mode and a fine mode? By this I mean it would scroll quite fast initially ("coarse mode") in order to pinpoint the general area of the screen you wanted to click on, then drop immediately into "fine" mode where the scroll speed would be much slower, and limited to, say, a 2cm square around the "coarse select" point? |
You mean something like:
1. Looped cursor movement right (coarse) within fullscreen
2. Looped cursor movement down (coarse) within fullscreen
3. Looped cursor movement right (fine) within reduced area
4. Looped cursor movement down (fine) within reduced area
5. Left-click
6. GOTO 1
?
If so, it's just a matter of two additional loops; could be like this:
| Code: | #!/bin/bash
# Req.: xdotool and xbindkeys
# Note: bind a dead key, for exmample 'pause/break' with the following command:
# echo true > /tmp/button_press_signal
# -----------------------------------------------------------------------------
STEP_COARSE=64
STEP_FINE=4
SPEED_COARSE=0.5
SPEED_FINE=0.1
# -----------------------------------------------------------------------------
# Temporary file for inter-communication
PRESS=/tmp/button_press_signal
# Make this file empty initially
: > $PRESS
# Read current screen resolution
read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'`
# Infinite loop
while :; do
X=0
Y=10
# ======
# COARSE
# ======
until [ -s $PRESS ]; do
X=$(($X+$STEP_COARSE)); [ $X -ge $MAXX ] && X=0
xdotool mousemove $X $Y
sleep $SPEED_COARSE
done
: > $PRESS
sleep 0.5
until [ -s $PRESS ]; do
Y=$(($Y+$STEP_COARSE)); [ $Y -ge $MAXY ] && Y=10
xdotool mousemove $X $Y
sleep $SPEED_COARSE
done
: > $PRESS
# Reduce area to 64x64
X1=$(($X-32)); [ $X1 -lt 0 ] && X1=0
Y1=$(($Y-32)); [ $Y1 -lt 0 ] && Y1=0
X2=$(($X+32)); [ $X2 -gt $MAXX ] && X2=$MAXX
Y2=$(($Y+32)); [ $Y2 -gt $MAXY ] && Y2=$MAXY
# ====
# FINE
# ====
until [ -s $PRESS ]; do
X=$(($X+$STEP_FINE)); [ $X -ge $X2 ] && X=$X1
xdotool mousemove $X $Y
sleep $SPEED_FINE
done
: > $PRESS
sleep 0.5
until [ -s $PRESS ]; do
Y=$(($Y+$STEP_FINE)); [ $Y -ge $Y2 ] && Y=$Y1
xdotool mousemove $X $Y
sleep $SPEED_FINE
done
: > $PRESS
xdotool click 1 # left-click
# If tempfile is empty - do nothing
until [ -s $PRESS ]; do
sleep 0.1
done
: > $PRESS # reset tempfile
done |
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Tue 12 Mar 2013, 17:47 Post subject:
|
|
| SFR wrote: | You mean something like:
1. Looped cursor movement right (coarse) within fullscreen
2. Looped cursor movement down (coarse) within fullscreen
3. Looped cursor movement right (fine) within reduced area
4. Looped cursor movement down (fine) within reduced area
5. Left-click
6. GOTO 1
?
|
Yes, that's the concept. I hope to try your script after work tonight. I'm hoping to handle everything with a mousebutton only (instead of the pause/break) but getting the cursor movement right is the first major step.
You are redundifying my initial "xdotool mousemove" plan, but that's probably a good thing
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Wed 13 Mar 2013, 13:07 Post subject:
|
|
I think I must be doing something wrong with my manual keybinding method. I can't get the script to respond to the pause key. The end paragraph of my /root/.jwm/jwm-personal looks like this:
| Code: |
<Key keycode="160">exec:amixer sset Master toggle</Key>
<Key keycode="176">exec:amixer sset Master 1+,1+</Key>
<Key keycode="174">exec:amixer sset Master 1-,1-</Key>
<Key keycode="178">exec:defaultbrowser</Key>
<Key keycode="236">exec:defaultbrowser</Key>
<Key keycode="111">exec:mtpaintsnapshot.sh</Key>
<Key keycode="75">exec:doubleclick_xdotool</Key>
<Key keycode="110">echo true > /tmp/button_press_signal</Key>
</JWM> |
I'm running Slacko53 so maybe I do already have xbindkeys as you suggested. I just need to do a bit of research to find out how to drive xbindkeys. I probably should load the gui.
EDIT : I just tried xbindkeys -k and it works so I definitely have xbindkeys. That cmd gave me some info which I am apparently supposed to graft into my /root/.xbindkeysrc file, which now has this:
| Code: | # Task manager
"/usr/local/bin/pprocess"
Control+Alt + Delete
#Added by greengeek to allow pause button to work with SFR mousemove script
"echo true > /tmp/button_press_signal"
m:0x0 + c:110
Pause
##################################
# End of xbindkeys configuration #
################################## |
but still no joy yet.
EDIT : Maybe I need to restart Xserver instead of just jwm each time.
EDIT : Yes! that's what was wrong - I needed to resatrt X.
SFR - This script is fantastic!!! It's giving me really good control over focus and positioning. I think I can use this to really good advantage. Thanks!!
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Thu 14 Mar 2013, 03:36 Post subject:
|
|
Hi SFR: the parameters that I think suit my needs perfectly are:
| Code: | STEP_COARSE=2
STEP_FINE=1
SPEED_COARSE=0.01
SPEED_FINE=0.1 |
If it is possible I would like the cursor to pause momentarily as it loops horizontally back through X=0 so that it is easier to line the pointer up with the menu button without overshooting (or maybe pause at x=15), and also pause momentarily as it loops vertically through y=10.
My guess is it would need to be something like:
| Code: | # ======
# COARSE
# ======
until [ -s $PRESS ]; do
X=$(($X+$STEP_COARSE)); [ $X -ge $MAXX ] && X=0
xdotool mousemove $X $Y
#greengeek mod for pause momentarily at x=15
#if x=15
#sleep 2
#fi
sleep $SPEED_COARSE
done
: > $PRESS
sleep 0.5
until [ -s $PRESS ]; do
Y=$(($Y+$STEP_COARSE)); [ $Y -ge $MAXY ] && Y=10
xdotool mousemove $X $Y
#greengeek mod for pause momentarily at y=10
#if y=10
#sleep 2
#fi
sleep $SPEED_COARSE
done
: > $PRESS |
But of course it's a stab in the dark as usual. Can you help?? (P_l_e_e_e_a_s_e..) Thanks!
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Thu 14 Mar 2013, 04:58 Post subject:
|
|
test post using sfr2
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 572
|
Posted: Thu 14 Mar 2013, 06:28 Post subject:
|
|
Hey Greengeek
| Code: | # ======
# COARSE
# ======
until [ -s $PRESS ]; do
X=$(($X+$STEP_COARSE)); [ $X -ge $MAXX ] && X=0
xdotool mousemove $X $Y
[ $X = 16 ] && sleep 2 || sleep $SPEED_COARSE # X must be even, since STEP_COARSE=2
done
: > $PRESS
sleep 0.5
until [ -s $PRESS ]; do
Y=$(($Y+$STEP_COARSE)); [ $Y -ge $MAXY ] && Y=10
xdotool mousemove $X $Y
[ $Y = 10 ] && sleep 2 || sleep $SPEED_COARSE # Y must be even, since STEP_COARSE=2
done
: > $PRESS |
However, I just noticed that while Menu (also pull-down menus) is opened, xbindkeys are off for some reason (tried under Compiz & JWM).
Do you have the same problem with this?
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
greengeek
Joined: 20 Jul 2010 Posts: 1184 Location: New Zealand
|
Posted: Thu 14 Mar 2013, 10:21 Post subject:
|
|
Yes, same problem here. Still trying to nut out a way around that. Also been seeing a couple of oddities that seem to be interactions between certain open windows. For example sometimes I hit the print scrn key by mistake and the screenshot timer opens up, and I get several mousepointers on screen at once, all doing their own thing (aaaaarrrgggh!).
With regard to the lockout of xbindkeys I thought about the possibility of having a separate script running in the background which waited till it detected a period of 10 or fifteen seconds where there was no mouse or key action, then automatically generated an "arrow down one" keystroke (slowly repeated until the pause break key was hit again). Sorry that this description is not that clear - what I mean is that I found that when I selected something like the "File" tab in a window, and the dropdown menu appeared, I was not able to use the pause key, but WAS able to tap the arrow down key to scroll down through the menu choices. I have it in mind that the pause key then came back active but I'm going to have to confirm that.
In trying to find a way around these issues I did note a couple of times that I got the focus back onto the sfr2 script, and was able to carry on, but had no idea exactly how/why.
In particular I noticed different window interactions depending on whether I started sfr2 by clicking the script icon, or by opening a terminal there and using the ./sfr2 syntax.
EDIT : Also I noticed that behaviours were slightly altered when I was using xvkbd onscreen at the same time. It has it's own "focus" button so that was adding extra confusion to my trials. I can't yet pin down all the symptoms/variations I'm getting.
Lots more testing for me to do.
EDIT : BTW - the delay that you added for low values of X and Y is excellent. Perfect. Well done adjusting for even values. I wonder if I should have gone to step=1 and just doubled the speed? (Maybe the script should always be set for a step size of 1 only, and just use the speed control to get the desired effect...? I'll come back to that thought after further testing).
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|