LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-02-2008, 11:24 PM   #1
shan_nathan
Member
 
Registered: Jun 2007
Location: India
Distribution: Redhat
Posts: 137

Rep: Reputation: 15
Virtual Desktop Switcher


Dear all,

I am using suse linux 10.1. One of my system was used to for NMS monitoring In NMS In my Linux Box we are running the application in "2" of virtual desktops. and we need to change the desktops manually. Is there any script to change the vir.Desktop's automatically every 2 minutes.

Thanks in advance
Shan
 
Old 01-02-2008, 11:40 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
I think man chvt is what you want.
 
Old 01-04-2008, 11:32 PM   #3
shan_nathan
Member
 
Registered: Jun 2007
Location: India
Distribution: Redhat
Posts: 137

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Uncle_Theodore View Post
I think man chvt is what you want.
Hi,

I could not find anything on " chvt "
Because i am using KDE and i am using two desktop's "multiple desktop" option and i want to switch over between that two Desktop only.


Shan
 
Old 01-05-2008, 11:54 AM   #4
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
chvt is for switching between virtual terminals, and has nothing to do with desktops.

Virtual desktops are not a feature of X, and implemented by the window managers. As such, there is no way a separate program can ask that the desktops be changed without going thru the window manager. By going thru the window manager, your script would be tied to that specific window manager. I have no idea how the KDE window manager works, or if it will allow external programs to request desktop changes. Your best bet to finding a answer is to look thru the KDE's window manager documentation, especially the parts relating to any installed programs to see if one of them can "talk" to the running window manager and request such a change.
 
Old 01-05-2008, 01:50 PM   #5
jozyba
Member
 
Registered: Sep 2007
Distribution: Debian Etch, Lenny, Lenny/Sid
Posts: 31

Rep: Reputation: 15
Suse has a utility called wmctrl that will work with KDE. So for instance if you wanted to automatically toggle between desktop 1 and desktop 4 every 120 seconds you could run this script in the background:
Code:
#!/bin/bash

VIEW_1=0    #First desktop
VIEW_2=3    #Fourth desktop

while true; do
    CURRENT_DESKTOP=$(wmctrl -d | awk '/\*/{print $1}')
    case $CURRENT_DESKTOP in
         $VIEW_1)    wmctrl -s $VIEW_2; sleep 120 ;;
         $VIEW_2)    wmctrl -s $VIEW_1; sleep 120 ;;
               *)    wmctrl -s $VIEW_1; sleep 120 ;;
    esac
done

Last edited by jozyba; 01-05-2008 at 02:26 PM.
 
Old 01-05-2008, 02:44 PM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
If you can't find the original sources for wmctrl, you can get them here:

http://distro.ibiblio.org/pub/linux/...l/wmctrl-1.07/

It has other interesting features as well.
 
Old 01-06-2008, 12:55 AM   #7
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
I am wondering whether devil's pie couldn't be used for this.
http://burtonini.com/blog/computers/devilspie
 
Old 01-06-2008, 01:32 AM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I think devils pie won't work for this job. It appears to work with individual windows. wmctrl is the only one I know of that will let you switch virtual desktops from the command line, though I suspect that some other desktop switchers may be able to do so.
The OP doesn't state which window manager he is using so it's hard to tell. But there are switchers which will work with various window managers which might do the job, like the ones that are made for fluxbox, blackbox, or aewm. Still, wmctrl is probably the easoest and most versatile way to go.
 
Old 01-09-2008, 07:09 AM   #9
shan_nathan
Member
 
Registered: Jun 2007
Location: India
Distribution: Redhat
Posts: 137

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jozyba View Post
Suse has a utility called wmctrl that will work with KDE. So for instance if you wanted to automatically toggle between desktop 1 and desktop 4 every 120 seconds you could run this script in the background:
Code:
#!/bin/bash

VIEW_1=0    #First desktop
VIEW_2=3    #Fourth desktop

while true; do
    CURRENT_DESKTOP=$(wmctrl -d | awk '/\*/{print $1}')
    case $CURRENT_DESKTOP in
         $VIEW_1)    wmctrl -s $VIEW_2; sleep 120 ;;
         $VIEW_2)    wmctrl -s $VIEW_1; sleep 120 ;;
               *)    wmctrl -s $VIEW_1; sleep 120 ;;
    esac
done
Hi,
It's working Great. Thanks . Can you tell me this thing. Right now if i ran that script then i want to work in that machine means first i have to stop that process the i have to restart that process. There is any way to modify that script like this way , If a user interact means, script has to wait then after that there is no interaction for sometime means again that process should continue. Is there any possiblity for that.

Thanks in advance
Shan
 
Old 01-09-2008, 05:31 PM   #10
jozyba
Member
 
Registered: Sep 2007
Distribution: Debian Etch, Lenny, Lenny/Sid
Posts: 31

Rep: Reputation: 15
The simplest way would be to adjust the script like this:
Code:
#!/bin/bash

VIEW_1=0    #First desktop
VIEW_2=3    #Fourth desktop

CURRENT_DESKTOP=$VIEW_2

while true; do
    case $CURRENT_DESKTOP in
         $VIEW_1)    wmctrl -s $VIEW_2; sleep 120 ;;
         $VIEW_2)    wmctrl -s $VIEW_1; sleep 120 ;;
               *)                       sleep 120 ;;
    esac
    CURRENT_DESKTOP=$(wmctrl -d | awk '/\*/{print $1}')
done
Now the script will toggle between the two views every 120 seconds, but if you manually switch to a different desktop the script will sleep until you finish your work and manually switch back to one of the two "view" desktops; then it will resume.

The problem with this is that if you happen to want to pause the script on one of the two "view" desktops the script will ignore you and just carry on toggling. I'll leave that problem for you to solve...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VMware and Gnome Desktop Switcher hosler Linux - Software 4 09-19-2007 01:11 PM
Gnome Desktop Switcher in KDE - is it possible? Nalorin Linux - Newbie 9 03-15-2005 10:16 PM
Stupid desktop switcher! itsjustme Red Hat 1 11-14-2003 04:06 PM
desktop switcher Morph Red Hat 4 09-10-2003 05:19 PM
Desktop Switcher and Afterstep Install concoran Linux - General 1 04-08-2002 11:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration