Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have the following script

  while [ true ]
    do
      gnome-screensaver-command -l
      xinput set-int-prop 10 "Device Enabled" 8 0
      sleep 1m
      xinput set-int-prop 10 "Device Enabled" 8 1
      sleep 30m
  done

I want to run it on startup. I have really bad neck pain so doctor suggested me to go for a walk or do minor exercise every 30 minutes or so. I created this script which will lock me out and disable mouse for one minute. I also want to add keyboard disabling which will totally lock me out of my computer for a minute. It would be really amazing if there is any better option for this.

share|improve this question
add comment

2 Answers

Unless you've got a really good reason to make something new (some people do), I'd look at existing applications that do what you're asking.

Gnome used to have a Typing Break feature but that was six years ago and that's a lot of time when developers are hell-bent on ripping out all the useful features. It might still be there. (Pre-post-edit: Yeah, looks like this was nuked in 2010/11. Sigh.)

RSI is a long-standing issue so there are other applications that do what you want:

  • Workrave is probably the best option. More configuration than Typing Break and it allows you to do exactly what you're asking (it'll blank out the screen and disable input). It's also in the repos.
  • drwright is a port of Typing Break for Gnome 3 stuff but it should work in Unity too. You'll need to add a PPA (on the page) to install it but that's not a huge issue.
share|improve this answer
add comment

To add the keyboard to it, you can use a very similar method to what you already have.

Go to a terminal and type xinput. This will show you the id numbers for all your input devices. In my case, my keyboard appears as "AT Translated Set 2 keyboard", id=12; so in my case I would add the lines

xinput set-int-prop 12 "Device Enabled" 8 0

and

xinput set-int-prop 12 "Device Enabled" 8 1

into the respective places in the script. Just substitute "12" for whatever ID your keyboard appears as in xinput.

As for running the script on startup; you will need a first line saying #!/bin/bash.

Assuming it is called lockmeout.sh, copy it to your home directory (~) and then do chmod +x ~/lockmeout.sh. Then, open "Startup applications" (available by typing "startup" in the dash), and add an entry that points to that script. Now it should execute whenever you log in, and stay running in the background.

Hope this helps!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.