Announcement

Collapse
No announcement yet.

Focus on open

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Focus on open

    Hi guys, I'm writing because I want to be able to tell a particular command to run in focus.

    I have a game which runs in a 32-bit WINE prefix, and it never takes focus when it opens, it just opens in the background.

    I can bring it into focus by clicking on it in the taskbar, or by running "wmctrl -R Alice: Madness Returns", but I can't just add that command to the end of the shortcut, (even using the parallel command), presumably because the game hasn't opened by the time the focus command has run.

    It's particularly awkward having to click on it in the tasktray after opening it, because the computer I'm trying to run it on is a media centre, and I'm running the game from XBMC, so I need to put down my gamepad and pick up the remote control to minimise XBMC, switch the remote control to air mouse to click on Alice Madness Returns in the task tray, then put the remote control down and pick up the gamepad again. Really I want something in the command to run it, which tells it to take focus.

    Does anyone know of a way to tell a the software to take focus in the command to run it?

    #2
    The command to run it (created by q4WINE) is
    Code:
    /usr/bin/env WINEPREFIX='/home/aco/.local/share/wineprefixes/32' 
    WINESERVER='/usr/bin/wineserver' WINELOADER='/usr/bin/wine' 
    WINEDLLPATH='/usr/lib/i386-linux-gnu/wine/' WINEARCH='win32' 
    WINEDEBUG='-all' /bin/sh -c 
    "cd '/home/aco/.local/share/wineprefixes/32/drive_c/Program Files/Alice Madness Returns/Alice2/Binaries/Win32/' && '/usr/bin/wine' 'AliceMadnessReturns.exe' 2>&1 "
    Last edited by Aston; Nov 24, 2014, 12:30 AM.

    Comment


      #3
      Update, I've found a way to do it with a shell script, but it's messy. If I put the command to open it in a script (called "launcher") then run the command
      Code:
      parallel ::: "sleep 10 && wmctrl -R Alice: Madness Returns" 
      "bash '/home/aco/wine32/Alice Madness Returns/Alice2/launch'"
      it will open the game and bring it into focus, but it seems like a roundabout way of doing it, and more to the point, I don't know how to get it into one command without saving part of it to a script.

      The problem is that there are already two levels of quotation marks, so I can't put the WINEPREFIX command in the parallel command, does anyone know how to get around the limitations of having ' and " used already and needing another level of quotation?
      Last edited by Aston; Nov 24, 2014, 12:29 AM.

      Comment


        #4
        Kwin rules ?

        Have you tried the kwin rules ?
        KWin allows the end-user to define rules to alter an application's window attributes.

        For example, when an application is started, it can be forced to always run on Virtual Desktop 2. Or a defect in an application can be worked-around to force the window above others...
        KDE system settings > Window Behavior > Window rules
        or
        Right click window top decoration > More actions...




        More:

        - KWin Rules: https://userbase.kde.org/KWin_Rules
        - KWin Rules Examples: https://userbase.kde.org/KWin_Rules_Examples
        - KWin Rules Window Matching: https://userbase.kde.org/KWin_Rules_Window_Matching
        - ...
        Last edited by Rog132; Nov 23, 2014, 03:47 AM.
        A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
        Searching FAQ's: Google Search 'FAQ from Kubuntuforums'

        Comment


          #5
          Originally posted by Aston View Post
          ...
          The problem is that there are already two levels of quotation marks, so I can't put the WINEPREFIX command in the parallel command...
          AFAICT, none of the WINE environment variable settings require quotes. The only place quoting is needed is to escape the spaces in the cd command, and you could use a backslash instead. I created a directory called Program Files, with one file x in it,
          Code:
          $ parallel ::: "sleep 4; echo foo" "bash -c 'cd Program\ Files;ls'"
          x
          foo
          Regards, John Little

          Comment


            #6
            Thanks both!

            The Kwin rules were the one category in that dialogue I didn't try, looks like a cool feature. It didn't seem to have any effect on the game, I tried with "exact match" of "Alice: Madness Returns" and "contains string" of "alice madness returns" (in case the colon was causing problems) with a rule which forced not minimised and forced focus, but it didn't seem to have an effect (screenshot included). Interestingly, I found out in the process that the window is minimised, not just out of focus.
            Click image for larger version

Name:	snapshot1.jpg
Views:	1
Size:	69.0 KB
ID:	642613

            On the quotations, ah that's awesome you can use the backslash like that, I did something very similar to solve the problem to my satisfaction. I ended up putting backslashes behind both of the double quotation (") marks in the WINEPREFIX command. That way it nests quite happily in the parallel command, and I can run that command from the Kicker shortcut and the XBMC Advanced Launcher entry without any script files.

            The fixed command .
            Code:
            parallel ::: "sleep 10 && wmctrl -R Alice: Madness Returns" 
            "/usr/bin/env  WINEPREFIX='/home/aco/.local/share/wineprefixes/32'  
            WINESERVER='/usr/bin/wineserver'  WINELOADER='/usr/bin/wine'  
            WINEDLLPATH='/usr/lib/i386-linux-gnu/wine/'  WINEARCH='win32'  
            WINEDEBUG='-all'  /bin/sh -c 
            \"cd '/home/aco/.local/share/wineprefixes/32/drive_c/Program Files/Alice Madness Returns/Alice2/Binaries/Win32/' &&   '/usr/bin/wine'   'AliceMadnessReturns.exe'  2>&1 \" "
            Last edited by Aston; Nov 24, 2014, 12:27 AM.

            Comment

            Working...
            X