Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: No sound on second XServer

  1. #11
    Join Date
    Feb 2007
    Location
    perdita
    Beans
    1,625
    Distro
    Ubuntu

    Re: No sound on second XServer

    Fix posted:
    http://code.google.com/p/xgamer/issues/detail?id=2

    (adding ck-launch-session through preferences did not work)

    P.S.: Why don't you update your thread to let more people know about the new xgamer?

    Amarok is now the only sound problem left for me. Had to switch to rhytmbox.
    Last edited by KIAaze; March 24th, 2010 at 10:45 AM.

  2. #12
    Join Date
    Jun 2006
    Beans
    471

    Re: No sound on second XServer

    AS you can see it needs testing. Up till now I've had no takers. I'll make the changes you highlighted.

  3. #13
    Join Date
    May 2010
    Beans
    2

    Lightbulb Re: No sound on second XServer

    Here is little edited xgame script.

    I have added to it ck-launch-session and sound is ok.
    Tested with OpenArena on Ubuntu 10.04 64bit


    Code:
    #!/usr/bin/perl -w
    # Script to run games on a separate X session
    
    # Here we dump the script in a huge while loop to keep it running
    while (!$quit){
    &list;
    
    # Here we look at the given script parameters    
    if ($ARGV[0]){
        $switch = $ARGV[0];
    } else {
        $switch = "-";
    }
    
    if ($switch =~/-[nN]/){
        if (!$ARGV[1] || $ARGV[1] !~/^\d+$/ || $ARGV[1] > @list || $ARGV[1] < 1){
            print ("Invalid number, terminating...\n");
        } else {
            $cmdoption = 1 if $ARGV[2] && $ARGV[2]=~/-c/;
            chomp ($input = $ARGV[1]);
            &checkbin;
        }
        $quit = 1;
    } elsif ($switch =~/--help/){
        &help;
        $quit = 1;
    } elsif ($switch =~/--add/){
        &gamelist;
        &addition;
        &gamelist;
        $quit = 1;
    } elsif ($switch =~/--del/){
        if (@list < 1) {
            print("No games to delete!\n");
        } else {
            &gamelist;
            &delete;
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/--edit/){
        if (@list < 1){
            print("No games to edit!\n");
        } else {
            &gamelist;
            &edit;
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/--prefs/){
            &preferences;
            $quit = 1;
    } elsif ($switch =~/--list/){
        if (@list < 1){
            print("No games to list!\n");
        } else {
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/--move/){
        if (@list < 2){
            print("Not enough games to move!\n");
        } else {
            &gamelist;
            &move;
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/-d/){
        ($input = (split/\t/,$options[3])[1]) =~s/\n//;
        if ($input !~/^\d+$/ || $input > @list || $input < 1){
            print ("Invalid default game, terminating...\n");
        } else {
            if ($ARGV[1] && $ARGV[1]=~/-c/){
                $cmdoption = 1;
                splice @ARGV, 1, 0, "";
            }
            &checkbin;
        }
        $quit = 1;
    } else {
        &gamelist;
        &options;
        &input;
    }
    }
    
    # Writing out the list when Xgame stops
    write_out($gamelist, @list, @options);
    
    # Here come the subroutines
    sub input {
        while(!$valid) {
            print ("Please choose your desired game or option: ");
            chomp ($input = <stdin>);
            $input = lc($input);
            $valid = 1;
            if ($input =~ /^\D$/){
                if ($input eq "a"){
                    undef $valid;
                    &addition;
                    &gamelist;
                    &options;
                } elsif ($input eq "p"){
                    undef $valid;
                    &preferences;
                    &gamelist;
                    &options;
                } elsif ($input eq "d" && @list > 0){
                    undef $valid;
                    &delete;
                    &gamelist;
                    &options;
                } elsif ($input eq "e" && @list > 0){
                    undef $valid;
                    &edit;
                    &gamelist;
                    &options;
                } elsif ($input eq "m" && @list > 1){
                    undef $valid;
                    &move;
                    &gamelist;
                    &options;
                } elsif ($input eq "q"){
                    print ("Goodbye!\n");
                    $quit = 1;
                } else {
                    undef $valid;
                    print ("Option not available!\n");
                }
            } else {
                if ($input !~/^\d+$/ || $input > @list || $input < 1){
                    undef $valid;
                    print ("Invalid number/option!\n");
                } else {
                    &checkbin;
                }
            }
        }
    }
    
    sub list {
        # Checking if the gamelist exists
        $gamelist = "$ENV{HOME}/.xgamelist";
        write_out($gamelist, "") if !-f "$gamelist";
            
        # Here we grab the list of games
        @list = grep {!/^\s*$/} cat($gamelist);
        if (grep (/\[options\]/, @list)){
            for (0 .. 3){
                unshift @options, (pop @list);
            }
        } else {
            @options = ("[options]\t\n", "xconfig\t\n", "xinitops\t\n", "default\t\n");
        }
    }
    
    sub gamelist {
        system "clear";
        # Here we process that gamelist then display it
        print "\t-=<Your Games>=-\n\n";
        $number = 1;
        foreach (@list){
            /(.*?)\t/;
            print "[" . $number++ . "]\t$1\n";
        }
        print "\n";
    }
    
    sub checkbin {
        # And this is where we process the choice
        @choice = split/\t/,$list[--$input];
    
        # Here we make sure the exe is correct and fire up if so
        @exe = split/\s+/,$choice[1];
        chomp $exe[0];
        if ($exe[0] =~/\//){
            chomp ($executable = qx|echo $exe[0]|);
            if (-f "$executable"){
                &startgame;
            } else {
                undef $valid; 
                die ("Invalid executable!\n");
            }
        } elsif (qx|which $exe[0] 2>&1| =~/which\: no $exe[0] in/){
            undef $valid;
            die ("Invalid executable!\n");
        } else {
            &startgame;
        }
    }
    
    sub startgame {
        print ("Starting $choice[0]...\n");
    
        # Checking for another instance of xgame
        chomp ($xinit = (qx|ls ~/.xinitrc.* 2>&1|)[0]);
        $xinit = "$ENV{HOME}/.xinitrc" if $xinit !~ /\.xinitrc\.\w{6,6}/;
    
        # Backing up existing .xinitrc to random temp file
        chomp ($tmpxinit = qx|mktemp ~/.xinitrc.XXXXXXX|);
        if (-f $xinit){
            write_out($tmpxinit, cat($xinit));
        } else {
            write_out($tmpxinit, "");
        }
        # Creating new .xinitrc from input and defined options
        if ($cmdoption){
            undef $cmdoption;
            for (0, 0, 0){
                splice @ARGV, $_, 1;
            }
            $choice[1] =~s/^(.*)$/$1 @ARGV/;
        }
        chomp ($choice = $choice[1]);
        
        # The new .xinitrc get's written
        ($xinitopts = (split/\t/,$options[2])[1]) =~s/\n//;
        write_out("$ENV{HOME}/.xinitrc", "$xinitopts\n", "exec ck-launch-session $choice");
    
        # Now we fire up the X server with the specified game
        if ((qx|ls /tmp/.X*lock 2>&1|)[-1] =~ /(\d+)/){
            ($xnumber = $1)++;
        } else {
            $xnumber = 0;
        }
        ($xconfig = (split/\t/,$options[1])[1]) =~s/\n//;
        $xconfig =~s/(.*)/-xf86config $1/ if $xconfig ne "";
        
        system "startx -- :$xnumber $xconfig";
    
        # Placing the backup back to where it belongs
        unlink $xinit;
        if (cat($tmpxinit) ne ""){
            rename ($tmpxinit, "$ENV{HOME}/.xinitrc") or die "Error moving file: $!\n";
        } else {
            unlink $tmpxinit;
        }
        $quit = 1;
    }
    
    sub help {
        print ("Usage: xgame [OPTION] <enter> or: xgame <enter>\n");
        print ("Options:\n\t-d,\t\t use the specified default game\n");
        print ("\t-n,\t\t instantly run the choosen game (-n <number>)\n");
        print ("\t-n/-d <> -c <>,\t run the chosen/default game with commandline arguments (-c <commandline args>)\n");
        print ("\t--add,\t\t add a game to the gamelist\n");
        print ("\t--del,\t\t delete a game from the gamelist\n");
        print ("\t--edit,\t\t edit a game on the gamelist\n");
        print ("\t--move,\t\t move a game on the gamelist\n");
        print ("\t--list,\t\t display the gamelist\n");
        print ("\t--prefs,\t change the preferences\n");
        print ("\t--help,\t\t this message\n");
        print ("Gamelist specific:\n");
        print ("\tThe gamelist is located at ~/.xgamelist.\n");
        print ("\tIt must be edited and maitained at all times through Xgame.\n");
        print ("\tNot doing this could result in failure!\n");
    }
    
    sub options {
        print "\t-=<Options>=-\n\n[A]\tAdd a game to the gamelist\n";
        print "[D]\tDelete a game from the gamelist\n[E]\tEdit a game on the gamelist\n" if @list > "0";
        print "[M]\tMove a game on the gamelist\n" if @list > "1";
        print "[P]\tXgame Preferences\n[Q]\tQuit\n\n";
    }
    
    sub preferences {
        while(!$pref_done){
            ($xconfig = (split/\t/,$options[1])[1]) =~s/\n//;
            ($xinitopts = (split/\t/,$options[2])[1]) =~s/\n//;
            ($input = (split/\t/,$options[3])[1]) =~s/\n//;
            system "clear";
            print "\t-=<Preferences>=-\n\n";
            print "[1]\tX server config file is \"$xconfig\"\n";
            print "[2]\tExtra startcommand on game launch \"$xinitopts\"\n";
            print "[3]\tDefault game specified by it's number \"$input\"\n";
            print "[S]\tSort the gamelist alphabetically\n";
            print "[Q]\tExit these preferences\n\n";
            print "Please choose your desired preference: ";
            chomp ($pref_input = <stdin>);
            $pref_input = lc($pref_input);
            $pref_done = 1;
            if ($pref_input =~ /(1)/ || $pref_input =~ /(2)/ || $pref_input =~ /(3)/){
                @_ = ("", "Please give the new X config file \(example: xorg.conf\) or hit <enter> to leave empty: ", "Please specify the extra startcommand on game launch or hit <enter> to leave empty: ", "Please specify the default game or hit <enter> to leave empty: ");
                print $_[$1];
                chomp ($newpref = <stdin>);
                $options[$1] =~s/(.*?\t).*/$1$newpref/;
                undef $pref_done;
            } elsif ($pref_input eq "s"){
                @list = sort {uc($a) cmp uc($b)} @list;
                undef $pref_done;
            } elsif ($pref_input ne "q"){
                undef $pref_done;
            }
        }
        undef $pref_done;
    }
    
    sub addition {
        # this is where we add games to the list
        print ("Please give the name of the game you'd like to add: ");
        chomp ($game = <stdin>);
        print ("Please give the command related to the game: ");
        chomp ($bin = <stdin>);
        
        # here the game get's added
        push (@list, "$game\t$bin\n");
    }
    
    sub delete {
        # Here we check which game the user wants deleted
        print "Please choose the game you'd like to delete: ";
        chomp ($del = <stdin>);
        while ($del !~/^\d+$/ || $del > @list || $del < 1){
            print "Invalid number, please choose again: ";
            chomp ($del = <stdin>);
        }
        
        # Here we create a new list without the choosen game
        splice @list, --$del, 1;
    }
    
    sub move {
        # First we ask which game has to be moved
        print "Please choose the game you'd like to move: ";
        chomp ($move = <stdin>);
        while ($move !~/^\d+$/ || $move > @list || $move < 1){
            print "Invalid number, please choose again: ";
            chomp ($move = <stdin>);
        }
        
        # Then we ask the destination for the game
        print "Please choose the destination: ";
        chomp ($destin = <stdin>);
        while ($destin !~/^\d+$/ || $destin > @list || $destin < 1){
            print "Invalid number, please choose again: ";
            chomp ($destin = <stdin>);
        }
        
        #Here we write the new gamelist
        $moving = $list[--$move];
        splice @list, $move, 1;
        splice @list, --$destin, 0, $moving;
    }
    
    sub edit {
        # First we ask which game has to be edited
        print "Please choose the game you'd like to edit: ";
        chomp ($edit = <stdin>);
        while ($edit !~/^\d+$/ || $edit > @list || $edit < 1){
            print "Invalid number, please choose again: ";
            chomp ($edit = <stdin>);
        }
        @display = split/\t/,$list[--$edit];
        chomp $display[1];
        print "You choose to edit: \"$display[0]\" with command: \"$display[1]\"\n";
        
        # Here we grab the name to be used
        print "Please give the new name or hit enter to use the existing one: ";
        $name = <stdin>;
        $name = $display[0] if $name eq "\n";
        chomp $name;
        
        # Here we grab the command to be used
        print "Please give the new command or hit enter to use the existing one: ";
        $command = <stdin>;
        $command = $display[1] if $command eq "\n";
        chomp $command;
        
        # Now onto changing the entry in the gamelist
        $list[$edit] = "$name\t$command\n";
    }
    
    sub cat {
        open MYFILE, $_[0] or die "$!";
        @_ = <MYFILE>; 
        close MYFILE; 
        return (wantarray) ? @_ : join("",  @_);
    }
    
    sub write_out {
        $_ = shift @_;
        open WRITE, ">", $_ or die "Error writing '$_': $!\n";
        print WRITE @_;
        close WRITE;
    }
    How to use it:

    1. Code:
      sudo gedit
    2. copy script to the gedit
    3. save them: "/usr/bin/xgame", close gedit
    4. Code:
      sudo chmod +x /usr/bin/xgame
    5. use script:
      Code:
      xgame

    Minimalize and restore:
    CTRL+ALT+F7 - for minimalization
    CTRL+ALT+F8 - for restore of game

    WARNING: CLOSE GAME FIRST, NOT TERMINAL
    Last edited by Miro1701; June 6th, 2010 at 04:48 PM.

  4. #14
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    3
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: No sound on second XServer

    Quote Originally Posted by Miro1701 View Post
    Here is little edited xgame script.

    I have added to it ck-launch-session and sound is ok.
    Tested with OpenArena on Ubuntu 10.04 64bit


    Code:
    #!/usr/bin/perl -w
    # Script to run games on a separate X session
    
    # Here we dump the script in a huge while loop to keep it running
    while (!$quit){
    &list;
    
    # Here we look at the given script parameters    
    if ($ARGV[0]){
        $switch = $ARGV[0];
    } else {
        $switch = "-";
    }
    
    if ($switch =~/-[nN]/){
        if (!$ARGV[1] || $ARGV[1] !~/^\d+$/ || $ARGV[1] > @list || $ARGV[1] < 1){
            print ("Invalid number, terminating...\n");
        } else {
            $cmdoption = 1 if $ARGV[2] && $ARGV[2]=~/-c/;
            chomp ($input = $ARGV[1]);
            &checkbin;
        }
        $quit = 1;
    } elsif ($switch =~/--help/){
        &help;
        $quit = 1;
    } elsif ($switch =~/--add/){
        &gamelist;
        &addition;
        &gamelist;
        $quit = 1;
    } elsif ($switch =~/--del/){
        if (@list < 1) {
            print("No games to delete!\n");
        } else {
            &gamelist;
            &delete;
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/--edit/){
        if (@list < 1){
            print("No games to edit!\n");
        } else {
            &gamelist;
            &edit;
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/--prefs/){
            &preferences;
            $quit = 1;
    } elsif ($switch =~/--list/){
        if (@list < 1){
            print("No games to list!\n");
        } else {
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/--move/){
        if (@list < 2){
            print("Not enough games to move!\n");
        } else {
            &gamelist;
            &move;
            &gamelist;
        }
        $quit = 1;
    } elsif ($switch =~/-d/){
        ($input = (split/\t/,$options[3])[1]) =~s/\n//;
        if ($input !~/^\d+$/ || $input > @list || $input < 1){
            print ("Invalid default game, terminating...\n");
        } else {
            if ($ARGV[1] && $ARGV[1]=~/-c/){
                $cmdoption = 1;
                splice @ARGV, 1, 0, "";
            }
            &checkbin;
        }
        $quit = 1;
    } else {
        &gamelist;
        &options;
        &input;
    }
    }
    
    # Writing out the list when Xgame stops
    write_out($gamelist, @list, @options);
    
    # Here come the subroutines
    sub input {
        while(!$valid) {
            print ("Please choose your desired game or option: ");
            chomp ($input = <stdin>);
            $input = lc($input);
            $valid = 1;
            if ($input =~ /^\D$/){
                if ($input eq "a"){
                    undef $valid;
                    &addition;
                    &gamelist;
                    &options;
                } elsif ($input eq "p"){
                    undef $valid;
                    &preferences;
                    &gamelist;
                    &options;
                } elsif ($input eq "d" && @list > 0){
                    undef $valid;
                    &delete;
                    &gamelist;
                    &options;
                } elsif ($input eq "e" && @list > 0){
                    undef $valid;
                    &edit;
                    &gamelist;
                    &options;
                } elsif ($input eq "m" && @list > 1){
                    undef $valid;
                    &move;
                    &gamelist;
                    &options;
                } elsif ($input eq "q"){
                    print ("Goodbye!\n");
                    $quit = 1;
                } else {
                    undef $valid;
                    print ("Option not available!\n");
                }
            } else {
                if ($input !~/^\d+$/ || $input > @list || $input < 1){
                    undef $valid;
                    print ("Invalid number/option!\n");
                } else {
                    &checkbin;
                }
            }
        }
    }
    
    sub list {
        # Checking if the gamelist exists
        $gamelist = "$ENV{HOME}/.xgamelist";
        write_out($gamelist, "") if !-f "$gamelist";
            
        # Here we grab the list of games
        @list = grep {!/^\s*$/} cat($gamelist);
        if (grep (/\[options\]/, @list)){
            for (0 .. 3){
                unshift @options, (pop @list);
            }
        } else {
            @options = ("[options]\t\n", "xconfig\t\n", "xinitops\t\n", "default\t\n");
        }
    }
    
    sub gamelist {
        system "clear";
        # Here we process that gamelist then display it
        print "\t-=<Your Games>=-\n\n";
        $number = 1;
        foreach (@list){
            /(.*?)\t/;
            print "[" . $number++ . "]\t$1\n";
        }
        print "\n";
    }
    
    sub checkbin {
        # And this is where we process the choice
        @choice = split/\t/,$list[--$input];
    
        # Here we make sure the exe is correct and fire up if so
        @exe = split/\s+/,$choice[1];
        chomp $exe[0];
        if ($exe[0] =~/\//){
            chomp ($executable = qx|echo $exe[0]|);
            if (-f "$executable"){
                &startgame;
            } else {
                undef $valid; 
                die ("Invalid executable!\n");
            }
        } elsif (qx|which $exe[0] 2>&1| =~/which\: no $exe[0] in/){
            undef $valid;
            die ("Invalid executable!\n");
        } else {
            &startgame;
        }
    }
    
    sub startgame {
        print ("Starting $choice[0]...\n");
    
        # Checking for another instance of xgame
        chomp ($xinit = (qx|ls ~/.xinitrc.* 2>&1|)[0]);
        $xinit = "$ENV{HOME}/.xinitrc" if $xinit !~ /\.xinitrc\.\w{6,6}/;
    
        # Backing up existing .xinitrc to random temp file
        chomp ($tmpxinit = qx|mktemp ~/.xinitrc.XXXXXXX|);
        if (-f $xinit){
            write_out($tmpxinit, cat($xinit));
        } else {
            write_out($tmpxinit, "");
        }
        # Creating new .xinitrc from input and defined options
        if ($cmdoption){
            undef $cmdoption;
            for (0, 0, 0){
                splice @ARGV, $_, 1;
            }
            $choice[1] =~s/^(.*)$/$1 @ARGV/;
        }
        chomp ($choice = $choice[1]);
        
        # The new .xinitrc get's written
        ($xinitopts = (split/\t/,$options[2])[1]) =~s/\n//;
        write_out("$ENV{HOME}/.xinitrc", "$xinitopts\n", "exec ck-launch-session $choice");
    
        # Now we fire up the X server with the specified game
        if ((qx|ls /tmp/.X*lock 2>&1|)[-1] =~ /(\d+)/){
            ($xnumber = $1)++;
        } else {
            $xnumber = 0;
        }
        ($xconfig = (split/\t/,$options[1])[1]) =~s/\n//;
        $xconfig =~s/(.*)/-xf86config $1/ if $xconfig ne "";
        
        system "startx -- :$xnumber $xconfig";
    
        # Placing the backup back to where it belongs
        unlink $xinit;
        if (cat($tmpxinit) ne ""){
            rename ($tmpxinit, "$ENV{HOME}/.xinitrc") or die "Error moving file: $!\n";
        } else {
            unlink $tmpxinit;
        }
        $quit = 1;
    }
    
    sub help {
        print ("Usage: xgame [OPTION] <enter> or: xgame <enter>\n");
        print ("Options:\n\t-d,\t\t use the specified default game\n");
        print ("\t-n,\t\t instantly run the choosen game (-n <number>)\n");
        print ("\t-n/-d <> -c <>,\t run the chosen/default game with commandline arguments (-c <commandline args>)\n");
        print ("\t--add,\t\t add a game to the gamelist\n");
        print ("\t--del,\t\t delete a game from the gamelist\n");
        print ("\t--edit,\t\t edit a game on the gamelist\n");
        print ("\t--move,\t\t move a game on the gamelist\n");
        print ("\t--list,\t\t display the gamelist\n");
        print ("\t--prefs,\t change the preferences\n");
        print ("\t--help,\t\t this message\n");
        print ("Gamelist specific:\n");
        print ("\tThe gamelist is located at ~/.xgamelist.\n");
        print ("\tIt must be edited and maitained at all times through Xgame.\n");
        print ("\tNot doing this could result in failure!\n");
    }
    
    sub options {
        print "\t-=<Options>=-\n\n[A]\tAdd a game to the gamelist\n";
        print "[D]\tDelete a game from the gamelist\n[E]\tEdit a game on the gamelist\n" if @list > "0";
        print "[M]\tMove a game on the gamelist\n" if @list > "1";
        print "[P]\tXgame Preferences\n[Q]\tQuit\n\n";
    }
    
    sub preferences {
        while(!$pref_done){
            ($xconfig = (split/\t/,$options[1])[1]) =~s/\n//;
            ($xinitopts = (split/\t/,$options[2])[1]) =~s/\n//;
            ($input = (split/\t/,$options[3])[1]) =~s/\n//;
            system "clear";
            print "\t-=<Preferences>=-\n\n";
            print "[1]\tX server config file is \"$xconfig\"\n";
            print "[2]\tExtra startcommand on game launch \"$xinitopts\"\n";
            print "[3]\tDefault game specified by it's number \"$input\"\n";
            print "[S]\tSort the gamelist alphabetically\n";
            print "[Q]\tExit these preferences\n\n";
            print "Please choose your desired preference: ";
            chomp ($pref_input = <stdin>);
            $pref_input = lc($pref_input);
            $pref_done = 1;
            if ($pref_input =~ /(1)/ || $pref_input =~ /(2)/ || $pref_input =~ /(3)/){
                @_ = ("", "Please give the new X config file \(example: xorg.conf\) or hit <enter> to leave empty: ", "Please specify the extra startcommand on game launch or hit <enter> to leave empty: ", "Please specify the default game or hit <enter> to leave empty: ");
                print $_[$1];
                chomp ($newpref = <stdin>);
                $options[$1] =~s/(.*?\t).*/$1$newpref/;
                undef $pref_done;
            } elsif ($pref_input eq "s"){
                @list = sort {uc($a) cmp uc($b)} @list;
                undef $pref_done;
            } elsif ($pref_input ne "q"){
                undef $pref_done;
            }
        }
        undef $pref_done;
    }
    
    sub addition {
        # this is where we add games to the list
        print ("Please give the name of the game you'd like to add: ");
        chomp ($game = <stdin>);
        print ("Please give the command related to the game: ");
        chomp ($bin = <stdin>);
        
        # here the game get's added
        push (@list, "$game\t$bin\n");
    }
    
    sub delete {
        # Here we check which game the user wants deleted
        print "Please choose the game you'd like to delete: ";
        chomp ($del = <stdin>);
        while ($del !~/^\d+$/ || $del > @list || $del < 1){
            print "Invalid number, please choose again: ";
            chomp ($del = <stdin>);
        }
        
        # Here we create a new list without the choosen game
        splice @list, --$del, 1;
    }
    
    sub move {
        # First we ask which game has to be moved
        print "Please choose the game you'd like to move: ";
        chomp ($move = <stdin>);
        while ($move !~/^\d+$/ || $move > @list || $move < 1){
            print "Invalid number, please choose again: ";
            chomp ($move = <stdin>);
        }
        
        # Then we ask the destination for the game
        print "Please choose the destination: ";
        chomp ($destin = <stdin>);
        while ($destin !~/^\d+$/ || $destin > @list || $destin < 1){
            print "Invalid number, please choose again: ";
            chomp ($destin = <stdin>);
        }
        
        #Here we write the new gamelist
        $moving = $list[--$move];
        splice @list, $move, 1;
        splice @list, --$destin, 0, $moving;
    }
    
    sub edit {
        # First we ask which game has to be edited
        print "Please choose the game you'd like to edit: ";
        chomp ($edit = <stdin>);
        while ($edit !~/^\d+$/ || $edit > @list || $edit < 1){
            print "Invalid number, please choose again: ";
            chomp ($edit = <stdin>);
        }
        @display = split/\t/,$list[--$edit];
        chomp $display[1];
        print "You choose to edit: \"$display[0]\" with command: \"$display[1]\"\n";
        
        # Here we grab the name to be used
        print "Please give the new name or hit enter to use the existing one: ";
        $name = <stdin>;
        $name = $display[0] if $name eq "\n";
        chomp $name;
        
        # Here we grab the command to be used
        print "Please give the new command or hit enter to use the existing one: ";
        $command = <stdin>;
        $command = $display[1] if $command eq "\n";
        chomp $command;
        
        # Now onto changing the entry in the gamelist
        $list[$edit] = "$name\t$command\n";
    }
    
    sub cat {
        open MYFILE, $_[0] or die "$!";
        @_ = <MYFILE>; 
        close MYFILE; 
        return (wantarray) ? @_ : join("",  @_);
    }
    
    sub write_out {
        $_ = shift @_;
        open WRITE, ">", $_ or die "Error writing '$_': $!\n";
        print WRITE @_;
        close WRITE;
    }
    How to use it:

    1. Code:
      sudo gedit
    2. copy script to the gedit
    3. save them: "/usr/bin/xgame", close gedit
    4. Code:
      sudo chmod +x /usr/bin/xgame
    5. use script:
      Code:
      xgame

    Minimalize and restore:
    CTRL+ALT+F7 - for minimalization
    CTRL+ALT+F8 - for restore of game

    WARNING: CLOSE GAME FIRST, NOT TERMINAL
    This is VERY NICE SCRIPT THAT IT WORKS

    But.... when I change to my first xserver and the revert back to the game it appears a black mouse cursor in the center of the screen.


    Uploaded with ImageShack.us

    Also we have to find a way to be able to use the hotkeys that we have to the first xserver cause when you want to change music or to talk to mumble (with hotkey enable) you have to change to the first xserver

  5. #15
    Join Date
    Dec 2007
    Beans
    2

    Re: No sound on second XServer

    I got the same problem when I change to my first xserver and then revert back to the game, it appears a black X cursor in the center of the screen.
    Using hotkeys for first xserver while playing would be nice too

  6. #16
    Join Date
    Mar 2009
    Beans
    37
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: No sound on second XServer

    Quote Originally Posted by mikeym View Post
    Here's the last version of the script I wrote for ubuntu, but I can't say that it's working as I can't test it. It may give you ideas though.

    install-x.game
    Code:
    #!/bin/bash
    #x.game linux game daemon
    #Version 0.9
    #written by mikey <abc.mikey@googlemail.com>
    
    zenity --question --text="Install x.game?"
    if [ $? = 1 ]; then 
    	exit 0
    fi
    #replace "allowed_users=console"
    gksudo -m "Install x.game" touch /tmp/lock-x.game
    if [  -e /tmp/lock-x.game ]; then
    	gksudo rm /tmp/lock-x.game
    else
    	exit 0
    fi
    #Allow any user to start an XServer
    gksudo awk '{ if ($1 ~ /^allowed_users=/) { printf "#"; print; print "allowed_users=anybody"; } else print }' /etc/X11/Xwrapper.config > /tmp/Xwrapper.config
    gksudo mv /tmp/Xwrapper.config /etc/X11/Xwrapper.config
    #Add group 'chvt' and add current user to group
    groupadd chvt
    current_user=`id | sed 's/uid=[0-9][0-9]*(\([^)]*\)).*/\1/'`
    gksudo "usermod -a -G chvt $current_user"
    zenity --info --text="User added to 'chvt' group.\nAdd any users to use x.game to group 'chvt'."
    #Add group 'chvt' to no password group for command 'chvt'
    gksudo cat /etc/sudoers > /tmp/sudoers; echo "%chvt ALL= NOPASSWD: /usr/bin/chvt" >> /tmp/sudoers; echo "%chvt ALL= NOPASSWD: /usr/bin/ck-launch-session" >> /tmp/sudoers
    gksudo "visudo -c -f /tmp/sudoers"
    if [ $? != 0 ]; then 
    	zenity --info --text="Error updating /etc/sudoers!"
    	exit 1
    fi
    if [ -e /etc/sudoers.tmp ]; then 
    	zenity --info --text="Error updating /etc/sudoers! Locked by another user. Try again later."
    	exit 1
    fi
    gksudo chmod 0440 /tmp/sudoers
    gksudo chown 0:0 /tmp/sudoers
    gksudo mv /tmp/sudoers /etc/sudoers
    #Authorise X for current user on display :1 
    xauth add :1.1 . `mcookie`
    #Install required programs from Universe
    gksudo "apt-get install openbox --yes"
    gksudo "apt-get install feh --yes"
    zenity --info --text="Select a background image for desktop."
    while true; do
    	FILE=$(zenity --file-selection)
    	RES=$(echo "${FILE}" | grep -i ".jpg$")
    	if [ -n "${RES}" ]; then
    		break
    	else
    		zenity --question --text="Invalid file name. Try again?"
    		if [ $? = 1 ]; then 
    			exit 0
    		fi
    	fi
    done
    head -n 5 $0 > /tmp/x.game
    echo "BGIMAGE=\"${FILE}\"" >> /tmp/x.game
    tail -n 81 $0 >> /tmp/x.game
    gksudo mv /tmp/x.game /usr/local/bin/x.game
    gksudo chmod +x /usr/local/bin/x.game
    zenity --info --text="Successfully installed.\nRun 'x.game start [program]'."
    exit 0
    
    PIDFILE="${HOME}/.xgame.pid"
    WMPATH="/usr/bin/openbox"
    function start {
    	if [ -f "/tmp/.X1-lock" ]; then
    		echo "X Display :1 already open"
    		sudo chvt 12
    		DISPLAY=:1
    	else
    		echo "Starting Daemon:"
    		start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --make-pidfile --name xgame --startas /usr/bin/xinit -- $WMPATH -- :1 vt12 &
    		sleep 2s
    		DISPLAY=:1
    		feh --bg-scale "$BGIMAGE" & 
    		ck-launch-session &
    	fi
    	PROGRAM=$1
    	echo "Program: $PROGRAM"
    	if [ "$PROGRAM" != "" ]; then
    		execute $*
    	fi
    }
    function stop {
    	echo "Stoping Daemon:"
    	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name xinit --startas /usr/bin/xinit 
    }
    function execute {
    	if [ -f "/tmp/.X1-lock" ]; then
    		echo "Switching to display :1"
    		sudo chvt 12
    		DISPLAY=:1
    	else
    		echo "Display :1 is not running!"
    		echo "Try 'x.game start PROGRAM'"
    		exit 1	
    	fi
    	PROGRAM=$1
    	shift
    	if [ "$PROGRAM" == "" ]; then
    		echo "Usage: "
    		echo "x.game [start | stop] [PROGRAM] [parameters]"
    		exit 1
    	else
    		while (( "$#" )); do
    			if [[ -n "$1" && $1 == *\ * ]]; then
    				ARGS="$ARGS \"$1\""
    			else
    				ARGS="$ARGS $1"
    			fi
    			shift
    		done
    	fi
    	echo $PROGRAM $ARGS
    	echo $ARGS | xargs $PROGRAM
    }
    #START OF SCRIPT
    IFS="
    "
    SS=$1
    echo "Selecting: $SS"
    case "$SS" in
    	start)
    		echo "Starting:"
    		shift
    		start $*
    		;;
    	stop)
    		echo "Stoping:"
    		shift
    		stop $*
    		;;
    	restart)
    		echo "Restarting:"
    		shift
    		stop $*
    		start $*
    		;;
    	*)
    		echo "Executing:"
    		execute $*
    esac
    exit 0
    (edit) Glad to hear it. It will be a good day when linux gets round to handling games properly. I think the compiz people are looking at it.
    had problems with
    Code:
    #Add group 'chvt' to no password group for command 'chvt'
    gksudo cat /etc/sudoers > /tmp/sudoers; echo "%chvt ALL= NOPASSWD: /usr/bin/chvt" >> /tmp/sudoers; echo "%chvt ALL= NOPASSWD: /usr/bin/ck-launch-session" >> /tmp/sudoers
    gksudo "visudo -c -f /tmp/sudoers"
    if [ $? != 0 ]; then 
    	zenity --info --text="Error updating /etc/sudoers!"
    	exit 1
    fi
    if [ -e /etc/sudoers.tmp ]; then 
    	zenity --info --text="Error updating /etc/sudoers! Locked by another user. Try again later."
    	exit 1
    fi
    gksudo chmod 0440 /tmp/sudoers
    gksudo chown 0:0 /tmp/sudoers
    gksudo mv /tmp/sudoers /etc/sudoers
    i added "%chvt ALL= NOPASSWD: /usr/bin/chvt" and "%chvt ALL= NOPASSWD: /usr/bin/ck-launch-session" to /etc/sudoers manualy and removed those lines from your script then everything worked perfectly. thank you for the script




    LE: ck-launch-session still needs to be started manualy after starting a new xserver
    Last edited by nknwn666; April 17th, 2011 at 09:08 PM.

  7. #17
    Join Date
    Mar 2010
    Location
    Netherlands
    Beans
    42
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: No sound on second XServer

    The trick with "ck-launch-session" no longer works in Ubuntu 11.10. Does anyone know a different workaround?

Page 2 of 2 FirstFirst 12

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
  •