Sponsored Content
Top Forums Shell Programming and Scripting Detect USB keyboard and other peripherals Post 302331378 by pludi on Monday 6th of July 2009 03:40:06 AM
Old 07-06-2009
Depending on how current your Debian installation is you might have DBUS & HAL installed. There's a command-line tool for DBUS which you can instruct to listen for added devices: (example is a flash drive)
Code:
> dbus-monitor --system --profile 'interface=org.freedesktop.Hal.Manager, member=DeviceAdded'
sig     1246865406      537113  2       /org/freedesktop/DBus   org.freedesktop.DBus    NameAcquired
sig     1246865413      849690  6387    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865413      898142  6390    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865414      883198  6393    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865414      883255  6394    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865414      903331  6403    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865415      53744   6430    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded
sig     1246865415      97264   6449    /org/freedesktop/Hal/Manager    org.freedesktop.Hal.Manager     DeviceAdded

If you pipe this into a loop you should be able to detect just about any HW change.
 

9 More Discussions You Might Find Interesting

1. Programming

mont of peripherals

hello i'm working on redhat linux which is installed with windows on the same hard disk i would like to get access to windows files throw linux the question is: how to mount hard disk and peripherals ? think you (0 Replies)
Discussion started by: selim
0 Replies

2. UNIX for Dummies Questions & Answers

USB keyboard in Solaris

I have a USB keyboard/mouse combo hooked up to an x86 box and when it loads the mouse works fine, but the ctrl, shift, alt, and i think the function keys don't do anything. Is there a setting I need to change, or a way to manually configure them. There are no drivers, it is supposed to emulate a... (0 Replies)
Discussion started by: Winzernotman
0 Replies

3. UNIX for Dummies Questions & Answers

Can't detect usb thumbdrive anymore

hey everyone! i have a Solaris 8 box with me, and i had been using my usb thrumbdrive on it all the time. one day, i was in a rush and i pulled out the thumbdrive without ejecting it or anything. and now i can't detect any thumbdrives at all. i had tried using another thumbdrive, but with no... (2 Replies)
Discussion started by: feef
2 Replies

4. Programming

How to detect usb storage arrival and its mount path from C

Hi, I am a newbi to linux, i wana to write a program in C that can detect arrival of a usb flash memory. I want also to find the actual mount point of new inserted flash disk. can anyone help me? thanks a lot (6 Replies)
Discussion started by: aghashahi
6 Replies

5. Shell Programming and Scripting

BASH Script to Detect and List USB Flash Drives

Hello. This is my first post to this forum. I've read many of the posts over the last two or three years and I've learned a lot. I'm creating a live Linux distribution using the Linux Live Scripts -- just as a hobby project -- and I'm wanting to create an automated way for a user to copy the... (7 Replies)
Discussion started by: godzillarama
7 Replies

6. Linux

How to read keys from USB keyboard on AT91SAM9260

Hi Everyone, I am using 2.6.26.3-olimex kernel(Embedded system) running on AT91SAM9260. I am using a Logitech USB keyboard. It is detected as "/dev/input/event0". I don't know how to detect key press events and read the keys? Why can't I read the keys using scanf() like funtions? ... (7 Replies)
Discussion started by: siva4ever
7 Replies

7. Shell Programming and Scripting

script to detect a file from inserted usb and puts into a Variable

There is a same named log file that I have on my 2 different android phones. When I plug it into my computer, it appears in the media folder, For example the first android phone: /media/F6BA-0AF5/folder/A.log I want to put that into a variable to be manipulated.... (3 Replies)
Discussion started by: tobenguyen
3 Replies

8. OS X (Apple)

Detect active usb device used by app

I've searched a number of sites but thought I'd post it here. I'm want to a detect certain usb device (external camera) that is actively being used by an app on a mac. My search has led me through looking at the system events log to see if there is a ProductID indicator logged. The device is... (2 Replies)
Discussion started by: dallas88
2 Replies

9. HP-UX

Configure X windows with both keyboard and USB barcode reader

Greetings. Seeking guidance on adding a USB barcode reader (BCR) to an HP c3750 workstation with HP-UX 11.11 which is essentially configuring X windows to accept input from both a primary keyboard and a secondary keyboard that happens to be the BCR. Historically, I have successfully added a BCR... (2 Replies)
Discussion started by: mnkaltenbach
2 Replies
Net::DBus(3pm)						User Contributed Perl Documentation					    Net::DBus(3pm)

