small hackish bash script...

Forum rules
Before you post please read how to get help

small hackish bash script...

Postby Carl on Sat Sep 10, 2011 11:42 am

I'm trying to create a small script which is going to ask me whether or not I want to disable compiz before loading a game however so far I can get it to turn off compiz and not load the game (i'd like it to turn off compiz and then load the game..) or I can get it to not turn off compiz and then load the game :? bearing in mind I've basically hacked this together from bit's and bobs on Google and I have no real knowledge of bash or zenity :roll:

Code: Select all
#!/bin/bash

zenity --question --text "Would You like to disable Compiz before continuing?"
if [[ $? == 0 ]] ; then
   metacity --replace
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
else
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
fi
[AMD Sempron 145 2.8GHz + Unlocked 2nd Core|ATI Radeon™ HD3000 Graphics|4GB DDR3|Biostar A780L3L]
Image
User avatar
Carl
Level 5
Level 5
 
Posts: 667
Joined: Wed Apr 15, 2009 5:20 pm
Location: West Sussex, UK

Linux Mint is funded by ads and donations.
 

Re: small hackish bash script...

Postby xenopeek on Sat Sep 10, 2011 1:04 pm

Some small changes, this should work and re-enable Compiz after running the game.

Code: Select all
#!/bin/bash

zenity --question --text "Would You like to disable Compiz before continuing?"
if [[ $? == 0 ]] ; then
   metacity --replace &
   sleep 1
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
   compiz --replace &
else
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
fi
User avatar
xenopeek
Level 21
Level 21
 
Posts: 15448
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: small hackish bash script...

Postby Carl on Sat Sep 10, 2011 2:01 pm

Vincent Vermeulen wrote:Some small changes, this should work and re-enable Compiz after running the game.

Code: Select all
#!/bin/bash

zenity --question --text "Would You like to disable Compiz before continuing?"
if [[ $? == 0 ]] ; then
   metacity --replace &
   sleep 1
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
   compiz --replace &
else
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
fi


Error:
Code: Select all
./test: line 7: exec: SDL_VIDEO_X11_DGAMOUSE=0: not found


that partially works but only if I remove the "SDL_VIDEO_X11_DGAMOUSE=0" part from the script and also it doesn't re-enable compiz afterwards

Thanks for trying :D
[AMD Sempron 145 2.8GHz + Unlocked 2nd Core|ATI Radeon™ HD3000 Graphics|4GB DDR3|Biostar A780L3L]
Image
User avatar
Carl
Level 5
Level 5
 
Posts: 667
Joined: Wed Apr 15, 2009 5:20 pm
Location: West Sussex, UK

Re: small hackish bash script...

Postby Carl on Sat Sep 10, 2011 2:03 pm

But this works perfectly :D Thanks for your help! although it would be good to know why removing "exec" and using parentheses works instead :?:

Code: Select all
#!/bin/bash

zenity --question --text "Would You like to disable Compiz before continuing?"
if [[ $? == 0 ]] ; then
   metacity --replace &
   sleep 1
   (SDL_VIDEO_X11_DGAMOUSE=0 teeworlds)
   compiz --replace &
else
   exec SDL_VIDEO_X11_DGAMOUSE=0 teeworlds
fi
[AMD Sempron 145 2.8GHz + Unlocked 2nd Core|ATI Radeon™ HD3000 Graphics|4GB DDR3|Biostar A780L3L]
Image
User avatar
Carl
Level 5
Level 5
 
Posts: 667
Joined: Wed Apr 15, 2009 5:20 pm
Location: West Sussex, UK


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests