-VERSION=-0
+VERSION=-1
-JAVAFX_HOME=/usr/lib64/javafx-sdk-13
+JAVAFX_HOME=/usr/local/javafx-sdk-15
+JAVA_HOME=/usr/local/jdk-15
CFLAGS=-Wall -Wno-parentheses
CPPFLAGS=
rm -rf bin
install: bin/notzed.busyalert.jar bin/busymon
- sed -e 's,@JAVAFX_HOME@,$(JAVAFX_HOME),g' \
- -e 's,@MODULE_DIR@,$(DESTDIR)$(prefix)/share/notzed.busyalert,g' \
+ sed -e 's,@JAVA_HOME@,$(JAVA_HOME),g' \
+ -e 's,@JAVAFX_HOME@,$(JAVAFX_HOME),g' \
+ -e 's,@MODULE_DIR@,$(prefix)/share/notzed.busyalert,g' \
< src/busyalert.in > bin/busyalert
chmod 755 bin/busyalert
install -D bin/busyalert $(DESTDIR)$(prefix)/share/notzed.busyalert/busyalert
src/busyalert.in src/busymon.c \
$(notzed.busyalert_JAVA) \
contrib
-
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.function.BooleanSupplier;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Insets;
public class BusyAlert extends Application {
long timeout = 60 * 5;
+ Label time = new Label();
+ Instant start = Instant.now();
ScheduledExecutorService queue = Executors.newSingleThreadScheduledExecutor((r) -> {
Thread t = new Thread(r);
});
@Override
- public void start(Stage primaryStage) throws Exception {
- Stage stage = new Stage();
-
- Label time = new Label();
+ public void start(Stage stage) throws Exception {
Label text = new Label("BREAK NOW!");
VBox box = new VBox(text, time);
text.setFont(Font.font("monspaced", 96));
- Instant start = Instant.now();
-
Scene scene = new Scene(box);
stage.setFullScreen(true);
stage.show();
- queueForever(() -> {
- Duration delta = Duration.between(start, Instant.now());
- long waited = delta.get(ChronoUnit.SECONDS);
- long left = timeout - waited;
-
- time.setText(String.format("%3d:%02d", left / 60, left % 60));
- });
-
- queue.schedule(() -> Platform.runLater(stage::close),
- timeout, TimeUnit.SECONDS);
- }
-
- void queueForever(Runnable r) {
- queue.schedule(() -> {
- Platform.runLater(r);
- queueForever(r);
- },
- 1, TimeUnit.SECONDS
- );
+ update();
}
void update() {
+ Duration delta = Duration.between(start, Instant.now());
+ long waited = delta.get(ChronoUnit.SECONDS);
+ long left = timeout - waited;
+
+ if (left >= 0) {
+ Platform.runLater(() -> time.setText(String.format("%3d:%02d", left / 60, left % 60)));
+ queue.schedule(this::update, 1, TimeUnit.SECONDS);
+ } else {
+ Platform.exit();
+ }
}
public static void main(String[] args) {