NAME
Net::DBus - Perl extension for the DBus message system SYNOPSIS
####### Attaching to the bus ########### use Net::DBus; # Find the most appropriate bus my $bus = Net::DBus->find; # ... or explicitly go for the session bus my $bus = Net::DBus->session; # .... or explicitly go for the system bus my $bus = Net::DBus->system ######## Accessing remote services ######### # Get a handle to the HAL service my $hal = $bus->get_service("org.freedesktop.Hal"); # Get the device manager my $manager = $hal->get_object("/org/freedesktop/Hal/Manager", "org.freedesktop.Hal.Manager"); # List devices foreach my $dev (@{$manager->GetAllDevices}) { print $dev, " "; } ######### Providing services ############## # Register a service known as 'org.example.Jukebox' my $service = $bus->export_service("org.example.Jukebox"); DESCRIPTION
Net::DBus provides a Perl API for the DBus message system. The DBus Perl interface is currently operating against the 0.32 development version of DBus, but should work with later versions too, providing the API changes have not been too drastic. Users of this package are either typically, service providers in which case the Net::DBus::Service and Net::DBus::Object modules are of most relevance, or are client consumers, in which case Net::DBus::RemoteService and Net::DBus::RemoteObject are of most relevance. METHODS
my $bus = Net::DBus->find(%params); Search for the most appropriate bus to connect to and return a connection to it. The heuristic used for the search is - If DBUS_STARTER_BUS_TYPE is set to 'session' attach to the session bus - Else If DBUS_STARTER_BUS_TYPE is set to 'system' attach to the system bus - Else If DBUS_SESSION_BUS_ADDRESS is set attach to the session bus - Else attach to the system bus The optional "params" hash can contain be used to specify connection options. The only support option at this time is "nomainloop" which prevents the bus from being automatically attached to the main Net::DBus::Reactor event loop. my $bus = Net::DBus->system(%params); Return a handle for the system message bus. Note that the system message bus is locked down by default, so unless appropriate access control rules are added in /etc/dbus/system.d/, an application may access services, but won't be able to export services. The optional "params" hash can contain be used to specify connection options. The only support option at this time is "nomainloop" which prevents the bus from being automatically attached to the main Net::DBus::Reactor event loop. my $bus = Net::DBus->session(%params); Return a handle for the session message bus. The optional "params" hash can contain be used to specify connection options. The only support option at this time is "nomainloop" which prevents the bus from being automatically attached to the main Net::DBus::Reactor event loop. my $bus = Net::DBus->test(%params); Returns a handle for a virtual bus for use in unit tests. This bus does not make any network connections, but rather has an in-memory message pipeline. Consult Net::DBus::Test::MockConnection for further details of how to use this special bus. my $bus = Net::DBus->new($address, %params); Return a connection to a specific message bus. The $address parameter must contain the address of the message bus to connect to. An example address for a session bus might look like "unix:abstract=/tmp/dbus-PBFyyuUiVb,guid=191e0a43c3efc222e0818be556d67500", while one for a system bus would look like "unix:/var/run/dbus/system_bus_socket". The optional "params" hash can contain be used to specify connection options. The only support option at this time is "nomainloop" which prevents the bus from being automatically attached to the main Net::DBus::Reactor event loop. my $connection = $bus->get_connection; Return a handle to the underlying, low level connection object associated with this bus. The returned object will be an instance of the Net::DBus::Binding::Bus class. This method is not intended for use by (most!) application developers, so if you don't understand what this is for, then you don't need to be calling it! my $service = $bus->get_service($name); Retrieves a handle for the remote service identified by the service name $name. The returned object will be an instance of the Net::DBus::RemoteService class. my $service = $bus->export_service($name); Registers a service with the bus, returning a handle to the service. The returned object is an instance of the Net::DBus::Service class. my $object = $bus->get_bus_object; Retrieves a handle to the bus object, "/org/freedesktop/DBus", provided by the service "org.freedesktop.DBus". The returned object is an instance of Net::DBus::RemoteObject my $name = $bus->get_unique_name; Retrieves the unique name of this client's connection to the bus. my $name = $bus->get_service_owner($service); Retrieves the unique name of the client on the bus owning the service named by the $service parameter. DATA TYPING METHODS
These methods are not usually used, since most services provide introspection data to inform clients of their data typing requirements. If introspection data is incomplete, however, it may be necessary for a client to mark values with specific data types. In such a case, the following methods can be used. They are not, however, exported by default so must be requested at import time by specifying 'use Net::DBus qw(:typing)' $typed_value = dbus_int16($value); Mark a value as being a signed, 16-bit integer. $typed_value = dbus_uint16($value); Mark a value as being an unsigned, 16-bit integer. $typed_value = dbus_int32($value); Mark a value as being a signed, 32-bit integer. $typed_value = dbus_uint32($value); Mark a value as being an unsigned, 32-bit integer. $typed_value = dbus_int64($value); Mark a value as being an unsigned, 64-bit integer. $typed_value = dbus_uint64($value); Mark a value as being an unsigned, 64-bit integer. $typed_value = dbus_double($value); Mark a value as being a double precision IEEE floating point. $typed_value = dbus_byte($value); Mark a value as being an unsigned, byte. $typed_value = dbus_string($value); Mark a value as being a UTF-8 string. This is not usually required since 'string' is the default data type for any Perl scalar value. $typed_value = dbus_signature($value); Mark a value as being a UTF-8 string, whose contents is a valid type signature $typed_value = dbus_object_path($value); Mark a value as being a UTF-8 string, whose contents is a valid object path. $typed_value = dbus_boolean($value); Mark a value as being an boolean $typed_value = dbus_array($value); Mark a value as being an array $typed_value = dbus_struct($value); Mark a value as being a structure $typed_value = dbus_dict($value); Mark a value as being a dictionary $typed_value = dbus_variant($value); Mark a value as being a variant SEE ALSO
Net::DBus, Net::DBus::RemoteService, Net::DBus::Service, Net::DBus::RemoteObject, Net::DBus::Object, Net::DBus::Exporter, Net::DBus::Dumper, Net::DBus::Reactor, "dbus-monitor(1)", "dbus-daemon-1(1)", "dbus-send(1)", <http://dbus.freedesktop.org>, AUTHOR
Daniel Berrange <dan@berrange.com> COPYRIGHT
Copyright 2004-2011 by Daniel Berrange perl v5.14.2 2011-06-30 Net::DBus(3pm)
All times are GMT -4. The time now is 09:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy