Advertisement
constantin-net

OnSongChange.sh_4

Feb 17th, 2020 (edited)
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.30 KB | None | 0 0
  1. #!/bin/bash
  2. ffmpeg -i "`mocp -Q %file`" $HOME/.moc/current_album.png -y
  3. if [ $? -eq 1 ]; then
  4.     cp $HOME/.moc/default_album.png $HOME/.moc/current_album.png
  5. fi
  6. command=`cat <<EOF
  7. local naughty = require("naughty")
  8. local awful = require("awful")
  9. local info = ""
  10. awful.spawn.easy_async({"bash", "-c", "mocp -i"},
  11. function(out)
  12.   info = out
  13.   local artist  = string.gsub(string.match(info, "Artist: %C*"), "Artist: ","")
  14.   local title   = string.gsub(string.match(info, "SongTitle: %C*"), "SongTitle: ","")
  15.   local album   = string.gsub(string.match(info, "Album: %C*"), "Album: ","")
  16.   local path = string.gsub(string.match(info, "File: %C*"), "File: ", "")
  17.   local file   = string.gsub(path, "^.*/","")
  18.   artist  = string.gsub(artist, "&amp;", "&")
  19.   title   = string.gsub(title, "&amp;", "&")
  20.   album   = string.gsub(album, "&amp;", "&")
  21.   file   = string.gsub(file, "&amp;", "&")
  22.   if artist == "" or nil then
  23.     artist = "unknown artist"
  24.   end
  25.   if title == "" or nil then
  26.     title = file
  27.   end
  28.   naughty.destroy_all_notifications()
  29.   naughty.notify({ timeout = 5, position = "bottom_right",
  30.     icon = "$HOME/.moc/current_album.png",
  31.     icon_size = 128,
  32.     title = title,
  33.     text =  artist})
  34.   awesome.emit_signal("music::changed")
  35.   end)
  36. EOF
  37. `
  38. echo "${command}" | awesome-client
  39. exit 0
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement