Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versions follo

## [Unreleased]

### Added
- **Press duration per key**, e.g. for games: hold the shortcut for a fixed time (`hold`, in
seconds) or as long as the deck key is pressed (`hold_while_pressed`). Set it in the editor
under *Key press*; such keys show a small marker. Several keys can be held at the same time,
and held keys are released when the deck is paused or disconnected.

## [0.3.1] – 2026-11-08

### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ shortcut is sent – matching your keyboard layout.
plugged into a monitor works the same with whichever computer is connected.
- **Profile editor** with live preview on the device, shortcut recording, built-in key
symbols and profile import/export.
- **Press duration per key** – a short tap, a fixed time or held as long as the deck key is
pressed, e.g. for games.
- **App icon across the deck** – flashes up on a switch, then shines through the keys.
- **Linux, macOS and Windows**, **English and German** (more welcome).

Expand Down
87 changes: 63 additions & 24 deletions dailydeck/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from StreamDeck.Transport.Transport import TransportError

from .appicons import find_app_icon
from .config import Config, ConfigError, Profile, active_config_path, load_config, local_path
from .config import Button, Config, ConfigError, Profile, active_config_path, load_config, local_path
from .focus import FocusUnavailable, WindowInfo, create_focus_provider
from .i18n import _
from .keys import KeySender, create_key_sender, format_shortcut
Expand Down Expand Up @@ -44,6 +44,7 @@ def __init__(self, deck, sender: KeySender, config: Config):
self._saved_config: Config | None = None # real config while previewing
self._lock = threading.RLock()
self._jobs: queue.Queue = queue.Queue()
self._held: dict[int, list] = {} # deck key -> keys held for "hold while pressed"
self._key_size = deck.key_image_format()["size"]
self._rows, self._cols = deck.key_layout()

Expand Down Expand Up @@ -129,6 +130,8 @@ def set_paused(self, paused: bool) -> None:
return
self.paused = paused
self._generation += 1 # cancel a running flash
if paused:
self._release_held()
self._apply_brightness()
if not paused:
self._draw_all()
Expand Down Expand Up @@ -186,40 +189,76 @@ def _set_image(self, key: int, image) -> None:
# --- input -------------------------------------------------------------

def _on_key(self, deck, key: int, pressed: bool) -> None:
# called from the deck's reader thread, one event after the other
with self._lock:
if self.paused:
return
slot = self._slots[key] if key < len(self._slots) else None
if slot is None:
return
try:
if isinstance(slot, NavSlot):
if pressed:
self.page += 1
self._generation += 1 # cancel a running flash
self._slots = self._layout()
self._draw_all()
return
if slot.empty:
held = self._held.pop(key, None) if not pressed else None
button = None
if held is None and not self.paused:
slot = self._slots[key] if key < len(self._slots) else None
try:
if isinstance(slot, NavSlot):
if pressed:
self.page += 1
self._generation += 1 # cancel a running flash
self._slots = self._layout()
self._draw_all()
return
if slot is None or slot.empty:
return
self._draw(key, pressed=pressed)
except TransportError:
return
self._draw(key, pressed=pressed)
except TransportError:
if pressed and slot.chords and self.sending:
button = slot
elif held is not None:
try:
self._draw(key)
except TransportError:
pass

# send outside the lock: holding keys takes time
if held is not None:
self.sender.release(held)
elif button is not None:
self._trigger(key, button)

def _trigger(self, key: int, button: Button) -> None:
if button.hold_while_pressed:
try:
held = self.sender.press(button.chords)
except Exception: # noqa: BLE001
log.exception("failed to press %s", format_shortcut(button.chords))
return
if pressed and slot.chords and self.sending:
self._jobs.put(slot)
with self._lock:
self._held[key] = held
elif button.hold > 0:
# its own thread, so a long press does not block other buttons
threading.Thread(target=self._send, args=(button,), daemon=True, name="hold").start()
else:
self._jobs.put(button) # short taps stay in order

def _send(self, button: Button) -> None:
try:
log.debug("send %s (hold %.2fs)", format_shortcut(button.chords), button.hold)
self.sender.send(button.chords, button.hold)
except Exception: # noqa: BLE001 - keep the worker alive
log.exception("failed to send %s", format_shortcut(button.chords))

def _release_held(self) -> None:
with self._lock:
held, self._held = list(self._held.values()), {}
for keys in held:
self.sender.release(keys)

