Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # Created by Siddharth Dushantha (sdushantha)
  4. #
  5. # Dependencies: xdotool, mpv
  6. #
  7. # This script was tested using Firefox, so if you use another
  8. # browser, replace the value for WEB_BROSWER with the name
  9. # of your web browser (e.g Google Chrome, Opera, etc.)
  10.  
  11. WEB_BROWSER="Mozilla Firefox"
  12.  
  13. # Checking if the user is currently on the web browser
  14. CURRENT=$(xdotool getwindowfocus getwindowname | grep "$WEB_BROWSER")
  15.  
  16. # Get the exit code of the command above.
  17. # If the user is using a web browser, then the
  18. # exit code will be 0
  19. STATUS=$?
  20.  
  21. # If the user is using web browser...
  22. if [ $STATUS -eq 0 ];then
  23.     # Then select the url bar and copy the url
  24.     xdotool key ctrl+l
  25.     xdotool key ctrl+c
  26. fi
  27.  
  28. # Get the content from the clipboard
  29. URL=$(xclip -selection clipboard -o)
  30.    
  31. notify-send "mpv" "Fetching video..."
  32. mpv $URL
  33.  
  34. # Get the exit code if mpv
  35. STATUS=$?
  36.  
  37. if [ $STATUS -ne 0 ];then
  38.     notify-send "mpv" "Failed to fetch the video"
  39.     exit
  40. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement