Skip to content

Commit

Permalink
use dbus-next and desktop-notifier instead of notify2, removing libdb…
Browse files Browse the repository at this point in the history
…us dependency
  • Loading branch information
bluppfisk committed Jun 20, 2023
1 parent 021f58a commit 6793bf1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ StartupNotify=false
Path=${args[0]}/venv/bin
Exec=coindicator
Icon=/tmp/logo_248px.png
X-GNOME-UsesNotifications=true
EOL

cp ./src/coin/resources/logo_248px.png /tmp
Expand Down
14 changes: 10 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@
#
# pip-compile
#
certifi>=2022.12.7
certifi==2023.5.7
# via
# coindicator (setup.py)
# requests
chardet==3.0.4
# via coindicator (setup.py)
charset-normalizer==3.1.0
# via requests
dbus-next==0.2.3
# via desktop-notifier
desktop-notifier==3.5.3
# via coindicator (setup.py)
idna==2.10
# via
# coindicator (setup.py)
# requests
notify2==0.3.1
# via coindicator (setup.py)
packaging==23.1
# via desktop-notifier
pycairo==1.24.0
# via pygobject
pygame==2.1.3
# via coindicator (setup.py)
pygobject==3.42.2
pygobject==3.44.1
# via coindicator (setup.py)
pyyaml==6.0
# via coindicator (setup.py)
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ install_requires=
certifi>=2022.12.7
chardet~=3.0.4
idna~=2.7
notify2~=0.3.1
desktop-notifier~=3.5.3
PyYAML>=4.2b1
requests~=2.20
urllib3~=1.26.5
pygame~=2.1.2
PyGObject~=3.42.2
PyGObject~=3.44.1

[options.packages.find]
where =
Expand Down
27 changes: 13 additions & 14 deletions src/coin/alarm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lets the user set an alert for a certain price point

import notify2
import desktop_notifier
import pygame

from coin.config import Config
Expand Down Expand Up @@ -67,20 +67,19 @@ def __notify(self, price, direction, threshold):
+ str(threshold)
)

if notify2.init(self.app_name):
if pygame.init():
pygame.mixer.music.load(
self.config["project_root"] / "resources/ca-ching.wav"
)
pygame.mixer.music.play()
logo = GdkPixbuf.Pixbuf.new_from_file(
str(self.config["project_root"] / "resources/icon_32px.png")
if pygame.init():
pygame.mixer.music.load(
self.config["project_root"] / "resources/ca-ching.wav"
)

n = notify2.Notification(title, message)
n.set_icon_from_pixbuf(logo)
n.set_urgency(2) # highest
n.show()
pygame.mixer.music.play()

notifier = desktop_notifier.DesktopNotifier(app_name=self.config["app"]["name"])
notifier.send_sync(
title,
message,
urgency=desktop_notifier.Urgency.Critical,
icon=str(self.config["project_root"] / "resources/icon_32px.png"),
)


class AlarmSettingsWindow(Gtk.Window):
Expand Down
19 changes: 9 additions & 10 deletions src/coin/coin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import signal
from pathlib import Path

import notify2
import desktop_notifier
import yaml
from gi.repository import Gtk

Expand Down Expand Up @@ -294,15 +294,14 @@ def update_assets(self):
self.discoveries = 0
self._load_assets()

if notify2.init(self.config.get("app").get("name")):
n = notify2.Notification(
self.config.get("app").get("name"),
"Finished discovering new assets",
str(self.icon),
)
n.set_urgency(1)
n.timeout = 2000
n.show()
notifier = desktop_notifier.DesktopNotifier(app_name=self.config["app"]["name"])
notifier.send_sync(
self.config.get("app").get("name"),
"Finished discovering new assets",
urgency=desktop_notifier.Urgency.Normal,
timeout=2000,
icon=self.icon,
)

self.main_item.set_icon_full(str(self.icon), "App icon")

Expand Down

0 comments on commit 6793bf1

Please sign in to comment.