Skip to content

Commit

Permalink
Fixup layout for PP. Update screenshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dejvino committed Feb 6, 2022
1 parent d9832dc commit 170bbf4
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 124 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ git clone https://github.com/Dejvino/birdie.git
cd birdie
# on Mobian/Debian:
sudo apt install gcc make checkinstall python3-pip
sudo apt install gcc make checkinstall python3-psutil python3-pip
sudo pip install mpris-server
sudo make install-deb
Expand Down
229 changes: 114 additions & 115 deletions app.ui

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions birdie
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import gi # Debian package: python3-gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio, GLib # Debian package: gir1.2-glib-2.0, gir1.2-gtk-3.0
import os, sys, signal
import psutil # Debian package: python3-psutil
from subprocess import Popen, PIPE
from pathlib import Path

Expand All @@ -27,7 +28,8 @@ SET_USER_ALARM_COMMAND_LOCAL = "./set-user-alarm"
SET_USER_ALARM_COMMAND_GLOBAL = f"/usr/lib/{APP_NAME}/libexec/set-user-alarm"
INHIBIT_COMMAND_PREFIX = ["/usr/bin/gnome-session-inhibit", "--inhibit", "suspend,logout,idle"]
ALARM_SOUND_COMMAND = [f"/usr/lib/{APP_NAME}/libexec/play-alarm-sound"]
USE_MPRIS = True # requires mpris_server
USE_MPRIS = True # requires mpris_server module, gets checked on module load
USE_INHIBIT = True # requires session manager support, gets checked on startup

dummy_time = "0000-01-01 00:00:00"
MSG_START = "Pick a time and day for waking up."
Expand All @@ -36,6 +38,7 @@ MSG_WAKE_UP = "<span color='orange'>Wake up!</span>"
MSG_SET_ALARM_ERROR = "<span color='red'>Error issuing alarm, check console.</span>"
MSG_PLAY_ALARM_ERROR = "<span color='red'>Error playing alarm, check console.</span>"
MSG_NO_TIME_LEFT = "No time left"
MSG_SCHEDULING_ALARM = "<span color='gray'>Scheduling alarm...</span>"

def showErrorDialog(text, title=None, parent=None):
dialog = Gtk.MessageDialog(
Expand Down Expand Up @@ -98,6 +101,7 @@ class AlarmApp(Gtk.Application):
self.setwakebutton = self.builder.get_object("setwake")
self.cancelbutton = self.builder.get_object("cancel")
self.snoozebutton = self.builder.get_object("snooze")
self.update_layout()
self.window.show_all()
try:
with open(user_folder + "/wake-up.timer", "r") as f:
Expand Down Expand Up @@ -150,22 +154,23 @@ class AlarmApp(Gtk.Application):
self.disable_elements(False)
self.errorlabel.set_label(MSG_START)
self.gen_user_timer(dummy_time)
print("Disabling alarm service")
check_output(["systemctl", "--user", "daemon-reload"]) # Debian package: systemd
check_output(["systemctl", "--user", "disable", "--now", "wake-up.timer"])
check_output(["set-user-alarm"])
self.run_set_user_alarm()
self.update()

def set_alarm(self, rewrite=True):
self.alarm_set = True
self.window.set_sensitive(False)
self.disable_elements(True)
self.errorlabel.set_markup(MSG_SCHEDULING_ALARM)
# TODO: spawn as async task
print("Enabling alarm service")
try:
if rewrite:
time_var = self.alarmtime.format("%Y-%m-%d %H:%M:%S")
if os.path.isfile(SET_USER_ALARM_COMMAND_LOCAL):
check_output([SET_USER_ALARM_COMMAND_LOCAL, time_var])
else:
check_output([SET_USER_ALARM_COMMAND_GLOBAL, time_var])
self.run_set_user_alarm([time_var])
self.gen_user_service()
self.gen_user_timer(time_var)
self.load_user_timer()
Expand All @@ -185,6 +190,12 @@ class AlarmApp(Gtk.Application):
self.minute.set_value(self.alarmtime.get_minute())
#self.second.set_value(self.alarmtime.get_second())

def run_set_user_alarm(self, params=[]):
if os.path.isfile(SET_USER_ALARM_COMMAND_LOCAL):
check_output([SET_USER_ALARM_COMMAND_LOCAL] + params)
else:
check_output([SET_USER_ALARM_COMMAND_GLOBAL] + params)

def do_snooze(self, snooze_time):
self.set_alarm_time(GLib.DateTime.new_now_local().add_minutes(snooze_time))
self.end_alarm()
Expand All @@ -199,7 +210,6 @@ class AlarmApp(Gtk.Application):
def snooze_clicked(self, button):
self.do_snooze_short()


def time_changed_text(self, input):
# read uncommitted value?
pass
Expand Down Expand Up @@ -258,6 +268,9 @@ class AlarmApp(Gtk.Application):
if self.alarm_proc != 0:
try:
print("Terminating alarm sound app")
children = psutil.Process(pid=self.alarm_proc.pid).children(recursive=True)
for child in children:
os.kill(child.pid, signal.SIGTERM)
self.alarm_proc.terminate()
self.errorlabel.set_label(MSG_START)
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mpris_server==0.2.16
psutil==5.9.0
6 changes: 5 additions & 1 deletion screenshots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Simple initial screen: set the time, enable, done!

![default](default.png)

Both portrait and landscape layouts are supported.

![landscape](landscape.png)

## Alarm Set and Waiting
Alarm is scheduled, settings are locked. Countdown to the alarm is shown.

Expand All @@ -23,7 +27,7 @@ Alarm can be stopped or snoozed directly from the lock screen, no need to log in
![lockscreen](lockscreen.png)

## Customization
Select different days, change the maximum alarm volume.
Select different days, change the maximum alarm volume, test how it sounds.

![setup](setup.png)

Binary file modified screenshots/alarm_ringing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/alarm_set.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 170bbf4

Please sign in to comment.