Skip to content

Commit

Permalink
Add support for color picker notifications on Linux
Browse files Browse the repository at this point in the history
Added support for displaying color picker notifications on Linux using `notify-send` in notification.py
  • Loading branch information
Lenochxd committed Dec 18, 2024
1 parent f7e16b6 commit 86bd2cb
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions app/buttons/color_picker/notification.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from sys import platform
if platform == 'win32':
from app.utils.platform import is_windows, is_linux
from app.utils.working_dir import get_base_dir
from app.utils.logger import log

import subprocess
import os
if is_windows:
from win10toast import ToastNotifier
toaster = ToastNotifier()


def toast(display_type, typestocopy, color_names_final):
if platform != 'win32':
return

icon = "static\\icons\\icon.ico"
duration = 5
message = ""
Expand All @@ -26,6 +30,23 @@ def toast(display_type, typestocopy, color_names_final):
)

title = "WebDeck Color Picker"
toaster.show_toast(
title, message, icon_path=icon, duration=duration, threaded=True
)

if is_windows:
toaster.show_toast(
title, message, icon_path=icon, duration=duration, threaded=True
)
return

elif is_linux:
icon_path = os.path.join(get_base_dir(), icon.replace('.ico', '.png'))
log.debug(f"Icon path: {icon_path}")
subprocess.Popen([
'notify-send',
title,
message,
'-a', title,
'-i', icon_path,
'-u', 'normal',
# '-t', str(duration * 1000),
])
return

0 comments on commit 86bd2cb

Please sign in to comment.