summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormagh <magh@maghmogh.com>2024-11-27 16:27:18 +0900
committermagh <magh@maghmogh.com>2024-11-27 16:27:18 +0900
commit62503934bebfac2fa7e8c50ce89d16333922c2bb (patch)
treeddb54221b4e96a111bedf3eca7236eb5bc9a4c75
parent87c2649c3bc81ff61b2bf1da08bd3e310c0e0c2b (diff)
add scripts and fix presentationHEADmaster
-rw-r--r--final_presentation/source.pdfbin140420 -> 140212 bytes
-rw-r--r--final_presentation/source.tex1
-rwxr-xr-xscripts/bookmarks_check144
3 files changed, 144 insertions, 1 deletions
diff --git a/final_presentation/source.pdf b/final_presentation/source.pdf
index b7e3c07..c23cfe5 100644
--- a/final_presentation/source.pdf
+++ b/final_presentation/source.pdf
Binary files differ
diff --git a/final_presentation/source.tex b/final_presentation/source.tex
index 98e818d..f6f6f18 100644
--- a/final_presentation/source.tex
+++ b/final_presentation/source.tex
@@ -201,7 +201,6 @@
\begin{itemize}
\item Window naming conventions
\item Inter-process communication
- \item Resource sharing
\end{itemize}
\end{itemize}
\end{frame}
diff --git a/scripts/bookmarks_check b/scripts/bookmarks_check
new file mode 100755
index 0000000..ba74728
--- /dev/null
+++ b/scripts/bookmarks_check
@@ -0,0 +1,144 @@
+#!/bin/bash
+
+BOOKMARKS_FILE="$HOME/.config/mpv/bookmarks.json"
+MATH_RIKA_FILE="$HOME/.local/bin/mt_play"
+COMP_SCI_FILE="$HOME/.local/bin/cs_play"
+TVSHOW_FILE="$HOME/.local/bin/bookmarked_play"
+ANIME_FILE="$HOME/.local/bin/anime_play"
+MOVIE_FILE="$HOME/.local/bin/movie_play"
+
+# Function to check if jq is installed
+check_jq() {
+ if ! command -v jq &> /dev/null; then
+ echo "jq is not installed. Please install it to parse JSON."
+ exit 1
+ fi
+}
+
+# Function to get the last bookmark number
+get_last_bookmark_number() {
+ if [ ! -f "$BOOKMARKS_FILE" ] || [ "$(jq 'keys | length' "$BOOKMARKS_FILE")" -eq 0 ]; then
+ echo "0"
+ else
+ jq 'keys | map(tonumber) | max' "$BOOKMARKS_FILE"
+ fi
+}
+
+# Function to get absolute path
+get_absolute_path() {
+ local path="$1"
+ if [[ "$path" = /* ]]; then
+ echo "$path"
+ else
+ echo "$(pwd)/$path"
+ fi
+}
+
+# Function to add new bookmark to the bookmarks.json file
+add_new_bookmark() {
+ local filepath="$1"
+ local title="$2"
+ local bookmark_num="$3"
+ local pos=0 # Starting position for new bookmarks
+ local filename="$(basename "$filepath")"
+
+ # Ensure bookmarks file exists
+ if [ ! -f "$BOOKMARKS_FILE" ]; then
+ echo "{}" > "$BOOKMARKS_FILE"
+ fi
+
+ jq --arg num "$bookmark_num" \
+ --arg filename "$filename" \
+ --arg filepath "$filepath" \
+ --arg title "$title" \
+ --argjson pos "$pos" \
+ '.[$num] = {filename: $filename, pos: $pos, filepath: $filepath, title: $title}' \
+ "$BOOKMARKS_FILE" > "${BOOKMARKS_FILE}.tmp" && mv "${BOOKMARKS_FILE}.tmp" "$BOOKMARKS_FILE"
+
+ echo "Bookmark details added to $BOOKMARKS_FILE"
+}
+
+# Main script
+check_jq
+
+if [ "$#" -ne 1 ]; then
+ echo "Usage: $0 <filename>"
+ exit 1
+fi
+
+filename="$1"
+filepath=$(get_absolute_path "$filename")
+title="$filename"
+
+# Determine which category the file belongs to
+if [[ "$filepath" == */Videos/maths_and_rika/* ]]; then
+ category="maths_and_rika"
+elif [[ "$filepath" == */Videos/computer_science/* ]]; then
+ category="computer_science"
+elif [[ "$filepath" == */Videos/variety_and_shows/* ]]; then
+ category="variety_and_shows"
+elif [[ "$filepath" == */Videos/anime/* ]]; then
+ category="anime"
+elif [[ "$filepath" == */Videos/movies/* ]]; then
+ category="movies"
+else
+ category="other"
+fi
+
+# Create a bookmark if the file is in the specified directories
+if [ "$category" != "other" ]; then
+ bookmark_num=$(get_last_bookmark_number)
+ bookmark_num=$((bookmark_num + 1))
+ echo "Added new bookmark with number $bookmark_num"
+ add_new_bookmark "$filepath" "$title" "$bookmark_num"
+ is_new_bookmark=1
+else
+ # For files not in specified directories, do not create a bookmark
+ echo "File is not in a specified directory; not creating a bookmark."
+ is_new_bookmark=0
+ bookmark_num=""
+fi
+
+# Execute mpv based on the category
+if [ "$category" == "maths_and_rika" ]; then
+ if [ "$is_new_bookmark" -eq 1 ]; then
+ echo "mpv_launcher --x11-name=mpv_2 --pause --script-opts=bookmarker-start_bookmark=$bookmark_num \"$filepath\" &" >> "$MATH_RIKA_FILE"
+ echo "Added to math and rika bookmarks file"
+ fi
+ mpv_launcher --x11-name=mpv_2 --script-opts=bookmarker-start_bookmark=$bookmark_num "$filepath" &
+ xdo activate -n mpv_2
+elif [ "$category" == "computer_science" ]; then
+ if [ "$is_new_bookmark" -eq 1 ]; then
+ echo "mpv_launcher --x11-name=mpv_1 --pause --script-opts=bookmarker-start_bookmark=$bookmark_num \"$filepath\" &" >> "$COMP_SCI_FILE"
+ echo "Added to computer science bookmarks file"
+ fi
+ mpv_launcher --x11-name=mpv_1 --script-opts=bookmarker-start_bookmark=$bookmark_num "$filepath" &
+ xdo activate -n mpv_1
+elif [ "$category" == "variety_and_shows" ]; then
+ if [ "$is_new_bookmark" -eq 1 ]; then
+ echo "mpv_launcher --x11-name=mpv_3 --pause --script-opts=bookmarker-start_bookmark=$bookmark_num \"$filepath\" &" >> "$TVSHOW_FILE"
+ echo "Added to TV shows bookmarks file"
+ fi
+ mpv_launcher --x11-name=mpv_3 --script-opts=bookmarker-start_bookmark=$bookmark_num "$filepath" &
+ xdo activate -n mpv_3
+elif [ "$category" == "anime" ]; then
+ if [ "$is_new_bookmark" -eq 1 ]; then
+ echo "mpv_launcher --x11-name=mpv_4 --pause --script-opts=bookmarker-start_bookmark=$bookmark_num \"$filepath\" &" >> "$ANIME_FILE"
+ echo "Added to anime bookmarks file"
+ fi
+ mpv_launcher --x11-name=mpv_4 --script-opts=bookmarker-start_bookmark=$bookmark_num "$filepath" &
+ xdo activate -n mpv_4
+elif [ "$category" == "movies" ]; then
+ if [ "$is_new_bookmark" -eq 1 ]; then
+ echo "mpv_launcher --x11-name=mpv_5 --pause --script-opts=bookmarker-start_bookmark=$bookmark_num \"$filepath\" &" >> "$MOVIE_FILE"
+ echo "Added to movies bookmarks file"
+ fi
+ mpv_launcher --x11-name=mpv_5 --script-opts=bookmarker-start_bookmark=$bookmark_num "$filepath" &
+ xdo activate -n mpv_5
+else
+ # For files not in specified directories, use start_mpv without bookmarks
+ echo "Launching mpv without bookmarks."
+ start_mpv "$filepath" &
+fi
+
+echo "MPV launched with appropriate settings"