You are not logged in.

#1 2008-10-15 19:46:33

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

[openbox] Start a program when switching to a specific Workspace

Hi guys

I have a (hopefully) interesting question:

-in openbox-

how would i go about executing a specific application when i switch to, say workspace 4? Ahah, now, i could map the same hotkey to switching and to that program, aren't I thick... no wait, i usually switch with the arrow keys... now damn, that doesn't work anymore. maybe I can write a little script to execute when i switch workspaces and check which workspace i am on and then execute that other program (or not, according to what it found out)...

So. problem solved, eh? Not quite. how do i check which workspace i am on? is there some api to openbox or if not, as openbox is EWMH compliant there should be a way to find out, not?

cheers Barde

PS: in awesome this would be easier as it has these nice hooks and that neat lua config file... but there are no such things in openbox, are there?

Offline

#2 2008-10-15 20:18:20

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [openbox] Start a program when switching to a specific Workspace

Here's one way to do it:

#!/bin/sh
while true; do
  DESK=$(($(xprop -root | grep "_NET_CURRENT_DESKTOP(CARDINAL)" | egrep -o [[:digit:]]) + 1))
  [ $DESK == 4 ] && thunar && break
  sleep 1
done

This script only works once, but it should give you a general idea...

Offline

#3 2008-10-15 21:03:09

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: [openbox] Start a program when switching to a specific Workspace

you're the man! thx a whole bunch! (have a cookie cookie2.gif)

what do you mean by only works once

cheers Barde

Offline

#4 2008-10-15 21:12:21

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [openbox] Start a program when switching to a specific Workspace

Heller_Barde wrote:

what do you mean by only works once

The loop ends once the application is executed successfully.  So you'd need to restart the script in case you close this application afterwards...

Offline

#5 2008-10-15 21:22:53

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: [openbox] Start a program when switching to a specific Workspace

ah. i see. that is no problem at all. i will just map the script (without the while loop) to any (both) keybindings i use to switch desktops smile

thanks again
Barde

PS: I never told what i wanted to do with it: the plan is to have a dedicated programming workspace.
point is that I use the layout de_CH which has most of the keys relevant to programming at very dumb places. so i want that the keymap is automatically switched to en_US when i enter this workspace and back when i leave it again

Last edited by Heller_Barde (2008-10-15 21:23:35)

Offline

Board footer

Powered by FluxBB