some updates

This commit is contained in:
Hannes
2026-08-14 13:52:56 +02:00
parent a5e11395ee
commit b5ce934840
12 changed files with 104 additions and 720 deletions
+1 -1
View File
@@ -7,4 +7,4 @@ source "$HOME/.config/function_helper.sh"
send_notification "low" "Pressed Makropad Button" "Row 1, Colums 4" "$HOME/.icons/BeautyLine-Garuda/apps/scalable/keyboard.svg"
~/.config/hypr/scripts/writing/todo.sh
~/.config/hypr/scripts/makropad/writing/todo.sh
+1 -1
View File
@@ -5,4 +5,4 @@ source "$HOME/.config/function_helper.sh"
send_notification "low" "Pressed Makropad Button" "Row 2, Colums 4 (08)" "$HOME/.icons/BeautyLine-Garuda/apps/scalable/keyboard.svg"
~/.config/hypr/scripts/writing/tmdb.sh
~/.config/hypr/scripts/makropad/writing/tmdb.sh
+94
View File
@@ -0,0 +1,94 @@
#!/bin/bash
set -x
tmdbid() {
local type q url
type="$1"
shift
q=$(printf '%s' "$*" | jq -sRr @uri)
echo "tmdbid: type=$type encoded query: $q" >&2
if [ "$type" = "tv" ]; then
url="https://www.themoviedb.org/search/tv?query=$q"
else
url="https://www.themoviedb.org/search/movie?query=$q"
fi
echo "tmdbid: url: $url" >&2
local result
result=$(curl -sL -A 'Mozilla/5.0' "$url" \
| grep -oE '/(movie|tv)/[0-9]+' \
| head -1 \
| cut -d/ -f3)
echo "tmdbid: result: $result" >&2
echo "$result"
}
clean_title() {
local s="$1"
echo "clean_title: input: $s" >&2
s=$(echo "$s" | sed -E 's/ *\([^)]*[0-9]{4}[^)]*\)//')
echo "clean_title: after year removal: $s" >&2
s="${s//ä/ae}"; s="${s//ö/oe}"; s="${s//ü/ue}"
s="${s//Ä/Ae}"; s="${s//Ö/Oe}"; s="${s//Ü/Ue}"
echo "clean_title: after umlauts: $s" >&2
s=$(echo "$s" | tr -d '0-9')
echo "clean_title: after number removal: $s" >&2
s=$(echo "$s" | tr -cd '[:alpha:] [:space:]')
echo "clean_title: after special char removal: $s" >&2
s=$(echo "$s" | tr -s ' ')
echo "clean_title: final: $s" >&2
echo "$s"
}
ws="${1:-3}"
title=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $ws)" | grep "The Movie Database" | sed 's/ — The Movie Database.*//' | sed 's/ "title": "//' | sed 's/"$//')
echo "title: $title" >&2
search_title=$(echo "$title" | sed -E 's/ *\([^)]*\) *//g')
echo "search_title: $search_title" >&2
if echo "$title" | grep -qi "TV [Ss]eries"; then
type="tv"
else
type="movie"
fi
echo "detected type: $type" >&2
tmdbid=$(tmdbid "$type" "$search_title")
echo "tmdbid: $tmdbid" >&2
if [ -z "$tmdbid" ]; then
if [ "$type" = "tv" ]; then
echo "retrying as movie" >&2
tmdbid=$(tmdbid "movie" "$search_title")
else
echo "retrying as tv" >&2
tmdbid=$(tmdbid "tv" "$search_title")
fi
echo "tmdbid (retry): $tmdbid" >&2
fi
if [[ $title =~ ([0-9]{4}) ]]; then
year="${BASH_REMATCH[1]}"
else
year=""
fi
echo "year: $year" >&2
clean=$(clean_title "$title")
echo "clean: $clean" >&2
result="$clean ($year) [tmdb-$tmdbid]"
echo "final wtype input: $result" >&2
wtype "$result"
+74
View File
@@ -0,0 +1,74 @@
#!/bin/bash
tmdbid() {
local type q url
type="$1"
shift
q=$(printf '%s' "$*" | jq -sRr @uri)
if [ "$type" = "tv" ]; then
url="https://www.themoviedb.org/search/tv?query=$q"
else
url="https://www.themoviedb.org/search/movie?query=$q"
fi
curl -sL -A 'Mozilla/5.0' "$url" \
| grep -oE '/(movie|tv)/[0-9]+' \
| head -1 \
| cut -d/ -f3
}
clean_title() {
local s="$1"
# remove (year) or (TV Series year) style parentheses
s=$(echo "$s" | sed -E 's/ *\([^)]*[0-9]{4}[^)]*\)//')
# umlaut replacement
s="${s//ä/ae}"; s="${s//ö/oe}"; s="${s//ü/ue}"
s="${s//Ä/Ae}"; s="${s//Ö/Oe}"; s="${s//Ü/Ue}"
# remove all numbers
s=$(echo "$s" | tr -d '0-9')
# remove special characters except spaces and letters
s=$(echo "$s" | tr -cd '[:alpha:] [:space:]')
# clean extra spaces
s=$(echo "$s" | tr -s ' ')
echo "$s"
}
ws="${1:-3}"
title=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $ws)" | grep "The Movie Database" | sed 's/ — The Movie Database.*//' | sed 's/ "title": "//' | sed 's/"$//')
search_title=$(echo "$title" | sed -E 's/ *\([^)]*\) *//g')
if echo "$title" | grep -qi "TV [Ss]eries"; then
type="tv"
else
type="movie"
fi
tmdbid=$(tmdbid "$type" "$search_title")
if [ -z "$tmdbid" ]; then
if [ "$type" = "tv" ]; then
tmdbid=$(tmdbid "movie" "$search_title")
else
tmdbid=$(tmdbid "tv" "$search_title")
fi
fi
if [[ $title =~ ([0-9]{4}) ]]; then
year="${BASH_REMATCH[1]}"
else
year=""
fi
clean=$(clean_title "$title")
wtype "$clean ($year) [tmdb-$tmdbid]"
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# Type "[TODO] "
wtype "[TODO] "
sleep 0.1
# Shift+End (select to end of line)
ydotool key 42:1 107:1 107:0 42:0
# 42 = Shift, 107 = End
sleep 0.1
# Ctrl+C (copy)
ydotool key 29:1 46:1 46:0 29:0
# 29 = Ctrl, 46 = C
sleep 0.1
# Tab twice
ydotool key 15:1 15:0
ydotool key 15:1 15:0
sleep 0.1
# Ctrl+V (paste)
ydotool key 29:1 47:1 47:0 29:0
# 29 = Ctrl, 47 = V
sleep 0.1
# Enter
ydotool key 28:1 28:0