Skip to content

Commit

Permalink
blur background added (default disabled)
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Nov 20, 2024
1 parent 7a9f25e commit 632b0d6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
3 changes: 1 addition & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Depends: ${misc:Depends},
gir1.2-vte-2.91,
python3-pil,
python3-xlib,
numlockx,
python3-gi-cairo
numlockx
Description: Pardus Greeter
Pardus greeter for lightdm login screen
2 changes: 2 additions & 0 deletions src/data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#logo=
#block-gui-timeout=10
#background=user
#background-blur=false
#background-blur-level=15
#background-update-interval=0

[screen]
Expand Down
43 changes: 43 additions & 0 deletions src/module/blur.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
blur_available = True
try:
from PIL import Image, ImageFilter
except:
blur_available = False

if blur_available and get("background-blur", False, "gtkwindow"):
mode="RGB"
def pixbuf2image(pix):
"""Convert gdkpixbuf to PIL image"""
global mode
data = pix.get_pixels()
w = pix.props.width
h = pix.props.height
stride = pix.props.rowstride
mode="RGB"
if pix.props.has_alpha == True:
mode = "RGBA"
im = Image.frombytes(mode, (w, h), data, "raw", mode, stride)
return im

def image2pixbuf(im):
"""Convert Pillow image to GdkPixbuf"""
data = im.tobytes()
w, h = im.size
data = GLib.Bytes.new(data)
pix = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,
(mode=="RGBA"), 8, w, h, w * len(mode))
return pix

def blur_draw(px):
if px:
im = pixbuf2image(px)
im = im.filter(ImageFilter.GaussianBlur( int(get("background-blur-level","15","gtkwindow")) ))
px = image2pixbuf(im)
return px

def module_init():
loginwindow.background_handler = blur_draw
loginwindow.update_user_background()
else:
def module_init():
return
7 changes: 7 additions & 0 deletions src/module/gtkwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def __init_variables(self):
self.height = -1
self.background_pixbuf = None
self.ignore_password_cache = False
self.background_handler = None


def o(self, name=None):
return self.builder.get_object(name)
Expand Down Expand Up @@ -349,6 +351,11 @@ def set_background(self, bg=None):
self.background_pixbuf = px
except Exception as e:
print(str(e))
if self.background_handler != None:
self.background_pixbuf = self.background_handler(self.background_pixbuf)
self.draw_background()

def draw_background(self):
if self.image_status:
self.o("ui_image_2").set_from_pixbuf(self.background_pixbuf)
self.o("ui_stack_image").set_visible_child_name("image2")
Expand Down
21 changes: 21 additions & 0 deletions src/module/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,27 @@ def button_event(widget):
xkb_buttons[layout+":"+variant].connect("clicked", button_event)
return xkb_buttons

def enable_numlock():
# Connect to the X server
d = display.Display()
root = d.screen().root

# Get the current state of the keyboard
keymap = root.get_keyboard_mapping()

# Define the Num Lock keycode (usually 77, but can vary)
num_lock_keycode = 77

# Check if Num Lock is already enabled
num_lock_state = (keymap[num_lock_keycode] & 1) != 0

if not num_lock_state:
# Send a key press and release event for Num Lock
root.grab_key(num_lock_keycode, 0, X.GrabModeAsync, X.GrabModeAsync)
root.send_event(request.KeyPress(keycode=num_lock_keycode))
root.send_event(request.KeyRelease(keycode=num_lock_keycode))
d.flush()


def module_init():
if get("numlock-on", True, "keyboard"):
Expand Down

0 comments on commit 632b0d6

Please sign in to comment.