Trying to use the Borg on Linux with xscreensaver

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joe B
    Rookie
    • Jan 2009
    • 10

    Trying to use the Borg on Linux with xscreensaver

    Update: This problem has been solved. There are instructions for installing this xscreensaver hack in post #3
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    After reading this post some time ago, I've wanted to get the Borg to work with xscreensaver. The problem is, Nick didn't post the information, he apparently just emailed it to takk.

    I've been hacking at takkaria's borg haphazardly for a few hours. While I've gotten the program to autorun the borg when given "-x" as a commandline argument (an accomplishment I'm somewhat proud of, even though it's implemented terribly), I don't know how to make it draw to the root window.

    I've tried running the curses version through phosphor and apple2, but apple2's window is too tiny, and phosphor bugs out and tries to cause seizures.

    tl;dr Does anyone have the "stuff" Nick was talking about? If not, any other help would also be appreciated.
    Last edited by Joe B; March 7, 2009, 01:59. Reason: PRESENTS FOR ALL
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9647

    #2
    Originally posted by Joe B
    While I've gotten the program to autorun the borg when given "-x" as a commandline argument (an accomplishment I'm somewhat proud of, even though it's implemented terribly), I don't know how to make it draw to the root window.
    Excellent. What you need is vroot.

    Does anyone have the "stuff" Nick was talking about?
    Here is what I have. It consists of a hacked (by me in copy of Immir, who was the originator of this stuff for 3.0.5) version of main-x11.c, plus vroot.h, which allows writing to the root window. I couldn't get it to autorun, so maybe between us we've solved it.

    I made my attempt for 3.0.9 (or maybe 3.0.9b). I think you may need to put a -DXSCREENSAVER in the Makefile as well. Good luck!
    One for the Dark Lord on his dark throne
    In the Land of Mordor where the Shadows lie.

    Comment

    • Joe B
      Rookie
      • Jan 2009
      • 10

      #3
      Sweet! It works! If you want to build the version I've got, with my autostart code and your root code, you can use this script I wrote. I'm going to write this post like a tutorial so anyone can do it.
      Code:
      #!/bin/bash
      
      # Download takkaria's 3.0.9b borg
      git clone git://repo.or.cz/angband/borg/takk.git
      cd takk
      
      # Create lib directory
      mkdir -p "$HOME/.angband-borg/Angband"
      cp -r lib/* "$HOME/.angband-borg/Angband"
      
      # Download modified files for xscreensaver support
      wget http://www.fileden.com/files/2009/3/6/2352442/borg-xscreensaver.tar.bz2
      tar -xjf borg-xscreensaver.tar.bz2
      
      # Compile!
      cd src
      make -f Makefile.svr
      Then it should be compiled. This script should be run as root, from the same directory as the first script:
      Code:
      #!/bin/bash
      
      # Modify these variables to your system's needs
      LIBDIR="/usr/lib/xscreensaver"
      CONFDIR="/usr/share/xscreensaver/config"
      # This should be the directory that contains the file "XScreenSaver":
      DEFAULTSDIR="/usr/share/X11/app-defaults"
      
      # Copy binary
      cd takk
      cp angband "$LIBDIR/angband-borg"
      
      # Download configuration
      cd "$CONFDIR"
      wget http://www.fileden.com/files/2009/3/6/2352442/angband-borg.xml
      
      # Edit XScreenSaver config file
      cd "$DEFAULTSDIR"
      mv XScreenSaver XScreenSaver.bak
      head -`grep -n attraction XScreenSaver.bak | sed s/:.*//` XScreenSaver.bak > XScreenSaver
      echo "angband-borg -x \\n\\" >> XScreenSaver
      tail -$[`cat XScreenSaver.bak | wc -l` - `grep -n attraction XScreenSaver.bak | sed s/:.*//`] XScreenSaver.bak >> XScreenSaver
      And it should be installed and ready to use. Just pick it in xscreensaver-demo.

      Your borg.txt file goes into ~/.angband-borg/Angband/
      Last edited by Joe B; March 10, 2009, 23:34.

      Comment

      • PaulBlay
        Knight
        • Jan 2009
        • 657

        #4
        If it wasn't 2am in my time-zone I'd do LOLCAT for this thread.

        I AM IN UR ROOT
        KILLN UR MORGOTH
        Currently turning (Angband) Japanese.

        Comment

        • Nick
          Vanilla maintainer
          • Apr 2007
          • 9647

          #5
          Awesome! I have it working now, too. The only thing I needed to change was
          Code:
          cd angband-3.0.9
          to
          Code:
          cd angband-3.0.9-borg in
          in ~/bin/borg-saver.

          And of course change to "Only one screensaver"
          One for the Dark Lord on his dark throne
          In the Land of Mordor where the Shadows lie.

          Comment

          • Nick
            Vanilla maintainer
            • Apr 2007
            • 9647

            #6
            OK one problem - my borg doesn't seem to be saving on interruption to the screensaver. Any clues?
            One for the Dark Lord on his dark throne
            In the Land of Mordor where the Shadows lie.

            Comment

            • Joe B
              Rookie
              • Jan 2009
              • 10

              #7
              Originally posted by Nick
              OK one problem - my borg doesn't seem to be saving on interruption to the screensaver. Any clues?
              Hmm, I'm not sure... It works fine for me. I'll check it out and see if I forgot to mention a step.

              I'm also not sure what you were talking about in your previous post.

              Edit: I just remembered something I had to do, but I don't know if it'll fix it.
              When I first compiled it, I had to copy the contents of the lib/ directory (but not the directory itself) to ~/.angband-borg You would think the program would do that by itself, but it seems not.

              Edit 2: I think my instructions might have been terribly wrong. I have lib/ directories all over my filesystem, and it appears the program isn't using the one I thought it was. On top of that, xscreensaver wasn't using the same binary I thought it was...

              Edit 3: Now it seems to not be saving for me, either...

              Edit Ω: Okay, after much fiddling around, it should now work the way I originally wanted it to. The new file is at the same location. Sorry about the inconvenience. I hope no other problems pop up, that was pretty embarrassing...

              Edit Oh yeah I forgot to mention: this setup looks pretty nice on 1024x768:
              Code:
              # Angband X11 settings
              
              TERM_WINS=3
              
              # Term 0
              AT_X_0=1
              AT_Y_0=-21
              COLS_0=80
              ROWS_0=24
              IBOX_0=1
              IBOY_0=1
              FONT_0=10x20
              TILE_WIDTH_0=10
              TILE_HEIGHT_0=20
              
              # Term 1
              AT_X_1=1
              AT_Y_1=469
              COLS_1=80
              ROWS_1=12
              IBOX_1=1
              IBOY_1=1
              FONT_1=6x13
              TILE_WIDTH_1=6
              TILE_HEIGHT_1=13
              
              # Term 2
              AT_X_2=544
              AT_Y_2=469
              COLS_2=80
              ROWS_2=23
              IBOX_2=1
              IBOY_2=2
              FONT_2=6x13
              TILE_WIDTH_2=6
              TILE_HEIGHT_2=13
              Save as ~/.angband-borg/Angband/x11-settings.prf
              Last edited by Joe B; March 7, 2009, 23:24.

              Comment

              • Nick
                Vanilla maintainer
                • Apr 2007
                • 9647

                #8
                Originally posted by Joe B
                I'm also not sure what you were talking about in your previous post.
                Bizarrely, it seems that my direct (read - a big hack) attempt to get it running was actually working - I have no idea why now - and I wasn't using yours at all.

                After much fiddling, I now have your version running. Points to note:
                1. Your first script failed due to lack of vroot.h; I copied mine over and reran, and it was all good.
                2. Most of the time was spent because I didn't notice that when there was already an angband-borg-xml, it copied the new one to angband-borg.xml.n+1, where n was the previous highest existing number. I had five of them when I twigged to this...it appears to be a 'feature' of wget, and changing to wget -p I think fixes it.
                3. I had to copy the subdirectories of lib to .angband-borg/Angband/ to get it running (so, eg, the savefile is in .angband-borg/Angband/save).


                Good work! This is now much cleaner than my version.
                One for the Dark Lord on his dark throne
                In the Land of Mordor where the Shadows lie.

                Comment

                • Joe B
                  Rookie
                  • Jan 2009
                  • 10

                  #9
                  Originally posted by Nick
                  1. Your first script failed due to lack of vroot.h; I copied mine over and reran, and it was all good.
                  2. Most of the time was spent because I didn't notice that when there was already an angband-borg-xml, it copied the new one to angband-borg.xml.n+1, where n was the previous highest existing number. I had five of them when I twigged to this...it appears to be a 'feature' of wget, and changing to wget -p I think fixes it.
                  3. I had to copy the subdirectories of lib to .angband-borg/Angband/ to get it running (so, eg, the savefile is in .angband-borg/Angband/save).
                  1. Heh, figures. I forgot to include vroot.h in the archive this time. I've got a terrible memory, so I used
                    Code:
                    ls *.bak | sed s/.bak// | while read line; do cp "$line" src/; done
                    and just assumed all the required files were there. Would you believe I almost didn't even include my Makefile?
                  2. Thanks for the tip!
                  3. I should probably add that part to the script.

                  I'll upload a corrected archive and improve the script for posterity.

                  Originally posted by Nick
                  Good work! This is now much cleaner than my version.
                  I love being appreciated.

                  Edit: (I have a terrible habit of editing posts too often, did you notice?) You might want to download the xml config file again, it now has "-x" enabled by default. The installation process should now be totally user-friendly, so I hope more people will try it out.
                  Last edited by Joe B; March 8, 2009, 05:15.

                  Comment

                  • d_m
                    Angband Devteam member
                    • Aug 2008
                    • 1517

                    #10
                    So I have followed these steps to the best of my ability, and I can get the auto-start working (once I create an initial character) but I can't get it drawing to the root window. It compiles, main-x11.c mentions vroot.h, but if I run the resulting angband executable it renders in a window, not in the root window.

                    As a side-note, angband-borg also doesn't show up in the list of xscreensaver options, but for now I'm more concerned with getting angband running in the root window.
                    linux->xterm->screen->pmacs

                    Comment

                    • Joe B
                      Rookie
                      • Jan 2009
                      • 10

                      #11
                      Originally posted by d_m
                      So I have followed these steps to the best of my ability, and I can get the auto-start working (once I create an initial character) but I can't get it drawing to the root window. It compiles, main-x11.c mentions vroot.h, but if I run the resulting angband executable it renders in a window, not in the root window.
                      It's weird like that -- it seems to just magically draw to root when it runs from xscreensaver. When you run it from the commandline, though, it runs like regular X11 Angband. ...Don't look at me, I didn't code it.

                      Originally posted by d_m
                      As a side-note, angband-borg also doesn't show up in the list of xscreensaver options, but for now I'm more concerned with getting angband running in the root window.
                      Did you make sure angband-borg.xml is in the right directory? It might be different on whatever distro you run. I think having the XML file should be enough to make it show up.

                      Comment

                      • Nick
                        Vanilla maintainer
                        • Apr 2007
                        • 9647

                        #12
                        Originally posted by Joe B
                        Did you make sure angband-borg.xml is in the right directory? It might be different on whatever distro you run. I think having the XML file should be enough to make it show up.
                        If all else fails, you can try writing an entry direct into your .xscreensaver file - then I think it will see it provided the angband-borg executable is in the right directory.
                        One for the Dark Lord on his dark throne
                        In the Land of Mordor where the Shadows lie.

                        Comment

                        • Joe B
                          Rookie
                          • Jan 2009
                          • 10

                          #13
                          Originally posted by Nick
                          If all else fails, you can try writing an entry direct into your .xscreensaver file - then I think it will see it provided the angband-borg executable is in the right directory.
                          Yeah, I've been having trouble getting it to work consistently, so I wrote another script to automatically add it to the XScreenSaver file (I figured I'd cut out the middle man and ignore .xscreensaver)

                          So, d_m, hopefully this will make it show up in xscreensaver-demo for you (run as root):
                          Code:
                          #!/bin/bash
                          
                          # This should be the directory that contains the file "XScreenSaver"
                          DEFAULTSDIR="/usr/share/X11/app-defaults"
                          
                          cd "$DEFAULTSDIR"
                          mv XScreenSaver XScreenSaver.bak
                          head -`grep -n attraction XScreenSaver.bak | sed s/:.*//` XScreenSaver.bak > XScreenSaver
                          echo "angband-borg -x \\n\\" >> XScreenSaver
                          tail -$[`cat XScreenSaver.bak | wc -l` - `grep -n attraction XScreenSaver.bak | sed s/:.*//`] XScreenSaver.bak >> XScreenSaver
                          I'm crossing my fingers for good luck...

                          Comment

                          • KarlM
                            Rookie
                            • May 2007
                            • 16

                            #14
                            Originally posted by d_m
                            So I have followed these steps to the best of my ability, and I can get the auto-start working (once I create an initial character) but I can't get it drawing to the root window. It compiles, main-x11.c mentions vroot.h, but if I run the resulting angband executable it renders in a window, not in the root window.

                            As a side-note, angband-borg also doesn't show up in the list of xscreensaver options, but for now I'm more concerned with getting angband running in the root window.
                            I've been trying this as well, and having the same problems as d_m. I'm using debian gnome if that makes a difference.

                            I have tried adding angband-borg directly into ~/.xscreensaver, so it does now appear in the list of available savers. (of course there is no preview since the borg doesnt understand the -window [hex] argument).

                            But when xscreensaver calls the borg (running on the root window, which is great) I get another problem: the borg can't see ./lib/*. Probably some sort of cd or permissions issue, I will fiddle a bit more in a couple days.

                            Cheers
                            Karl
                            "You hit Morgoth, Lord of Darkness. You have slain Morgoth, Lord of Darkness. Congratulations, you have won the game. The Great Wyrm of Balance breathes chaos. You die."

                            Comment

                            • Joe B
                              Rookie
                              • Jan 2009
                              • 10

                              #15
                              Were you guys having trouble using the script? By that I mean, did it work at all? I just tested it again, and wget -p wasn't doing what I expected it to.

                              Originally posted by KarlM
                              But when xscreensaver calls the borg (running on the root window, which is great) I get another problem: the borg can't see ./lib/*. Probably some sort of cd or permissions issue, I will fiddle a bit more in a couple days.
                              That's bizarre -- it shouldn't be looking for ./lib at all! I hardcoded "~/.angband-borg/Angband" as the default lib directory.

                              Here's what I'm thinking, though:
                              Did you run the first script as root? Only the second script should be run as root. Maybe try running:
                              Code:
                              sudo chown -R $USER:users $HOME/.angband-borg/Angband

                              Comment

                              Working...
                              😀
                              😂
                              🥰
                              😘
                              🤢
                              😎
                              😞
                              😡
                              👍
                              👎