blob: a442ec3a70b88ca1df7090787d943a44be4da8f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/bash
# Function to check if a path contains a specific directory
path_contains() {
case "$1" in
*"$2"*) return 0 ;;
*) return 1 ;;
esac
}
# Check if at least one argument is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <video_file>"
exit 1
fi
# Get the full path of the first argument (assumed to be the video file)
full_path=$(readlink -f "$1")
# Determine the x11-name based on the path
if path_contains "$full_path" "/Videos/computer_science"; then
x11_name="mpv_1"
elif path_contains "$full_path" "/Videos/maths_and_rika"; then
x11_name="mpv_2"
else
x11_name="mpv_0"
fi
# Launch mpv with the appropriate x11-name
mpv --x11-name="$x11_name" "$@" &
mpv_pid=$!
# Wait for the window to appear
window_id=""
while [ -z "$window_id" ]; do
sleep 0.1
window_id=$(xdotool search --onlyvisible --pid $mpv_pid 2>/dev/null)
done
# Activate the window
xdotool windowactivate "$window_id"
echo "Launched mpv with x11-name: $x11_name"
|