| | 1 | #--------------------------------------------------------------------------------------------------- |
| | 2 | # |
| | 3 | # This program is free software: you can redistribute it and/or modify |
| | 4 | # it under the terms of the GNU General Public License as published by |
| | 5 | # the Free Software Foundation, either version 3 of the License, or |
| | 6 | # (at your option) any later version. |
| | 7 | # |
| | 8 | # This program is distributed in the hope that it will be useful, |
| | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| | 11 | # GNU General Public License for more details. |
| | 12 | # |
| | 13 | # You should have received a copy of the GNU General Public License |
| | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| | 15 | # |
| | 16 | #--------------------------------------------------------------------------------------------------- |
| | 17 | # |
| | 18 | # GPL-licensed icons included in applet.icns are courtesy of KMyMoney's developers! |
| | 19 | # |
| | 20 | #--------------------------------------------------------------------------------------------------- |
| | 21 | # |
| | 22 | # Authors: |
| | 23 | # - Brad Giesbrecht <brad@pixilla.com> |
| | 24 | # - Marko K"aning <MK-MacPorts@techno.ms> |
| | 25 | # |
| | 26 | ######################################################## |
| | 27 | |
| | 28 | try |
| | 29 | |
| | 30 | set userID to do shell script "stat -f '%Su' $HOME" |
| | 31 | |
| | 32 | end try |
| | 33 | |
| | 34 | set kdedirID to "" |
| | 35 | set ICEauthorityID to "" |
| | 36 | set XauthorityID to "" |
| | 37 | |
| | 38 | set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string) |
| | 39 | set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string) |
| | 40 | set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string) |
| | 41 | |
| | 42 | set kdeDirMessage to "" |
| | 43 | |
| | 44 | try |
| | 45 | |
| | 46 | POSIX file kdeDir as alias |
| | 47 | set kdedirID to do shell script "stat -f '%Su' $HOME/.kde" |
| | 48 | |
| | 49 | end try |
| | 50 | |
| | 51 | try |
| | 52 | |
| | 53 | POSIX file ICEauthority as alias |
| | 54 | set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority" |
| | 55 | |
| | 56 | end try |
| | 57 | |
| | 58 | try |
| | 59 | |
| | 60 | POSIX file Xauthority as alias |
| | 61 | set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority" |
| | 62 | |
| | 63 | end try |
| | 64 | |
| | 65 | if ((not kdedirID is equal to "") and not kdedirID = userID) or not ICEauthorityID = userID or not XauthorityID = userID then |
| | 66 | |
| | 67 | if (not kdedirID is equal to "") then set kdeDirMessage to (kdeDir & return & " is owned by " & kdedirID & return & return) |
| | 68 | |
| | 69 | set fixPermissions to button returned of ¬ |
| | 70 | (display dialog (kdeDirMessage ¬ |
| | 71 | & ICEauthority & return & " is owned by " & ICEauthorityID & return & return ¬ |
| | 72 | & Xauthority & return & " is owned by " & XauthorityID & return & return ¬ |
| | 73 | & "They should be owned by " & userID & " for KMyMoney to run properly!") ¬ |
| | 74 | buttons {"Cancel", "Fix"} default button {"Fix"} with icon 2) |
| | 75 | |
| | 76 | if fixPermissions = "Fix" then |
| | 77 | |
| | 78 | if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges |
| | 79 | do shell script "chown " & userID & " " & ICEauthority with administrator privileges |
| | 80 | do shell script "chown " & userID & " " & Xauthority with administrator privileges |
| | 81 | |
| | 82 | end if |
| | 83 | |
| | 84 | end if |
| | 85 | |
| | 86 | try |
| | 87 | do shell script "$SHELL -l -c __PREFIX__/bin/kmymoney > /dev/null 2>&1" |
| | 88 | on error |
| | 89 | display alert "There was an error launching KMyMoney." & return & return & ¬ |
| | 90 | "Try 'port installed kmymoney' to verify kmymoney is installed." & return & return & ¬ |
| | 91 | "The command we tried to execute was:" & return & return & ¬ |
| | 92 | "'$SHELL -l -c __PREFIX__/bin/kmymoney > /dev/null 2>&1'" as warning |
| | 93 | end try |