aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/jellyfin-mpv-shim/scripts/set-lights.lua5
-rwxr-xr-x.local/share/bin/scene30
2 files changed, 24 insertions, 11 deletions
diff --git a/.config/jellyfin-mpv-shim/scripts/set-lights.lua b/.config/jellyfin-mpv-shim/scripts/set-lights.lua
new file mode 100644
index 0000000..b454519
--- /dev/null
+++ b/.config/jellyfin-mpv-shim/scripts/set-lights.lua
@@ -0,0 +1,5 @@
+function on_start_file()
+ os.execute("scene scene.aux_eiga_moodo");
+end
+
+mp.register_event("start-file", on_start_file)
diff --git a/.local/share/bin/scene b/.local/share/bin/scene
index 3a140fa..c7faff6 100755
--- a/.local/share/bin/scene
+++ b/.local/share/bin/scene
@@ -19,7 +19,7 @@ update_cache() {
[ ! -e "$CACHE_FILE" ] && update_cache
# update the cache if requested explicitly
-[ "$1" = "update" ] && {
+[ "$1" = "--update" ] && {
update_cache
exit
}
@@ -28,16 +28,24 @@ update_cache() {
MAX_CACHE_AGE=$(( 60 * 60 * 24 )) # one day
[ $(( $(date +%s) - $MAX_CACHE_AGE )) -gt $(date -r "$CACHE_FILE" +%s) ] && update_cache
-# pick a scene using rofi in dmenu mode
-scene="$(cat "$CACHE_FILE" |\
- rofi \
- -dmenu \
- -display-columns 1 \
- -display-column-separator "$TAB" |\
- cut -d"$TAB" -f2 |\
- jq --raw-input)"
-
-# exit if no scene was selected
+if [ $# -eq 0 ] ; then
+ # pick a scene using rofi in dmenu mode
+ scene="$(cat "$CACHE_FILE" |\
+ rofi \
+ -dmenu \
+ -display-columns 1 \
+ -display-column-separator "$TAB" |\
+ cut -d"$TAB" -f2 |\
+ jq --raw-input)"
+else
+ # non interactive scene pick
+ scene="$(cat "$CACHE_FILE" |\
+ grep -w "$*" | head -n1 |\
+ cut -d"$TAB" -f2 |\
+ jq --raw-input)"
+fi
+
+# exit if no scene was selected / found
[ -z "$scene" ] && exit 0
jq -n --argjson scene "$scene" '{"entity_id": $scene}' |\