Skip to content

Commit

Permalink
Save notification images to /tmp/lnxlink folder
Browse files Browse the repository at this point in the history
  • Loading branch information
bkbilly committed Aug 7, 2024
1 parent 78d0a28 commit 0e52431
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion io.github.bkbilly.lnxlink.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<component type="console-application">
<content_rating type="oars-1.0" />
<id>io.github.bkbilly.lnxlink</id>
<name>LNXlink</name>
<name>LNXlink</name>

<metadata_license>MIT</metadata_license>
<project_license>MIT</project_license>
Expand Down
7 changes: 5 additions & 2 deletions lnxlink/modules/notify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Shows notifications"""
import os
import logging
import tempfile
import requests
Expand Down Expand Up @@ -33,10 +34,12 @@ def start_control(self, topic, data):
sound_url = data.get("sound")
icon_path = icon_url
sound_path = sound_url
if not os.path.exists("/tmp/lnxlink"):
os.makedirs("/tmp/lnxlink")
if icon_url is not None and icon_url.startswith("http"):
try:
with tempfile.NamedTemporaryFile(
prefix="lnxlink_icon_", delete=False
prefix="lnxlink_icon_", delete=False, dir="/tmp/lnxlink"
) as icon_file:
img_data = requests.get(icon_url, timeout=3).content
icon_file.write(img_data)
Expand All @@ -46,7 +49,7 @@ def start_control(self, topic, data):
if sound_url is not None and sound_url.startswith("http"):
try:
with tempfile.NamedTemporaryFile(
prefix="lnxlink_sound_", delete=False
prefix="lnxlink_sound_", delete=False, dir="/tmp/lnxlink"
) as sound_file:
sound_data = requests.get(sound_url, timeout=3).content
sound_file.write(sound_data)
Expand Down

0 comments on commit 0e52431

Please sign in to comment.