How can I determine touch screen device in a bash script? - linux

I am trying out the eGalax touch screen driver for my touch screen, as an alternative to the evdev/xinput_calibrator combination.
The calibration tool that comes with the eGalax driver, TKCal, takes the device to which the touch screen is connected as a command line argument.
Now I would like to start the calibration tool from a bash script. Is there some smart way to determine the device within the script, instead of hard coding "/dev/hidraw0" as in this example:
TKCal /dev/hidraw0 Cal
I presume that I can't rely on the touch screen landing on hidraw0 every time, can I? If I run my software on a different system, with a mouse and a keyboard and touch screen, I guess I have to handle that the devices can be conneted to different hdrawX devices. Please correct me if I am wrong.
Thank you very much!
/Fredrik Israelsson

Try looking at /sys/class/hidraw/hidraw*/device/uevent.

The guys developing the eGalax drive told be to try a much simpler solution:
Write a udev rule that will map the touch screen to a device name of my choice.

Related

How to reenter Linux process after closing putty

I'm new to Linux.Yesterday I wrote some Python codes,now I'm using Linux to execute my codes,it may take a few hours. As my Linux is not native,it's a remote server,I use putty to connect to it.
Now ,I want to close putty and go to sleep.But I don't know how to find my process again and reenter it after I wake up and start putty.And also,I wrote some code to print progress rate,next time when I find the process,can I see the print info again?
Run screen, start your programm and close the connection. After logging in again, use screen -r to resume your session.
Alternatively nohup will do the trick.
screen is the best built-in tool that's always available for that, although it gets a bit weird around keyboard shortcuts, some of which sometimes don't work the way you want exactly.
I've found tmux to be much better in terms of usability.
Alternatively. take a look at mosh, which is trying to replace ssh. It's a mobile shell tool from MIT that supports intermittent connectivity, lots of praise there.

Custom print on DNP DS620 cutting problems

Hi everyone i'm currently using a DNP DS620 on a raspberry pi and i'm doing some printing with the lpr commands like lpr -P printername -o landscape picturename
This gave me a picture of 4x6 inch (10x15cm)
So i'm able to order some prints with a command system (good yeah!) but i don't find any way to use the cutting option to have a double 2x6inch picture at the end.
I know that some Epson printers use the source=DocFeedCut command but it didn't work in my case.
So does everyone know the command for that or a way to do that?
So I contact someone from the driver's developer's team explaining my issue to him, this operation wasn't possible at that time on this device. They made some modifications to enable this kind of process on this new kind of printer, now it's possible.

get userinput from bash script (executed by cron or udev)

EDIT, the question might have not been totally clear, short version:
How to popup a dialog asking for user input if the script is running in the background and not in an active console?
/EDIT
When I run a bash script from udev or cron, it usually runs quietly somewhere in the background. Example could be plugging in an external harddrive runs rsync for data backup. So not every time I plug in the harddrive do I want to launch this action.
What is the most minimal way to fire up some user input dialog and ask yes or no? I could write some interface with PyQt but I want as little dependencies as possible, ideally cross window manager and maybe even without window manager.
Thanks!
EDIT 2: The lightweight (and hence as ugly as expected) version is xmessage, this would probably be the answer to the question, unless you have a better one:
xmessage "Do you want to run the backup script?" -buttons yes,no
http://linux.byexamples.com/archives/87/using-gui-dialog-box/
EDIT: So there's KDialog for kde, is there something really lightweight for X?
http://www.linux-magazine.com/Issues/2009/99/Zenity-and-KDialog
kdialog --title "Do you want to run the backup script?"
--yesno "Do you want to run the backup script?"
I'm currently leaning towards zenity, only trouble is it pulls in a whole array of gtk dependencies on kde, but is cross platform and works on windows. In essence, this is exaclty what I was looking for:
if zenity --question --text="Please press a button."; then
zenity --info --text="You pressed Yes\!"
else
zenity --error --text="You pressed No\!"
fi
But was hoping it would be a lot lighter on the resources / dependencies. Any alternative suggestions?
A simple approach would be for the automated script to simply email you, or perhaps alert with wall with instructions (containing the location of the real script).
Another approach would be for the automated script to touch a file in /var/lib and proceed if the file is still present after 5 minutes. This gives the user the option to stop the process (by removing the file), but maintains some automation.
This is not something you should have cron or udev handling in the first place. Write a userland daemon that listens for the appropriate D-Bus messages and performs the appropriate actions.
This should be post in linux or superuser or serverfault.
But, the number one google search on linux read user input links back here to StackOverflow:
https://www.google.com/search?q=linux+read+user+input&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=fflb
so I guess it's not too off base.
Again, the third or so google result for linux invoke command usb device plugin links to ServerFault:
https://serverfault.com/questions/399698/execute-a-command-when-a-device-is-connected-via-usb
I'll leave combining those two as an exercise.

