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 | |
---|
39 | get alias kmymoney |
---|
40 | |
---|
41 | on error |
---|
42 | |
---|
43 | 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 |
---|
44 | return |
---|
45 | |
---|
46 | end try |
---|
47 | |
---|
48 | set command to "" |
---|
49 | |
---|
50 | set kdedirID to "" |
---|
51 | set qtdirID to "" |
---|
52 | set ICEauthorityID to "" |
---|
53 | set XauthorityID to "" |
---|
54 | |
---|
55 | set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string) |
---|
56 | set qtDir to (POSIX path of (path to home folder) & ".qt/" as string) |
---|
57 | set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string) |
---|
58 | set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string) |
---|
59 | |
---|
60 | set kdeDirMessage to "" |
---|
61 | set qtDirMessage to "" |
---|
62 | set ICEauthorityMessage to "" |
---|
63 | set XauthorityMessage to "" |
---|
64 | |
---|
65 | try |
---|
66 | |
---|
67 | POSIX file kdeDir as alias |
---|
68 | set kdedirID to do shell script "stat -f '%Su' $HOME/.kde" |
---|
69 | |
---|
70 | end try |
---|
71 | |
---|
72 | try |
---|
73 | |
---|
74 | POSIX file qtDir as alias |
---|
75 | set qtdirID to do shell script "stat -f '%Su' $HOME/.qt" |
---|
76 | |
---|
77 | end try |
---|
78 | |
---|
79 | try |
---|
80 | POSIX file ICEauthority as alias |
---|
81 | set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority" |
---|
82 | |
---|
83 | end try |
---|
84 | |
---|
85 | try |
---|
86 | |
---|
87 | POSIX file Xauthority as alias |
---|
88 | set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority" |
---|
89 | |
---|
90 | end try |
---|
91 | |
---|
92 | if ((not kdedirID is equal to "") and not kdedirID = userID) or ((not qtdirID is equal to "") and not qtdirID = userID) or ((not ICEauthorityID is equal to "") and not ICEauthorityID = userID) or ((not XauthorityID is equal to "") and not XauthorityID = userID) then |
---|
93 | |
---|
94 | if (not kdedirID is equal to "") then set kdeDirMessage to (kdeDir & return & " is owned by " & kdedirID & return & return) |
---|
95 | if (not qtdirID is equal to "") then set qtDirMessage to (qtDir & return & " is owned by " & qtdirID & return & return) |
---|
96 | if (not ICEauthorityID is equal to "") then set ICEauthorityMessage to (ICEauthority & return & " is owned by " & ICEauthorityID & return & return) |
---|
97 | if (not XauthorityID is equal to "") then set XauthorityMessage to (Xauthority & return & " is owned by " & XauthorityID & return & return) |
---|
98 | |
---|
99 | set fixPermissions to button returned of (display dialog (kdeDirMessage & qtDirMessage & ICEauthorityMessage & XauthorityMessage & "They should be owned by " & userID & " for KMyMoney to run properly!") buttons {"Cancel", "Fix"} default button {"Fix"} with icon 2) |
---|
100 | |
---|
101 | if fixPermissions = "Fix" then |
---|
102 | |
---|
103 | if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges |
---|
104 | if (not qtdirID is equal to "") then do shell script "chown -R " & userID & " " & qtDir with administrator privileges |
---|
105 | if (not ICEauthorityID is equal to "") then do shell script "chown " & userID & " " & ICEauthority with administrator privileges |
---|
106 | if (not XauthorityID is equal to "") then do shell script "chown " & userID & " " & Xauthority with administrator privileges |
---|
107 | |
---|
108 | end if |
---|
109 | |
---|
110 | end if |
---|
111 | |
---|
112 | |
---|
113 | set command to "sh -l -c " & (POSIX path of kmymoney) & " > /dev/null 2>&1" |
---|
114 | |
---|
115 | try |
---|
116 | |
---|
117 | do shell script command |
---|
118 | |
---|
119 | on error |
---|
120 | |
---|
121 | display alert "There was an error launching KMyMoney." & return & return & "Try 'port installed kmymoney' to verify that port 'kmymoney' is installed." & return & return & "The command we tried to execute was:" & return & return & "'" & command & "'" as warning |
---|
122 | |
---|
123 | end try |
---|