def _worker(self) -> None:
while True:
button = self._jobs.get()
if button is None:
return
try:
log.debug("send %s", format_shortcut(button.chords))
self.sender.send(button.chords)
except Exception: # noqa: BLE001 - keep the worker alive
log.exception("failed to send %s", format_shortcut(button.chords))
self._send(button)

def close(self) -> None:
self._release_held()
self._jobs.put(None)
try:
with self.deck:
Expand Down
15 changes: 15 additions & 0 deletions dailydeck/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .focus import WindowInfo
from .i18n import _, pgettext
from .keys import Chord, ShortcutError, parse_shortcut
from .keys.base import MAX_HOLD

log = logging.getLogger(__name__)

Expand All @@ -30,6 +31,8 @@ class Button:
text_color: str | None = None
icon: Path | None = None
font_size: int | None = None
hold: float = 0.0 # seconds the shortcut stays pressed (0 = short tap)
hold_while_pressed: bool = False # keep it pressed as long as the deck key is down

@property
def empty(self) -> bool:
Expand Down Expand Up @@ -394,14 +397,26 @@ def button_chords(data: dict, platform: str | None = None) -> tuple[Chord, ...]:
return chosen


def button_hold(data: dict) -> tuple[float, bool]:
"""(seconds the shortcut stays pressed, hold while the deck key is pressed)."""
hold = data.get("hold", 0)
if isinstance(hold, bool) or not isinstance(hold, (int, float)) or not 0 <= hold <= MAX_HOLD:
raise ShortcutError(_("hold must be a number of seconds between 0 and {max}, not {value}").format(
max=f"{MAX_HOLD:g}", value=repr(hold)))
return float(hold), bool(data.get("hold_while_pressed", False))


def load_button(data: dict, base_dir: Path) -> Button:
hold, hold_while_pressed = button_hold(data)
return Button(
label=data.get("label", ""),
chords=button_chords(data),
color=data.get("color"),
text_color=data.get("text_color"),
icon=resolve_icon(base_dir, data.get("icon")),
font_size=data.get("font_size") or None,
hold=hold,
hold_while_pressed=hold_while_pressed,
)


Expand Down
3 changes: 3 additions & 0 deletions dailydeck/data/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
# drawn in the text colour, e.g. "symbol:play" (names from
# lucide.dev; the editor shows all of them under "Symbol …")
# font_size maximum font size
# hold seconds the shortcut stays pressed, e.g. 0.8 (default: a short tap)
# hold_while_pressed = true keeps it pressed as long as the deck key is
# held down – for games (sprint, aim, push to talk …)
#
# Profile names and labels are translated into your language when this file
# is created; after that it is yours to edit.
Expand Down
40 changes: 40 additions & 0 deletions dailydeck/data/locale/dailydeck.pot
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ msgstr ""
msgid "cannot read {file}: {error}"
msgstr ""

#: dailydeck/config.py
#, python-brace-format
msgid "hold must be a number of seconds between 0 and {max}, not {value}"
msgstr ""

#: dailydeck/config.py
#, python-brace-format
msgid "profile “{name}”, key {number} (“{label}”): {error}"
Expand Down Expand Up @@ -225,10 +230,22 @@ msgstr ""
msgid "Font size"
msgstr ""

#: dailydeck/gui.py
msgid "For games: how long the keys stay pressed"
msgstr ""

#: dailydeck/gui.py
msgid "Gap between the keys of the device, so the icon looks continuous"
msgstr ""

#: dailydeck/gui.py
msgid "Hold for a fixed time"
msgstr ""

#: dailydeck/gui.py
msgid "Hold while the deck key is pressed"
msgstr ""

#: dailydeck/gui.py
msgid "How long the icon lights up at full brightness after switching apps; 0 = off"
msgstr ""
Expand Down Expand Up @@ -292,6 +309,10 @@ msgstr ""
msgid "Key opacity"
msgstr ""

#: dailydeck/gui.py
msgid "Key press"
msgstr ""

#: dailydeck/gui.py
msgid "Key spacing on the device"
msgstr ""
Expand Down Expand Up @@ -449,6 +470,10 @@ msgstr ""
msgid "Settings …"
msgstr ""

#: dailydeck/gui.py
msgid "Short tap"
msgstr ""

#: dailydeck/gui.py
msgid "Shortcut"
msgstr ""
Expand Down Expand Up @@ -674,6 +699,11 @@ msgstr ""
msgid "unknown modifier “{modifier}” in “{shortcut}”"
msgstr ""

#: dailydeck/layout.py
#, python-brace-format
msgid "{seconds} s"
msgstr ""

