summaryrefslogtreecommitdiff
path: root/skel/parabola-irc.sh
blob: 3f87fa7cebef925d23ad7c7f84bcdf0dd139b7bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

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."


#      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

          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_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