diff --git a/Scripts/focusyoutube.sh b/Scripts/focusyoutube.sh new file mode 100755 index 0000000..ddc4e1d --- /dev/null +++ b/Scripts/focusyoutube.sh @@ -0,0 +1,3 @@ +# Focuses the first youtube window +WINDOWID="$(wmctrl -l | grep -v "wmctrl" | grep -m 1 "YouTube" | awk '{print $1}')" +wmctrl -i -a $WINDOWID diff --git a/Scripts/youtube.sh b/Scripts/youtube.sh new file mode 100755 index 0000000..e7ae738 --- /dev/null +++ b/Scripts/youtube.sh @@ -0,0 +1,13 @@ +# Prints the title of the first open YouTube window +# It works if the tab is in focus, so seperate the youtube tab from +# the rest of the browser so you don't have to keep it in focus and the script will work. + +OUTPUT="$(wmctrl -l | grep -v "wmctrl" | grep -m 1 YouTube | awk -v skipstart=3 -v skipend=4 '{delim = ""; for (i=skipstart+1;i<=NF-skipend;i++) {printf delim "%s", $i; delim = OFS};}')" +if [ "$OUTPUT" = "" ]; then + echo " " +else + echo " $OUTPUT" | head -c 35 +fi + +# general method to exlude fields +# awk -v skipstart=1 -v skipend=1 '{delim = ""; for (i=skipstart+1;i<=NF-skipend;i++) {printf delim "%s", $i; delim = OFS}; printf "\n"}' \ No newline at end of file