diff --git a/screen-toolkit/plugin.toml b/screen-toolkit/plugin.toml index 6c7b7225..084256ee 100644 --- a/screen-toolkit/plugin.toml +++ b/screen-toolkit/plugin.toml @@ -8,7 +8,7 @@ id = "alexander/screen-toolkit" name = "Screen Toolkit" -version = "1.3.0" +version = "1.3.1" plugin_api = 13 author = "alexander" license = "MIT" @@ -157,6 +157,13 @@ label_key = "settings.record_audio_in.label" description_key = "settings.record_audio_in.description" default = false +[[setting]] +key = "hide-when-unused" +type = "bool" +label_key = "settings.hide_when_unused.label" +description_key = "settings.hide_when_unused.description" +default = false + [[setting]] key = "hide-cursor" type = "bool" diff --git a/screen-toolkit/translations/en.json b/screen-toolkit/translations/en.json index 76ec92d4..bb6f4c8a 100644 --- a/screen-toolkit/translations/en.json +++ b/screen-toolkit/translations/en.json @@ -93,6 +93,10 @@ "description": "Maximum duration in seconds for GIF recordings.", "label": "Max GIF Duration" }, + "hide_when_unused": { + "description": "Hide the bar widget when no recording is active. It will appear only while recording.", + "label": "Hide When Unused" + }, "hide_cursor": { "description": "Exclude the cursor from recordings. Screenshots never include the cursor.", "label": "Hide Cursor in Recordings" diff --git a/screen-toolkit/widget.luau b/screen-toolkit/widget.luau index eec96749..055e1345 100644 --- a/screen-toolkit/widget.luau +++ b/screen-toolkit/widget.luau @@ -6,10 +6,13 @@ -- Recording logic lives in the [[service]] — this widget -- only reflects the published state and drives the service through the -- "command" state channel. +-- When "hide-when-unused" is enabled, the widget is hidden until a +-- recording starts (issue #444). -local recording = false +local recording = noctalia.state.get("recording") == true +local hideWhenUnused = noctalia.getConfig("hide-when-unused") == true local phase = 0 -local startedAt = nil +local startedAt = noctalia.state.get("recordStartedAt") local function elapsed() if not startedAt then return "00:00" end @@ -18,6 +21,12 @@ local function elapsed() end local function render() + if hideWhenUnused and not recording then + barWidget.setVisible(false) + return + end + barWidget.setVisible(true) + local container = barWidget.isVertical() and ui.column or ui.row local children = {} if recording then @@ -52,6 +61,11 @@ noctalia.state.watch("recordStartedAt", function(value) render() end) +function onConfigChanged() + hideWhenUnused = noctalia.getConfig("hide-when-unused") == true + render() +end + function onClick() -- The bar icon never stops a recording; it just opens the panel so the -- stop button (in the panel header, next to the close X) is reachable.