Ticket #28276: arb_macsetup.diff

File arb_macsetup.diff, 2.9 KB (added by matt.cottrell@…, 13 years ago)

Patch file to tweak the arb_macsetup script

  • arb_macsetup

    old new  
    2929#
    3030
    3131# This is the arb_macsetup script
    32 # Use it to set the ARBHOME and PATH variables after installing ARB using MacPorts.
     32# Use it to set the ARBHOME and PATH variables and to install a .xmodmap file after installing ARB using MacPorts.
    3333
    3434# Derived from the MacPorts postflight script
    3535# Provided by: Matthew Cottrell
    36 # October 1, 2009
     36# January 31, 2011
    3737
    3838# Abstraction variables:
    3939# The MacPorts PREFIX is typicaly /opt/local
     
    4343MANPAGES=${PREFIX}/share/man
    4444TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
    4545BACKUP_SUFFIX=macports-saved_${TIMESTAMP}
     46XMODMAP_FILE=xmodmap
    4647OUR_STRING="ARB Installer addition on ${TIMESTAMP}"
    4748
    4849# Determine the user's shell, in order to choose an appropriate configuration file we'll be tweaking.
     
    105106    echo "An appropriate ${1} variable has been added to your shell environment by the ${3} installer."
    106107}
    107108
     109function write_xmodmap_setting () {
     110    if [ -f ${HOME}/.${XMODMAP_FILE} ] && ! grep "${OUR_STRING}" ${HOME}/.${XMODMAP_FILE} > /dev/null; then
     111        echo "Backing up your ${HOME}/.${XMODMAP_FILE} keyboard confguration file as ${HOME}/.${XMODMAP_FILE}.${BACKUP_SUFFIX} before adapting it for ARB."
     112        /bin/cp -fp ${HOME}/.${XMODMAP_FILE} "${HOME}/.${XMODMAP_FILE}.${BACKUP_SUFFIX}" || {
     113            echo "An attempt to backup your original configuration file failed! Please set your ARB compatible environment manually."
     114           
     115            exit 1
     116        }
     117        echo -e "\n##\n# Your previous ${HOME}/.${XMODMAP_FILE} file was backed up as ${HOME}/.${XMODMAP_FILE}.${BACKUP_SUFFIX}\n##" >> ${HOME}/.${XMODMAP_FILE}
     118    fi
     119    echo -e "\n# ${OUR_STRING}: adding an appropriate ${1} variable for use with ${3}." >> ${HOME}/.${XMODMAP_FILE}
     120    echo "${1}\n ${2}\n ${3}\n ${4}\n ${5}\n ${6}\n ${7}\n" >> ${HOME}/.${XMODMAP_FILE}
     121    echo -e "# Finished adapting your xmodmap file for use with ARB.\n" >> ${HOME}/.${XMODMAP_FILE}
     122    chown ${USER} ${HOME}/.${XMODMAP_FILE} || echo "Warning: unable to adapt permissions on your ${HOME}/.${XMODMAP_FILE} shell configuration file!"
     123    echo "An appropriate xmodmap file has been added to your home folder by the ${8} installer."
     124}
     125
    108126# Confirm that MacPorts has been configured for this user:
    109127if ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/printenv PATH" | grep ${PREFIX} > /dev/null; then
    110128    echo "Your shell already has the right PATH environment variable for use with MacPorts!"
     
    149167        write_setting ARBHOME "${PREFIX}/share/arb" ARB
    150168fi
    151169
     170#write the .xmodmap file for easy keyboard shortcutsin the ARB sequence editor
     171write_xmodmap_setting "clear Mod1" "clear Mod2" "keycode 63 = Mode_switch" "keycode 66 = Meta_L" "keycode 69 = Meta_R" "add Mod1 = Meta_L Meta_R" "add Mod2 = Mode_switch" ARB
     172
    152173# arb_setenv script is done with its job - exit gracefully!
    153174echo ""
    154175echo "You have succesfully installed ARB"