You are not logged in.

#1 2012-02-04 21:51:27

Hspasta
Member
Registered: 2011-12-24
Posts: 189
Website

[SOLVED]Catching Events

How do you catch certain events, both hardware and software?
For example I want to detect when my vga cable is unplugged or when mpd finishes playing a song.

I was playing around with handler.sh from acpid and I was hoping I could do the same for non-power related things.

Last edited by Hspasta (2012-02-06 03:17:07)

Offline

#2 2012-02-04 21:59:29

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [SOLVED]Catching Events

Does this do what you want?

udevadm monitor

Offline

#3 2012-02-04 22:44:52

Hspasta
Member
Registered: 2011-12-24
Posts: 189
Website

Re: [SOLVED]Catching Events

I'm not sure how I would use that.

I should have been more clear in my original post. I want to run a script when I plug in my VGA automatically.

Offline

#4 2012-02-04 23:18:28

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [SOLVED]Catching Events

Ah, I see. Do a search in {forums,wiki} for how to run a script on udev events. Within the last month, I can recall a few threads/posts about such things as:

  • switching power saving measures on when the power cord is unplugged, and turning power saving off when the cord is plugged in

  • switching to HDMI audio when the HDMI cable is plugged in, and reverting to the laptop speakers when the HDMI cable is unplugged

I trust you'll be able to suitably modify such information to suit your specific requirements ;-)

Last edited by /dev/zero (2012-02-04 23:19:01)

Offline

#5 2012-02-04 23:21:09

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]Catching Events

You can use 'watch' with some script that will query e.g. 'xrandr' to see if something's connected to VGA.
Some apps may have built-in features e.g. turn off the computer after it finishes playing the last song from the list.

Offline

#6 2012-02-06 03:16:57

Hspasta
Member
Registered: 2011-12-24
Posts: 189
Website

Re: [SOLVED]Catching Events

Thanks for all the input.

Offline

Board footer

Powered by FluxBB