added new scripts

This commit is contained in:
elena 2017-08-22 14:48:50 +03:00
parent 669c8120f8
commit 225c4e7562
2 changed files with 16 additions and 0 deletions

3
Scripts/focusyoutube.sh Executable file
View file

@ -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

13
Scripts/youtube.sh Executable file
View file

@ -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"}'