#: dailydeck/profile_io.py
msgid "not a Daily Deck profile file"
msgstr ""
Expand Down Expand Up @@ -845,6 +875,11 @@ msgstr ""
msgid "The sync folder {folder} is not reachable or has no configuration yet – using the configuration of this computer."
msgstr ""

#: dailydeck/layout.py
msgctxt "decimal separator"
msgid "."
msgstr ""

#: dailydeck/data/default_config.toml
msgctxt "default config"
msgid "Address"
Expand Down Expand Up @@ -1344,3 +1379,8 @@ msgstr ""
msgctxt "default config"
msgid "Zoom −"
msgstr ""

#: dailydeck/layout.py
msgctxt "key badge"
msgid "hold"
msgstr ""
40 changes: 40 additions & 0 deletions dailydeck/data/locale/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ msgstr "kein Profil"
msgid "cannot read {file}: {error}"
msgstr "{file} lässt sich nicht lesen: {error}"

#: dailydeck/config.py
#, python-brace-format
msgid "hold must be a number of seconds between 0 and {max}, not {value}"
msgstr "hold muss eine Anzahl Sekunden zwischen 0 und {max} sein, nicht {value}"

#: dailydeck/config.py
#, python-brace-format
msgid "profile “{name}”, key {number} (“{label}”): {error}"
Expand Down Expand Up @@ -227,10 +232,22 @@ msgstr "Schriftart"
msgid "Font size"
msgstr "Schriftgröße"

#: dailydeck/gui.py
msgid "For games: how long the keys stay pressed"
msgstr "Für Spiele: wie lange die Tasten gedrückt bleiben"

#: dailydeck/gui.py
msgid "Gap between the keys of the device, so the icon looks continuous"
msgstr "Abstand zwischen den Tasten am Gerät, damit das Icon durchgehend wirkt"

#: dailydeck/gui.py
msgid "Hold for a fixed time"
msgstr "Feste Dauer halten"

#: dailydeck/gui.py
msgid "Hold while the deck key is pressed"
msgstr "Halten, solange die Deck-Taste gedrückt ist"

#: dailydeck/gui.py
msgid "How long the icon lights up at full brightness after switching apps; 0 = off"
msgstr "So lange leuchtet das Icon nach einem Programmwechsel in voller Helligkeit; 0 = aus"
Expand Down Expand Up @@ -297,6 +314,10 @@ msgstr "Taste – oben eine Taste anklicken"
msgid "Key opacity"
msgstr "Deckkraft der Tasten"

#: dailydeck/gui.py
msgid "Key press"
msgstr "Tastendruck"

#: dailydeck/gui.py
msgid "Key spacing on the device"
msgstr "Tastenabstand am Gerät"
Expand Down Expand Up @@ -454,6 +475,10 @@ msgstr "Einstellungen"
msgid "Settings …"
msgstr "Einstellungen …"

#: dailydeck/gui.py
msgid "Short tap"
msgstr "Kurz antippen"

#: dailydeck/gui.py
msgid "Shortcut"
msgstr "Kürzel"
Expand Down Expand Up @@ -693,6 +718,11 @@ msgstr "unbekannte Taste „{key}“ in „{shortcut}“"
msgid "unknown modifier “{modifier}” in “{shortcut}”"
msgstr "unbekannter Modifier „{modifier}“ in „{shortcut}“"

#: dailydeck/layout.py
#, python-brace-format
msgid "{seconds} s"
msgstr "{seconds} s"

#: dailydeck/profile_io.py
msgid "not a Daily Deck profile file"
msgstr "keine Daily-Deck-Profildatei"
Expand Down Expand Up @@ -869,6 +899,11 @@ msgstr ""
msgid "The sync folder {folder} is not reachable or has no configuration yet – using the configuration of this computer."
msgstr "Der Sync-Ordner {folder} ist nicht erreichbar oder enthält noch keine Konfiguration – verwendet wird die Konfiguration dieses Rechners."

#: dailydeck/layout.py
msgctxt "decimal separator"
msgid "."
msgstr ","

#: dailydeck/data/default_config.toml
msgctxt "default config"
msgid "Address"
Expand Down Expand Up @@ -1368,3 +1403,8 @@ msgstr "Zoom 100%"
msgctxt "default config"
msgid "Zoom −"
msgstr "Zoom −"

#: dailydeck/layout.py
msgctxt "key badge"
msgid "hold"
msgstr "halten"
Loading
Loading