Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit c153f0e

Browse files
committed
MacDialog chnages like Linux
1 parent fe75817 commit c153f0e

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

core/Recorder.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22
class Recorder {
33

4-
const PID_FILE = '/run/lock/TaskTimeTerminate';
4+
const PID_FILE_LINUX = '/run/lock/TaskTimeTerminate';
5+
const PID_FILE_MAC = '/private/tmp/TaskTimeTerminate';
56

67
public Dialog $dialog;
78

@@ -95,27 +96,28 @@ private function recordNew(JSONReader $r) : void {
9596
}
9697

9798
public static function runOnlyOnce() : void {
98-
if( Utilities::getOS() === Utilities::OS_LINUX ){
99+
if( Utilities::getOS() === Utilities::OS_LINUX || Utilities::getOS() === Utilities::OS_MAC ){
100+
$osPidFile = Utilities::getOS() === Utilities::OS_LINUX ? self::PID_FILE_LINUX : self::PID_FILE_MAC;
99101
$pid = getmypid();
100102
if( $pid !== false ){
101103
// check if other running
102-
if( is_file( self::PID_FILE ) ){
103-
$otherPid = file_get_contents(self::PID_FILE);
104+
if( is_file( $osPidFile ) ){
105+
$otherPid = file_get_contents($osPidFile);
104106
if( is_numeric($otherPid) ){
105107
if( !posix_kill( intval($otherPid), SIGQUIT ) ){
106108
posix_kill( intval($otherPid), SIGKILL );
107109
}
108110
}
109111
}
110112
// set yourself running
111-
file_put_contents( self::PID_FILE, $pid, LOCK_EX );
113+
file_put_contents( $osPidFile, $pid, LOCK_EX );
112114

113115
// delete run file on exit
114-
register_shutdown_function( function ($pid) {
115-
if( is_file( self::PID_FILE ) && file_get_contents(self::PID_FILE) == $pid ){
116-
unlink(self::PID_FILE);
116+
register_shutdown_function( function ($pid, $osPidFile) {
117+
if( is_file( $osPidFile ) && file_get_contents($osPidFile) == $pid ){
118+
unlink($osPidFile);
117119
}
118-
}, $pid);
120+
}, $pid, $osPidFile);
119121
}
120122
}
121123
}

core/Utilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
class Utilities {
66

7-
const VERSION = 'v0.8.1 alpha';
7+
const VERSION = 'v0.8.2 alpha';
88

99
/**
1010
* OS Consts

core/platform/MacDialog.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ public function open() : void {
1010
'-cats',
1111
'"'. implode(',', $this->categories) .'"'
1212
);
13-
exec(implode(' ', $cmd), $stdout, $return);
13+
$handle = popen(implode(' ', $cmd), 'r');
14+
$stdout = fgets($handle);
15+
pclose($handle);
1416

15-
if( $return === 0 && !empty($stdout) ){
16-
$stdout = json_decode($stdout[0], true);
17+
if( !empty($stdout) ){
18+
$stdout = json_decode(trim($stdout), true);
1719

1820
if( $stdout['pause'] ){
1921
$this->shortBreak = true;
Binary file not shown.

core/platform/macos/TaskTimeTerminate.app/Contents/_CodeSignature/CodeResources

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
<dict>
77
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
88
<data>
9-
DiSUbmXvQvqY7x2/oE96H2NEtUw=
9+
e18yfL9mWFXba/Nk6jOoFUizYxU=
1010
</data>
1111
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
1212
<data>
13-
IQsFH80gY6fBchH0ef9VMMLdZUk=
13+
tKB3zm0oh092IIKVC3Griz18ELI=
1414
</data>
1515
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
1616
<data>
17-
f+UKI1tIL0DBtbFgZJg1asfp4pY=
17+
m4BjeFcFksMYrmZcmCXz+4nzRFI=
1818
</data>
1919
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
2020
<data>
21-
RQhhd8f6VNGPeZ//rXqtwUIL+Jo=
21+
ait94q3Y199A/Y3/71T9WhYNvaQ=
2222
</data>
2323
<key>Resources/en.lproj/Main.strings</key>
2424
<dict>
@@ -36,28 +36,28 @@
3636
<dict>
3737
<key>hash2</key>
3838
<data>
39-
fdTh9cwTl5YcU1c3bL4sqi1dUzrpHagjFZzlRzmAv7s=
39+
qugeW59zcSFxOuxVdS9d7wiuOmkgOkyELumX0/qY7qs=
4040
</data>
4141
</dict>
4242
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
4343
<dict>
4444
<key>hash2</key>
4545
<data>
46-
2sHlhd/y5zaoN304U/77mvq4CKxgomuu3ZmquXYFMZ8=
46+
HhsQHpomDddTuX/KNf9U3lCGB6JTz6JyJvVT17jf534=
4747
</data>
4848
</dict>
4949
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
5050
<dict>
5151
<key>hash2</key>
5252
<data>
53-
w2aeIh12aIFgj58/49oNDNHmnQLt1r4ysmnx8sQ8dJI=
53+
0gI4orTZXo+QU82I7RhehE/rTe1r3ql3zp8AIg8xy4w=
5454
</data>
5555
</dict>
5656
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
5757
<dict>
5858
<key>hash2</key>
5959
<data>
60-
6QebTVxtaLwhGPCIsNq8mM2tb4VwOe0KFKestIphND0=
60+
WNUjdwKoG+2YblGRy/ULWQxgeN4ihtPFQw06ciX0DQo=
6161
</data>
6262
</dict>
6363
<key>Resources/en.lproj/Main.strings</key>

core/platform/macos/TaskTimeTerminate/TaskTimeTerminate/AppDelegate.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,4 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1616

1717
func applicationWillTerminate(_ aNotification: Notification) {
1818
}
19-
20-
private func tapplicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
21-
return true;
22-
}
23-
24-
func windowShouldClose(_ sender: Any) {
25-
NSApplication.shared.terminate(self)
26-
}
2719
}

0 commit comments

Comments
 (0)