source: trunk/dports/kde/kmymoney/files/KMyMoney.applescript @ 105376

Last change on this file since 105376 was 68458, checked in by mk@…, 10 years ago
  • be more precise concerning icons
File size: 4.6 KB
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 used by the .app created from this script are
19# courtesy of KMyMoney's developers and taken from KMyMoney's sources.
20# (See ../Portfile for details.)
21#
22#----------------------------------------------------------------------
23#
24# Authors:
25#  - Brad Giesbrecht <brad@pixilla.com>
26#  - Marko K"aning <MK-MacPorts@techno.ms>
27#
28#----------------------------------------------------------------------
29
30try
31       
32        set userID to do shell script "stat -f '%Su' $HOME"
33       
34end try
35
36set executable to "__PREFIX__/bin/kmymoney" as string
37set kmymoney to (POSIX file executable)
38
39try
40       
41        get alias kmymoney
42       
43on error
44       
45        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
46        return
47       
48end try
49
50set command to ""
51
52set kdedirID to ""
53set qtdirID to ""
54set ICEauthorityID to ""
55set XauthorityID to ""
56
57set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string)
58set qtDir to (POSIX path of (path to home folder) & ".qt/" as string)
59set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string)
60set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string)
61
62set kdeDirMessage to ""
63set qtDirMessage to ""
64set ICEauthorityMessage to ""
65set XauthorityMessage to ""
66
67try
68       
69        POSIX file kdeDir as alias
70        set kdedirID to do shell script "stat -f '%Su' $HOME/.kde"
71       
72end try
73
74try
75       
76        POSIX file qtDir as alias
77        set qtdirID to do shell script "stat -f '%Su' $HOME/.qt"
78       
79end try
80
81try
82        POSIX file ICEauthority as alias
83        set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority"
84       
85end try
86
87try
88       
89        POSIX file Xauthority as alias
90        set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority"
91
92end try
93
94if ((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
95       
96        if (not kdedirID is equal to "") then set kdeDirMessage to (kdeDir & return & " is owned by " & kdedirID & return & return)
97        if (not qtdirID is equal to "") then set qtDirMessage to (qtDir & return & " is owned by " & qtdirID & return & return)
98        if (not ICEauthorityID is equal to "") then set ICEauthorityMessage to (ICEauthority & return & " is owned by " & ICEauthorityID & return & return)
99        if (not XauthorityID is equal to "") then set XauthorityMessage to (Xauthority & return & " is owned by " & XauthorityID & return & return)
100       
101        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)
102       
103        if fixPermissions = "Fix" then
104               
105                if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges
106                if (not qtdirID is equal to "") then do shell script "chown -R " & userID & " " & qtDir with administrator privileges
107                if (not ICEauthorityID is equal to "") then do shell script "chown " & userID & " " & ICEauthority with administrator privileges
108                if (not XauthorityID is equal to "") then do shell script "chown " & userID & " " & Xauthority with administrator privileges
109               
110        end if
111       
112end if
113
114
115set command to "sh -l -c " & (POSIX path of kmymoney) & " > /dev/null 2>&1"
116
117try
118       
119        do shell script command
120       
121on error
122       
123        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
124       
125end try
Note: See TracBrowser for help on using the repository browser.