View Full Version : Terminal command to switch window manager
AcidFX
August 18th, 2007, 05:55 PM
I am new to this forum and, well, Linux as well (using Ubuntu). I've got to say that this is a great project. Excellent work!!!
I hope this is alright for me to post here because I am using Beryl Manager and not Compiz Fusion, which, if I understand is a merge of Compiz and Beryl. All I would like to know is a command line for switching from Beryl to Metacity and vice versa. The reason being is when I start Counter Strike through wine using a script, I would like it to automaticallly switch to Metacity before the game starts, then when I close the game and steam, switches back to Beryl. I did some searching on the original beryl forum and google, but didn't turn anything up, but I am probably just searching for the wrong thing.
Any help would be greatly appreciated.
bluebyt
August 18th, 2007, 09:11 PM
Here you go!
metacity --replace
AcidFX
August 18th, 2007, 11:27 PM
Thanks for the info, but it only half worked for me. While under metacity, running "beryl --replace" switches to beryl, but while in beryl and running "metacity --replace" I get the following:
Window manager warning: "" found in configuration database is not a valid value for keybinding "toggle_shaded"
Window manager warning: Lost connection to the display ':0.0';
most likely the X server was shut down or you killed/destroyed
the window manager.
I played with it a little and found that merely typing in either "beryl" or "metacity" (still get the first part of the warning above though) would switch between them, but unfortunately, execution of the terminal is halted until I use ctrl+c, at which point the window manager is unloaded. When I type metacity and then ctrl+c to end, it doesn't really cause a problem because it seems to reload metacity immediately, but when I type beryl and then ctrl+c to end, it seems to unload all styles, so I don't even have a title bar to grab and move. Plus this method of doing this wouldn't really work at this point because the script needs to start the game afterwords and if execution in the terminal is halted, how would it get to the command to start counter strike? When you run it in a terminal does it halt like mine, or does it finish executing and bring up another $ prompt? Thanks.
lurkinator
August 19th, 2007, 12:15 AM
If you add an ampersand to the command (beryl --replace &), it will make the process independent of your terminal and you should be able to quit out of it without killing beryl (or metacity if that's what you started) too. You may not see your command prompt to enter more commands until you hit enter though.
double ampersands ( && ) between your game's run command and "beryl --replace" (in your script) should have the script wait for the game to exit before running beryl. however I realized today that my understanding of these damn ampersands is lacking.
I guess googling about that keybinding error is what I'd do... there's lots of hits (http://www.scroogle.org/cgi-bin/nbbw.cgi?Gw=%22not+a+valid+value+for+keybinding+to ggle_shaded%22), I don't know if any are relevant to your situation, here's a good starting point I think:As for the error with compiz, try opening up gconf-editor (by typing it in a terminal) and then searching for "toggle_shaded" including the first checkbox in the search window. There will be two results, click the first and note that in the top right box it's there too. Under "value" you won't find anything. That's wrong. Change it to "disabled" like the others.I really haven't a clue about that one though. good luck
AcidFX
August 19th, 2007, 02:53 AM
lurkinator, thanks for that snippet, it fixed the toggle_shaded warning I was getting. I am now having problems in the consistency that the command work within a script. I have tried various combinations using && and sleep on the script below.
metacity --replace &
cd '/home/AcidFX/.wine/drive_c/Program Files/Steam/'
WINEDEBUG=-all nice -10 wine Steam.exe -applaunch 240 -dxlevel90 -console
&&
beryl --replace &
The problem is that only sometimes it will switch from beryl to metacity, but when it does, it will never switch back to beryl or it will lose styles and title bar all together, and if that happens I have to manually select a window manager. Usually the first time it won't switch from beryl to metacity, it won't switch again unless I wait a few minutes. Running them manually in a terminal seems to work consistently, even when switching rapidly from one to the other.
I can't see it being some kind of permissions issue, because it works sometimes. Is it possible a log or buffer is getting filled up? If someone has a moment could you please try the above and see if the behavior you see matches mine? The command in between metacity and beryl shouldn't matter, it may even be ok to just put "sleep #" in place of my cd and wine commands.
rgdg
August 19th, 2007, 03:52 AM
Here is a script I use for google earth, I don't know anything about or use wine so try putting the wine stuff where I have google earth. Use beryl instead of compiz, etc.
Then I chmod +x scriptname and link a launcher to it - works like a charm
#!/bin/bash
#Script Compiz/on/off
# Compiz off;
killall avant-window-navigator &&
killall compiz.real &
metacity --replace &
#run game;
/home/rob/GoogleEarth//googleearth %f;
#Compiz on;
avant-window-navigator &
compiz --replace &
AcidFX
August 19th, 2007, 08:23 AM
Perfect!!! Thank you. Here is my final code (which is almost identical to rgdg's code) in case anyone is interested.
# beryl off;
killall beryl-manager &&
killall beryl
metacity --replace &
#run game;
cd '/home/bmeine/.wine/drive_c/Program Files/Steam/'
WINEDEBUG=-all nice -10 wine Steam.exe -applaunch 240 -dxlevel90 -console
#beryl on;
beryl-manager &
Because beryl is the window manager when I kill beryl-manager, when beryl-manager is started back up it uses the last window manager so no need to run "beryl --replace &", in my case anyway. One odd thing though, when I am prompted for how I want to run the script (run in terminal or run), if I select run in terminal, for some reason it can't start beryl-manager at the end. Selecting run works fine. But if I open a terminal and run my script from the command line, everything works. Just thought it was kind of odd.
Anyway, thanks to each of you for the help.
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.