Thread: Switching .Xdefauls configurations

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446

    Switching .Xdefauls configurations

    Folks, how can I set up different .Xdefaults configurations depending on the wm I'm using?

    EDIT: nevermind. Sorry. I was just tired of search engines. solved. ignore this. etc.
    Last edited by Mario F.; 08-13-2010 at 04:02 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    Can you give us a little more information about your setup and what you want to achieve?

    For me, this is as easy as adding an appropriate `xrdb' line to my `.xinitrc'.

    I just have a tiny bit of shell code that examines a few environment variables to add the relevant defaults and execute the manager specific `.xinitrc.VM_COMMON_NAME' script.

    Soma

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Yeah. I think I still need help with this, after all. I don't like my solution much. There must be a simpler way.

    I use Openbox as my wm. But for sometime, because of the way I set it up and have been using it, I've been realizing that what I really want when I'm programming in Linux is a tiling window manager. For some time I've been using i3 and like it a lot. But every time I switch between them I'm forced to edit my .Xdefaults resources file.

    I've set this script:

    Code:
    # home/marfig/startx
    #!/bin/sh
    
    case "$1" in
    'openbox')
        WM=openbox-session
        ln -sf ~/.Xdefaults.openbox ~/.Xdefaults
    ;;
    *)
        WM=i3
        ln -sf ~/.Xdefaults.i3 ~/.Xdefaults
    ;;
    esac
    
    export WM
    /usr/bin/startx
    By default it sets up i3 resources file. And only if I specify openbox, will it do it.

    In .xinitrc I did this:

    Code:
    if [ -n "${WM+x}" ]; then
        exec "$WM"
    else
        exec i3
    fi
    So, everything works. i3 starts by default, and openbox only if i pass the 'openbox' argument

    But I really don't like having to type "./" to launch a script. I feel what I did is sloppy. Can you suggest me something better?
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Look, I'm just tired and dumb. Of course the solution is to move my own /home/marfig/startx script to the top of /usr/bin/startx!

    /usr/bin/startx does have code for a $1, but I never used it before, and this doesn't seem to have any influence on it. I'm so tired from this that the obvious solution only comes when I finally decided to take my mind off it.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Well, after a good night sleep I came up with better. It's my newbiness...
    Editing /usr/bin/startx isn't that of a good idea either. So I created a bin folder in my home folder, set my path to $HOME/bin:$PATH and:

    Code:
    # ~/bin/startx
    #!/bin/sh
    
    # Set env for openbox or i3. Later processed by .xinitrc
    case "$1" in
    'i3')
            WM="$HOME/bin/start.i3"
            ln -sf ~/.Xdefaults.i3 ~/.Xdefaults
    ;;
    *)
            WM="openbox-session"
            ln -sf ~/.Xdefaults.openbox ~/.Xdefaults
    ;;
    esac
    
    # Run wm
    export WM
    /usr/bin/startx "$2"
    Code:
    # ~/bin/start.i3
    # called from ./startx
    #!/bin/bash
    
    /usr/bin/i3 -V >>$HOME/.i3/i3log >&1
    Code:
    #!/bin/sh
    #
    # ~/.xinitrc
    #
    # Executed by startx (run your window manager from here)
    
    # Initiate vmware integration
    vmware-user&
    
    # Execute WM
    if [ -n "${WM+x}" ]; then
    	exec "$WM" 
    else
    	exec openbox-session 
    fi
    I was having problems with it before I created start.i3. With a bit of help I learned that the redirection was confusing bash and evaluating the whole thing as one command. So start.i3 is necessary to avoid that behavior.

    It's working beautifully now. And I can now easily expand it to other configuration files or, if necessary, to other wms. Who said we need login managers...
    Last edited by Mario F.; 08-14-2010 at 08:22 AM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    You are getting pretty near what I've done.

    About the only difference is that my script (installed in `/usr/bin') only sets an environment variable based on content pulled from a simple "CSV" file. I only need to call the usual `startx'--with no parameters.

    The only necessary changes are local files (`.login' or `.profile'). I need to add a call to setup the default "WM" for the given user.

    Code:
    lgxwst.wm --switch openbox
    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Node switching help
    By Link_26 in forum C++ Programming
    Replies: 0
    Last Post: 02-15-2009, 09:03 PM
  2. Thread paused when switching tasks
    By stickman in forum Windows Programming
    Replies: 4
    Last Post: 09-29-2006, 05:57 PM
  3. Automate Fast User Switching
    By haku_nin in forum Windows Programming
    Replies: 2
    Last Post: 07-29-2005, 12:44 AM
  4. Win32 File Switching within a directory
    By hemanth.balaji in forum Windows Programming
    Replies: 1
    Last Post: 06-10-2005, 10:20 AM
  5. Switching frequency and Bandwidth???
    By pastecopy in forum Tech Board
    Replies: 0
    Last Post: 03-23-2003, 11:13 AM