ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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:
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.
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:
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.
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.