diff --git a/lock/bash.sh b/lock/bash.sh new file mode 100755 index 0000000..f746983 --- /dev/null +++ b/lock/bash.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +while true; do + inotifywait -e close_write main.css + fabric-cli exec lock 'app.set_css()' +done + + diff --git a/lock/lock.py b/lock/lock.py new file mode 100644 index 0000000..4701754 --- /dev/null +++ b/lock/lock.py @@ -0,0 +1,92 @@ +import gi, pam, fabric + +gi.require_version("GtkSessionLock", "0.1") +from gi.repository import Gdk, GtkSessionLock + +from fabric.widgets.window import Window + +# from widgets.wayland import WaylandWindow as Window +from fabric.widgets.entry import Entry +from fabric.widgets.datetime import DateTime +from fabric.widgets.box import Box +from fabric.widgets.centerbox import CenterBox +from fabric import Application + +from fabric.utils import get_relative_path + + +class ContentBox(CenterBox): + def __init__(self, *args, **kwargs): + super().__init__( + name="content-box", + h_expand=True, + orientation="vertical", + v_expand=True, + start_children=[ + DateTime( + formatters=["%A. %d %B"], + interval=10000, + h_expand=False, + v_align="start", + v_expand=False, + name="date", + ), + DateTime(formatters=["%I:%M"], name="clock"), + ], + end_children=[ + Entry( + placeholder="gib password", + name="password-entry", + h_align="center", + v_align="end", + password=True, + on_activate=on_activate(self), + ), + ], + **kwargs + ) + + +class LockScreen(Window): + def __init__(self, lock: GtkSessionLock.Lock): + self.lock = lock + super().__init__( + title="lock", + visible=True, + all_visible=False, + name="lockscreen-bg", + anchor="center", + child=ContentBox(), + ) + + def on_activate(self, entry: Entry, *args): + if entry.get_text() == "help": + pass + elif not pam.authenticate("saumya", (entry.get_text() or "").strip()): + return + self.lock.unlock_and_destroy() + self.destroy() + + +def initialize(): + lock = GtkSessionLock.prepare_lock() + lock.lock_lock() + lockscreen = LockScreen(lock) + lock.new_surface(lockscreen, Gdk.Display.get_default().get_monitor(0)) + lockscreen.show_all() + + +if __name__ == "__main__": + initialize() + lock = LockScreen(GtkSessionLock.Lock()) + app = Application("lock", lock) + + def set_css(): + app.set_stylesheet_from_file( + get_relative_path("main.css"), + ) + + app.set_css = set_css + + app.set_css() + app.run() diff --git a/lock/main.css b/lock/main.css new file mode 100644 index 0000000..4950242 --- /dev/null +++ b/lock/main.css @@ -0,0 +1,37 @@ +/* album_cover.set_style(f"background-image:url('{fallback_cover_path}')") */ +#lockscreen-bg { + /* background-color: rgba(225, 225, 225, 0.9); */ + background-image: url("/home/saumya/.current.wall"); + background-size: cover; +} +* { + all: unset; + font-family: "SF Pro Rounded"; +} +#password-entry { + background-color: white; + border-radius: 20px; + min-width: 300px; + color: black; + min-height: 50px; + font-size: 20px; + margin-bottom: 80px; + font-weight: bold; +} + +#date { + background-color: transparent; + color: alpha(#fff, 0.5); + border: none; + font-size: 50px; + margin-top: 80px; + font-weight: bold; +} +#clock { + background-color: transparent; + color: alpha(#fff, 0.5); + border: none; + font-size: 150px; + margin-top: -20px; + font-weight: bold; +} diff --git a/modules/osd.py b/modules/osd.py index a39cd1d..4539690 100644 --- a/modules/osd.py +++ b/modules/osd.py @@ -413,7 +413,7 @@ class OSD(Window): super().__init__( layer="overlay", anchor="bottom", - title="modus", + title="modus-osd", child=self.main_box, visible=False, pass_through=True,