Page 1 of 4 123 ... LastLast
Results 1 to 10 of 37

Thread: [SOLVED] Turning off Compiz for Games Script

  1. #1
    Join Date
    Oct 2007
    Location
    USA - Indiana
    Beans
    557
    Distro
    Ubuntu 10.10 Maverick Meerkat

    [SOLVED] Turning off Compiz for Games Script

    I'm looking to write a simple script for my friend. I want to have a shortcut open that script in the terminal and ask him... "What game would you like to play?". The script would then replace Compiz with Metacity.... run that game command... and then, once the game is closed... it will restart compiz and exit the terminal.

    Here is what I have written...

    Code:
    #!/bin/bash
    
    read -p "What game would you like to play?" GAME
    metacity --replace &
    $GAME
    compiz --replace
    exit
    I'm not at a linux computer... so I don't know if it will work. Does this seem right, or should something be changed?


    PS- I'm brand new to BASH scripting

  2. #2
    Join Date
    Nov 2007
    Location
    india
    Beans
    485
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Turning off Compiz for Games Script

    probably you would also like to run compiz in the background :
    Code:
    compiz --replace &

  3. #3
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Turning off Compiz for Games Script

    You may also need to disown the compiz process from the parent shell:

    Code:
    compiz --replace &
    disown
    Don't try to make something "fast" until you are able to quantify "slow".

  4. #4
    Join Date
    Oct 2007
    Beans
    145

    Re: Turning off Compiz for Games Script

    There is another option... Give compiz-icon or compiztray a look. You can either look for them in google or synaptic.

    They give you a quick simple icon in your tray that allows you to quickly switch between compiz and metacity.

  5. #5
    Join Date
    Oct 2007
    Location
    USA - Indiana
    Beans
    557
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Turning off Compiz for Games Script

    I already installed fusion-icon for him... I'm just trying to take a click or two away from the process, but thanks for the suggestion.

    I understand putting "&" after compiz --replace... so that it can actually exit after that command is run, but why might I need to disown? Just curious... I've never used that command.

  6. #6
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Turning off Compiz for Games Script

    Quote Originally Posted by anotherdisciple View Post
    I understand putting "&" after compiz --replace... so that it can actually exit after that command is run, but why might I need to disown? Just curious... I've never used that command.
    The best way to describe it is by example. Start a terminal and type:

    Code:
    gcalctool &
    exit
    Notice the gnome calculator dies when the shell dies. Now try:

    Code:
    gcalctool &
    disown
    exit
    The gnome calculator stays even after the terminal is closed. You can check the man page for bash to find out more information about disown.
    Don't try to make something "fast" until you are able to quantify "slow".

  7. #7
    Join Date
    Oct 2007
    Location
    USA - Indiana
    Beans
    557
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Turning off Compiz for Games Script

    hmmm that's strange... disown didn't work..

    Code:
    gcalctool &
    disown
    exit
    just exited the terminal and closed the calculator... is there something not typed correctly?

  8. #8
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Turning off Compiz for Games Script

    That's odd. Are you using bash as your shell? If I start a new terminal and type the two sets of statements above, it works as I'd expect.
    Don't try to make something "fast" until you are able to quantify "slow".

  9. #9
    Join Date
    Oct 2007
    Location
    USA - Indiana
    Beans
    557
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Turning off Compiz for Games Script

    Yes, I'm using BASH.... weird!? The second command keeps the terminal open just like before... it's like it ignores the exit command.

    It all works as I suspected... asks "What game do you want to play?" switches to metacity, opens the program.... switches back to compiz once the game is closed... if I close the terminal it doesn't change the compiz command since I put & after compiz, but it doesn't close the terminal for me... how can I do this?

  10. #10
    Join Date
    Oct 2007
    Location
    USA - Indiana
    Beans
    557
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Turning off Compiz for Games Script

    So... does anyone know how to make a BASH script close the terminal after it is finished? If I can figure that out I'll mark this thread as solved.

    So far I have had no luck. If you type exit in the terminal... it will close the terminal.... if it's in that bash script... it doesn't seem to do anything.... I tried killall gnome-terminal... that didn't work either.... back to the drawing board...

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •