Ticket #24433: main.4.applescript

File main.4.applescript, 3.5 KB (added by mkae (Marko Käning), 14 years ago)

Ooops, there were still 2 line-breaks in it. (Now "file main.applescript" returns "ASCII with very long lines".)

Line 
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
28try
29       
30        set userID to do shell script "stat -f '%Su' $HOME"
31       
32end try
33
34set executable to "__PREFIX__/bin/kmymoney" as string
35set kmymoney to (POSIX file executable)
36
37try
38        get alias kmymoney
39on 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
42end try
43
44set command to ""
45
46set kdedirID to ""
47set ICEauthorityID to ""
48set XauthorityID to ""
49
50set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string)
51set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string)
52set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string)
53
54set kdeDirMessage to ""
55
56try
57       
58        POSIX file kdeDir as alias
59        set kdedirID to do shell script "stat -f '%Su' $HOME/.kde"
60       
61end try
62
63try
64       
65        POSIX file ICEauthority as alias
66        set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority"
67       
68end try
69
70try
71       
72        POSIX file Xauthority as alias
73        set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority"
74       
75end try
76
77if ((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       
91end if
92
93try
94        tell application "X11"
95                open POSIX path of kmymoney
96        end tell
97on 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
99end try