practical app to do screenshots with voiceover on windows and/or linux

Does anyone knows what package(s) is suitable to do:
pressing PrintScr (or any other button) making screenshot and starts recording from mic
pressing PringScr again stops recording from mic
files are saved into some directory with timestamps to be latter renamed. Picture and audio file to have the same file name to simplify playback
Have you tried google?
http://en.wikipedia.org/wiki/Screenshot
Under Linux, you'd look at X11 capture.
Sound can be done through a number of applications. Something as simple as cat /dev/... > file might suffice, although using sox is a far better choice. (Sox includes play and rec command line utilities, as well as audio conversion and numerous other tools. It's commonly found already installed on Linux systems.)
Date stamping files is as easy as date in a simple tcsh or bash script.
The Printscreen button is close to impossible. Keyboard events are redirected to the currently active process (window). You might be able to trigger (intercept) something through your X11 window manager. Maybe. Otherwise you are looking at the kernel.
You could always hook up some other hardware, like a second mouse, and write software to listen for it. Or run a simple GUI application, or even command-line, at the border of your screen, and use ImageMagick utilities to trim that portion of your screen off.
Though a far easier solution is to run it on a second computer, networked to (ssh'ing into) the first. For example:
(Everything is done on computerB.)
(convert is part of ImageMagick.)
machineB % ssh machineA
machineA % echo $DISPLAY
localhost:10.0
machineA % setenv DISPLAY machineA:0
machineA % rm tmp.root.xwd
machineA % xwd -root > tmp.root.xwd
machineA % convert tmp.root.xwd image.`date +%Y.%m.%d_%H:%M:%S`.gif
Caveat: On machineA, on the actual machineA, you might need to type xhost +machineA first.

auto permissions on udev'd device files?

This is a dupe from SuperUser.com . Folks over there weren't smart enough or willing to help me out; maybe it's more a programmer question than an administrator one:
I have an app that reads input from 4 (four) mice that are plugged in via USB in addition to the built-in touchpad. This is no problem for Ubuntu 9.10: hald notices the new devices and udev's them brand new entries called /dev/input/mouse4 ... mouse7.
My app runs as a normal user app. The files in /dev belong to root and aren't readable to anyone else.
I don't have a problem doing chmod a+r mouse? once, but the devices come and go with every reboot and every time the dang rodents are plugged in or out.
Can someone please tell me a script or something to manipulate so my chmod happens automagically?
This information is easily discoverable, I just had to look at /etc/udev/rules.d/91-permissions.rules on a Debian configuration. :-)
Some interesting examples pasted from there:
# default permissions for block devices
SUBSYSTEM=="block", GROUP="disk"
Looks like there's this "GROUP" thing to determine the group owner...
And, you can chmod stuff apparently:
KERNEL=="pty*", MODE="0666", GROUP="tty"
Note the MODE part...
I'm sure RTFM-ing for the udev config file format will give you even more information. :-)

Resources