Enhance LockScreen
This commit is contained in:
1 parent
746d6df1c8
commit
1f9f25c2c4
2 files changed
+26
-12
No files matched your search
@@ -1,7 +1,14 @@
|
|||||||
import gi, pam, fabric
|
import gi, pam
|
||||||
|
|
||||||
|
gi.require_version("Gdk", "3.0")
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
|
||||||
|
|
||||||
gi.require_version("GtkSessionLock", "0.1")
|
gi.require_version("GtkSessionLock", "0.1")
|
||||||
from gi.repository import Gdk, GtkSessionLock
|
from gi.repository import (
|
||||||
|
Gdk, # pyright: ignore[reportMissingModuleSource]
|
||||||
|
GtkSessionLock, # pyright: ignore[reportAttributeAccessIssue]
|
||||||
|
)
|
||||||
|
|
||||||
from fabric.widgets.window import Window
|
from fabric.widgets.window import Window
|
||||||
|
|
||||||
@@ -30,8 +37,8 @@ class IndicatorBox(Box):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
h_align="end",
|
h_align="end",
|
||||||
name="indicatorbox",
|
name="indicator-box",
|
||||||
spacing=5,
|
spacing=9,
|
||||||
h_expand=True,
|
h_expand=True,
|
||||||
children=[
|
children=[
|
||||||
BatteryIndicator(show_window=False),
|
BatteryIndicator(show_window=False),
|
||||||
@@ -50,7 +57,7 @@ class ContentBox(CenterBox):
|
|||||||
v_align="center",
|
v_align="center",
|
||||||
visible=False,
|
visible=False,
|
||||||
password=True,
|
password=True,
|
||||||
# on_activate=on_activate,
|
on_activate=on_activate,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.password_entry.set_property("xalign", 0.5)
|
self.password_entry.set_property("xalign", 0.5)
|
||||||
@@ -92,7 +99,7 @@ class ContentBox(CenterBox):
|
|||||||
children=[
|
children=[
|
||||||
Image(
|
Image(
|
||||||
name="face-icon",
|
name="face-icon",
|
||||||
image_file="/home/saumya/.face.icon",
|
image_file=os.path.expanduser("~/.face.icon"),
|
||||||
size=64,
|
size=64,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -131,7 +138,7 @@ class LockScreen(Window):
|
|||||||
self.content = ContentBox(self.on_activate)
|
self.content = ContentBox(self.on_activate)
|
||||||
super().__init__(
|
super().__init__(
|
||||||
title="lock",
|
title="lock",
|
||||||
visible=True,
|
visible=False,
|
||||||
all_visible=False,
|
all_visible=False,
|
||||||
name="lockscreen-bg",
|
name="lockscreen-bg",
|
||||||
anchor="center",
|
anchor="center",
|
||||||
@@ -183,9 +190,12 @@ class LockScreen(Window):
|
|||||||
|
|
||||||
def on_activate(self, entry: Entry, *args):
|
def on_activate(self, entry: Entry, *args):
|
||||||
if not pam.authenticate(getpass.getuser(), (entry.get_text() or "").strip()):
|
if not pam.authenticate(getpass.getuser(), (entry.get_text() or "").strip()):
|
||||||
|
entry.set_text("")
|
||||||
|
entry.set_placeholder_text("Wrong Password")
|
||||||
return
|
return
|
||||||
self.lock.unlock_and_destroy()
|
self.lock.unlock_and_destroy()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
GLib.idle_add(app.quit) # schedules quit after unlock
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
def initialize():
|
||||||
@@ -194,15 +204,15 @@ def initialize():
|
|||||||
lockscreen = LockScreen(lock)
|
lockscreen = LockScreen(lock)
|
||||||
lock.new_surface(
|
lock.new_surface(
|
||||||
lockscreen,
|
lockscreen,
|
||||||
Gdk.Display.get_default().get_monitor(
|
Gdk.Display.get_default().get_monitor( # pyright: ignore[reportAttributeAccessIssue, reportOptionalMemberAccess]
|
||||||
0
|
0
|
||||||
), # pyright: ignore[reportAttributeAccessIssue, reportOptionalMemberAccess]
|
),
|
||||||
)
|
)
|
||||||
lockscreen.show_all()
|
lockscreen.show()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# initialize()
|
initialize()
|
||||||
lockscreen = LockScreen(GtkSessionLock.Lock())
|
lockscreen = LockScreen(GtkSessionLock.Lock())
|
||||||
|
|
||||||
app = Application("lock", lockscreen)
|
app = Application("lock", lockscreen)
|
||||||
|
|||||||
+5
-1
@@ -1,6 +1,10 @@
|
|||||||
#lockscreen-bg {
|
#lockscreen-bg {
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
#indicator-box {
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
#container-box {
|
#container-box {
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
min-width: 250px;
|
min-width: 250px;
|
||||||
@@ -42,7 +46,7 @@
|
|||||||
font-family: "SF Pro Rounded ";
|
font-family: "SF Pro Rounded ";
|
||||||
border: none;
|
border: none;
|
||||||
/* font-family: "SF Pro Rounded"; */
|
/* font-family: "SF Pro Rounded"; */
|
||||||
font-size: 130px;
|
font-size: 120px;
|
||||||
margin-top: -20px;
|
margin-top: -20px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user