You are not logged in.

#1 2009-09-16 16:21:26

yphqyn
Member
Registered: 2009-04-23
Posts: 20

(XMonad) event to run script...

hii,

how can i run some script (in e.g. bash) when some window is focussed ?
example:

i run two window: in first i have urxvt, and in second i have firefox,
first window (urxvt) is focussed, and when i focussed firefox-window some script run.

regards yph

Offline

#2 2009-09-16 17:40:41

Lich
Member
Registered: 2009-09-13
Posts: 437

Re: (XMonad) event to run script...

yphqyn wrote:

hii,

how can i run some script (in e.g. bash) when some window is focussed ?
example:

i run two window: in first i have urxvt, and in second i have firefox,
first window (urxvt) is focussed, and when i focussed firefox-window some script run.

regards yph

Do you mean like a hook? to run somethign automatically when you focus a frame? Or are you just asking how to run stuff from xmonad? If it's the latter just make something like

---add this somewhere in xmonad.hs
myPROG = "script.sh"
---add this to your keys array
((modMask,               xK_p     ), spawn myPROG)

Archlinux | ratpoison + evilwm | urxvtc | tmux

Offline

#3 2009-09-16 19:14:55

yphqyn
Member
Registered: 2009-04-23
Posts: 20

Re: (XMonad) event to run script...

no, i mean run something when i focus a frame.
how can i do it ?

Offline

#4 2009-09-16 19:21:04

Lich
Member
Registered: 2009-09-13
Posts: 437

Re: (XMonad) event to run script...

yphqyn wrote:

no, i mean run something when i focus a frame.
how can i do it ?

I'm not sure you can do that...not unless you hack some source to get there anyway..
But wait..I think it's either your english or my poor listener abilities but..do you actually mean window or are you refering to virtual workspaces?
Because if you have an open window , Firefox won't open "in" that window, it would just open and get automatically tiled...so you would be left with 3 windows on the screen instead of 2...that's all.
Can you explain more please?


Archlinux | ratpoison + evilwm | urxvtc | tmux

Offline

#5 2009-09-16 19:27:11

yphqyn
Member
Registered: 2009-04-23
Posts: 20

Re: (XMonad) event to run script...

ok, i open terminal-program, and this program (instant message) generate event when i get a message - (on my dzen2 statusbar) show envelope, when i get a message in this terminal program.
and i whant kill this "envelope-dzen2" when i focussed this terminal-window.

sory for my en ;/

Last edited by yphqyn (2009-09-16 19:28:31)

Offline

#6 2009-09-16 20:00:50

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: (XMonad) event to run script...

what your describing sounds like an urgency hook. 

if i understand you correctly, you've already got some custom script that prints to your dzen bar when your chat program gets a message, yes?  and you'd like xmonad to kill this script when you focus that terminal, thus turning off your notification.

using some pretty standard xmonad-contrib stuff, xmonad can use urgency hooks to change the display of your workspaces in your status bar if a non visible workspace needs your attention (i.e. a terminal bell or message in an im client).  this notification is automatically disabled when you shift focus to the workspace that originally called you.  it sounds like a much cleaner solution to your situation.

this is all handled through XMonad.Hooks.DynamicLog and XMonad.Hooks.UrgencyHook (documentation is at xmonad.org).

to do /exactly/ as you describe (if i understand it) would require a custom event handler that sees the crossing event, checks to see that its /the/ terminal, then runs your notification-killing script. 

this is far above my head, though the friendly people on IRC in #xmonad would probably be able to help you out (or find a better way to do what you want).

/edit: typos.

Last edited by brisbin33 (2009-09-16 20:01:27)

Offline

#7 2009-09-16 20:15:14

yphqyn
Member
Registered: 2009-04-23
Posts: 20

Re: (XMonad) event to run script...

brisbin33 write:

if i understand you correctly, you've already got some custom script that prints to your dzen bar when your chat program gets a message, yes?  and you'd like xmonad to kill this script when you focus that terminal, thus turning off your notification.

yes, You right, thx smile

Offline

Board footer

Powered by FluxBB