| 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 executable to "__PREFIX__/bin/kmymoney" as string |
|---|
| 35 | set kmymoney to (POSIX file executable) |
|---|
| 36 | |
|---|
| 37 | try |
|---|
| 38 | get alias kmymoney |
|---|
| 39 | on error |
|---|
| 40 | display alert "There was an error locating KMyMoney's executable." & return & return & "Try 'port installed kmymoney' to verify that port 'kmymoney' is installed." & return & return & "The file we tried to find was:" & return & return & "'" & executable & "'" as warning |
|---|
| 41 | return |
|---|
| 42 | end try |
|---|
| 43 | |
|---|
| 44 | set command to "" |
|---|
| 45 | |
|---|
| 46 | set kdedirID to "" |
|---|
| 47 | set ICEauthorityID to "" |
|---|
| 48 | set XauthorityID to "" |
|---|
| 49 | |
|---|
| 50 | set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string) |
|---|
| 51 | set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string) |
|---|
| 52 | set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string) |
|---|
| 53 | |
|---|
| 54 | set kdeDirMessage to "" |
|---|
| 55 | |
|---|
| 56 | try |
|---|
| 57 | |
|---|
| 58 | POSIX file kdeDir as alias |
|---|
| 59 | set kdedirID to do shell script "stat -f '%Su' $HOME/.kde" |
|---|
| 60 | |
|---|
| 61 | end try |
|---|
| 62 | |
|---|
| 63 | try |
|---|
| 64 | |
|---|
| 65 | POSIX file ICEauthority as alias |
|---|
| 66 | set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority" |
|---|
| 67 | |
|---|
| 68 | end try |
|---|
| 69 | |
|---|
| 70 | try |
|---|
| 71 | |
|---|
| 72 | POSIX file Xauthority as alias |
|---|
| 73 | set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority" |
|---|
| 74 | |
|---|
| 75 | end try |
|---|
| 76 | |
|---|
| 77 | if ((not kdedirID is equal to "") and not kdedirID = userID) or not ICEauthorityID = userID or not XauthorityID = userID then |
|---|
| 78 | |
|---|
| 79 | if (not kdedirID is equal to "") then set kdeDirMessage to (kdeDir & return & " is owned by " & kdedirID & return & return) |
|---|
| 80 | |
|---|
| 81 | set fixPermissions to button returned of (display dialog (kdeDirMessage & ICEauthority & return & " is owned by " & ICEauthorityID & return & return & Xauthority & return & " is owned by " & XauthorityID & return & return & "They should be owned by " & userID & " for KMyMoney to run properly!") buttons {"Cancel", "Fix"} default button {"Fix"} with icon 2) |
|---|
| 82 | |
|---|
| 83 | if fixPermissions = "Fix" then |
|---|
| 84 | |
|---|
| 85 | if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges |
|---|
| 86 | do shell script "chown " & userID & " " & ICEauthority with administrator privileges |
|---|
| 87 | do shell script "chown " & userID & " " & Xauthority with administrator privileges |
|---|
| 88 | |
|---|
| 89 | end if |
|---|
| 90 | |
|---|
| 91 | end if |
|---|
| 92 | |
|---|
| 93 | try |
|---|
| 94 | tell application "X11" |
|---|
| 95 | open POSIX path of kmymoney |
|---|
| 96 | end tell |
|---|
| 97 | on error |
|---|
| 98 | display alert "There was an error launching KMyMoney." & return & return & "Try 'port installed kmymoney' to verify that port 'kmymoney' is installed." as warning |
|---|
| 99 | end try |
|---|