Ticket #24433: main.applescript

File main.applescript, 1.8 KB (added by mkae (Marko Käning), 15 years ago)

Apple script being main component of KMyMoney.app

Line 
1try
2       
3        set userID to do shell script "stat -f '%Su' $HOME"
4       
5end try
6
7set kdedirID to ""
8set ICEauthorityID to ""
9set XauthorityID to ""
10
11set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string)
12set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string)
13set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string)
14
15set kdeDirMessage to ""
16
17try
18       
19        POSIX file kdeDir as alias
20        set kdedirID to do shell script "stat -f '%Su' $HOME/.kde"
21       
22end try
23
24try
25       
26        POSIX file ICEauthority as alias
27        set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority"
28       
29end try
30
31try
32       
33        POSIX file Xauthority as alias
34        set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority"
35       
36end try
37
38if ((not kdedirID is equal to "") and not kdedirID = userID) or not ICEauthorityID = userID or not XauthorityID = userID then
39       
40        if (not kdedirID is equal to "") then set kdeDirMessage to (kdeDir & return & " is owned by " & kdedirID & return & return)
41       
42        set fixPermissions to button returned of Â
43                (display dialog (kdeDirMessage Â
44                        & ICEauthority & return & " is owned by " & ICEauthorityID & return & return Â
45                        & Xauthority & return & " is owned by " & XauthorityID & return & return Â
46                        & "They should be owned by " & userID & " for KMyMoney to run properly!") buttons {"Cancel", "Fix"} default button {"Fix"} with icon 2)
47       
48        if fixPermissions = "Fix" then
49               
50                if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges
51                do shell script "chown " & userID & " " & ICEauthority with administrator privileges
52                do shell script "chown " & userID & " " & Xauthority with administrator privileges
53               
54        end if
55       
56end if
57
58set results to do shell script "cd ~; PATH=$PATH:/opt/local/bin; export PATH; source .profile; /opt/local/bin/kmymoney > /dev/null 2>&1 &"