diff options
Diffstat (limited to 'skel/parabola-irc.sh')
-rw-r--r--[-rwxr-xr-x] | skel/parabola-irc.sh | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/skel/parabola-irc.sh b/skel/parabola-irc.sh index b457e71..3f87fa7 100755..100644 --- a/skel/parabola-irc.sh +++ b/skel/parabola-irc.sh @@ -1,32 +1,43 @@ #!/bin/bash -DEFAULT_NICK='parabola-user' # ASSERT: as defined in ~/.purple/accounts.xml and ~/.purple/blist.xml +readonly DEFAULT_NICK='parabola-user' # ASSERT: as defined in ~/.purple/accounts.xml and ~/.purple/blist.xml +readonly NETWORK='@irc.freenode.net' +readonly DEFAULT_ACCOUNT="${DEFAULT_NICK}${NETWORK}" +readonly CURRENT_NICK=$(grep '<name>.*</name>' ~/.purple/accounts.xml | sed "s|.*<name>\(.*\)${NETWORK}</name>.*|\1|") +readonly KEEP_NICK_MSG="Your Parabola IRC nick-name is currently '${CURRENT_NICK}'.\n\n \ +Would you like to keep this nick-name, or choose another?\n\n \ +Note that choosing another will delete any changes you have may have made to pidgin." -if [ -z "$(grep $DEFAULT_NICK@irc.freenode.net ~/.purple/accounts.xml)" ] || \ - [ -z "$(grep $DEFAULT_NICK@irc.freenode.net ~/.purple/blist.xml )" ] -then if zenity --question --width=320 \ - --title="Parabola IRC Login" \ - --text="The default 'parabola-user' freenode IRC account has been modified. \ -This desktop shortcut is only for that account. You can either restore Pidgin to it's default \ -configuration (deleting any changes you have made); or delete this shortcut from the desktop." \ - --ok-label="Reset Pidgin completely" \ - --cancel-label="Remove this desktop shortcut" +# gxmessage -title "Parabola IRC Login" \ +# -buttons "Choose a different nick-name:0,Keep this nickname:1" \ +# -default "Choose a different nick-name" \ +# -geometry 620x460 \ +# -center -wrap -ontop -sticky \ +# "$KEEP_NICK_MSG" +# if which gxmessage > /dev/null +if which zenity > /dev/null +then if (diff ~/.purple/accounts.default.xml ~/.purple/accounts.xml > /dev/null && \ + diff ~/.purple/blist.default.xml ~/.purple/blist.xml > /dev/null ) || \ + zenity --question --width=480 \ + --title="Parabola IRC Login" \ + --text="${KEEP_NICK_MSG}" \ + --ok-label="Choose a different nick-name" \ + --cancel-label="Keep this nick-name" then cp ~/.purple/accounts.default.xml ~/.purple/accounts.xml cp ~/.purple/blist.default.xml ~/.purple/blist.xml - else rm ~/Desktop/parabola-irc.desktop - rm ~/parabola-irc.sh - exit - fi -fi -nick=$(zenity --entry --width=320 \ - --title="Parabola IRC Login" \ - --text="Choose a nick-name:" \ - --entry-text=$DEFAULT_NICK ) -nick=${nick// /} ; [ "$nick" ] || nick=$DEFAULT_NICK ; + nick=$(zenity --entry --width=320 \ + --title="Parabola IRC Login" \ + --text="Choose a nick-name:" \ + --entry-text=${DEFAULT_NICK} ) + nick=${nick// /} ; [ "$nick" ] || nick=${DEFAULT_NICK} ; -sed -i "s|$DEFAULT_NICK@irc.freenode.net|$nick@irc.freenode.net|" ~/.purple/accounts.xml -sed -i "s|$DEFAULT_NICK@irc.freenode.net|$nick@irc.freenode.net|" ~/.purple/blist.xml + sed -i "s|${DEFAULT_ACCOUNT}|${nick}${NETWORK}|" ~/.purple/accounts.xml + sed -i "s|${DEFAULT_ACCOUNT}|${nick}${NETWORK}|" ~/.purple/blist.xml + else sed -i 's|^Exec=.*|Exec=pidgin|' ~/Desktop/parabola-irc.desktop + rm $0 + fi +fi pidgin |