Ticket #24433: main.2.applescript

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

apple script w/o line breaks to avoid UTF-8/ISO-8859 issues with AS editor

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 kdedirID to ""
35set ICEauthorityID to ""
36set XauthorityID to ""
37
38set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string)
39set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string)
40set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string)
41
42set kdeDirMessage to ""
43
44try
45       
46        POSIX file kdeDir as alias
47        set kdedirID to do shell script "stat -f '%Su' $HOME/.kde"
48       
49end try
50
51try
52       
53        POSIX file ICEauthority as alias
54        set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority"
55       
56end try
57
58try
59       
60        POSIX file Xauthority as alias
61        set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority"
62       
63end try
64
65if ((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 & 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)
72       
73        if fixPermissions = "Fix" then
74               
75                if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges
76                do shell script "chown " & userID & " " & ICEauthority with administrator privileges
77                do shell script "chown " & userID & " " & Xauthority with administrator privileges
78               
79        end if
80       
81end if
82
83try
84        do shell script "__PREFIX__/bin/kmymoney > /dev/null 2>&1"
85on error
86        display alert "There was an error launching KMyMoney." & return & return & "Try 'port installed kmymoney' to verify kmymoney is installed." & return & return & "The command we tried to execute was:" & return & return & "'__PREFIX__/bin/kmymoney > /dev/null 2>&1'" as warning
87end try