scripts

Utility script that make my life slightly easier
Log | Files | Refs | README | LICENSE

setupob.sh (1960B)


      1 #!/bin/sh
      2 
      3 #Personal Setup for Openbox main script
      4 #"setupob.sh"
      5 #M. Yamanaka
      6 #email: myamanaka@live.com
      7 #website: csmyamanaka.com
      8 #license: MIT (See included "LICENSE" file for details)
      9 
     10 ## Migrated from old repo
     11 
     12 ##
     13 ## Overhead
     14 ##
     15 
     16 #openbox recognizes the following as its per-user config directory.
     17 #It will hence forth be known as "OBROOT" in this script
     18 OBROOT=$HOME/.config/openbox
     19 
     20 #OBROOT is not created by default in most cases
     21 mkdir -p $OBROOT
     22 
     23 #also, a bunch of other directories will be made
     24 mkdir -p $HOME/.local/media/images
     25 mkdir -p $HOME/.local/scripts
     26 #yes, we are using rofi today ladies and gentlemen
     27 mkdir -p $HOME/.config/rofi
     28 
     29 #copy rofi configs
     30 cp $(pwd)/rofi/*.rasi $HOME/.config/rofi
     31 
     32 #Openbox usually creates a global config directory /etc/xdg/openbox upon installation
     33 #the global config files are copied to OBROOT to be modified
     34 cp /etc/xdg/openbox/*.xml $OBROOT
     35 
     36 ##
     37 ## Keybindings
     38 ##
     39 
     40 #retrieve the first and last line numbers of the keybindings portion in the original file
     41 
     42 #### TODO: Make this more efficient!! find a better way than to do the grep | cut ... etc twice ####
     43 KBBEGIN=$(grep -n "keyboard" $OBROOT/rc.xml | cut -f 1 -d ":" | head -n 1)
     44 KBEND=$(grep -n "keyboard" $OBROOT/rc.xml | cut -f 1 -d ":" | tail -n 1)
     45 
     46 #The script also needs to know the size of the original config file so that the "tail" command can
     47 #print out the correct number of lines from the bottom
     48 RCFILESZ=$(wc -l $OBROOT/rc.xml | awk '{print $1}')
     49 CONFTAIL=$(( $RCFILESZ - $KBEND ))
     50 
     51 CONFHEAD=$(( $KBBEGIN - 1 ))
     52 
     53 #The overall strategy is to replace the keybindings section with the contents of my custom keybindings file
     54 CUSTOMKEYS=$(pwd)/keybindings.xml
     55 
     56 head -n $CONFHEAD $OBROOT/rc.xml > $OBROOT/tmpconf
     57 cat $CUSTOMKEYS >> $OBROOT/tmpconf
     58 tail -n $CONFTAIL $OBROOT/rc.xml >> $OBROOT/tmpconf
     59 
     60 mv $OBROOT/tmpconf $OBROOT/rc.xml
     61 
     62 ##
     63 ## xinitrc
     64 ##
     65 
     66 #replace the existing xinitrc (if any) with the one in this repo
     67 mv $(pwd)/xinitrc $HOME/.xinitrc

Generated using stagit (https://codemadness.org/stagit.html)