refactor(nvim): better dir structure
This commit is contained in:
20
configs/waybar/capture_mp3.sh
Executable file
20
configs/waybar/capture_mp3.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
arecord -f cd -t raw -d 4 -q | lame -r -q - output.mp3 2>/dev/null
|
||||
|
||||
if [ ! -f "./output.mp3" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
JSON=$(songrec audio-file-to-recognized-song output.mp3)
|
||||
|
||||
RETRYMS=$(echo $JSON | jq '.retryms')
|
||||
|
||||
if [ $RETRYMS != null ]; then
|
||||
echo $(expr $RETRYMS / 1000)
|
||||
else
|
||||
SONG=$(echo $JSON | tr '\r\n' ' ' | jq '.track.share.subject')
|
||||
echo $SONG
|
||||
rm -rf output.mp3
|
||||
fi
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_FILES="$HOME/.config/waybar/config $HOME/.config/waybar/style.css"
|
||||
CONFIG_FILES="$HOME/.config/waybar/config $HOME/.config/waybar/*.css $HOME/.config/waybar/*.sh"
|
||||
|
||||
killall waybar;
|
||||
|
||||
|
34
configs/waybar/mediaplayer.py
Normal file → Executable file
34
configs/waybar/mediaplayer.py
Normal file → Executable file
@@ -3,20 +3,23 @@ import argparse
|
||||
import logging
|
||||
import sys
|
||||
import signal
|
||||
import time
|
||||
import gi
|
||||
import json
|
||||
gi.require_version('Playerctl', '2.0')
|
||||
from gi.repository import Playerctl, GLib
|
||||
import subprocess
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
playerVisible = False
|
||||
|
||||
def write_output(text, player):
|
||||
def write_output(text, player_name):
|
||||
logger.info('Writing output')
|
||||
|
||||
output = {'text': text,
|
||||
'class': 'custom-' + player.props.player_name,
|
||||
'alt': player.props.player_name}
|
||||
output = {'text': text.replace("&", "&"),
|
||||
'class': 'custom-' + player_name,
|
||||
'alt': player_name}
|
||||
|
||||
sys.stdout.write(json.dumps(output) + '\n')
|
||||
sys.stdout.flush()
|
||||
@@ -43,18 +46,32 @@ def on_metadata(player, metadata, manager):
|
||||
|
||||
if player.props.status != 'Playing' and track_info:
|
||||
track_info = ' ' + track_info
|
||||
write_output(track_info, player)
|
||||
write_output(track_info, player.props.player_name)
|
||||
|
||||
|
||||
def update_song():
|
||||
global playerVisible
|
||||
while not playerVisible:
|
||||
result = subprocess.run("./capture_mp3.sh",stdout=subprocess.PIPE)
|
||||
resultString = result.stdout.decode("utf-8")
|
||||
print(resultString);
|
||||
write_output(resultString, "Spotify")
|
||||
time.sleep(6)
|
||||
|
||||
def on_player_appeared(manager, player, selected_player=None):
|
||||
global playerVisible
|
||||
if player is not None and (selected_player is None or player.name == selected_player):
|
||||
playerVisible = True
|
||||
init_player(manager, player)
|
||||
else:
|
||||
logger.debug("New player appeared, but it's not the selected player, skipping")
|
||||
|
||||
|
||||
def on_player_vanished(manager, player):
|
||||
global playerVisible
|
||||
logger.info('Player has vanished')
|
||||
playerVisible = False
|
||||
update_song()
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.flush()
|
||||
|
||||
@@ -64,6 +81,7 @@ def init_player(manager, name):
|
||||
player = Playerctl.Player.new_from_name(name)
|
||||
player.connect('playback-status', on_play, manager)
|
||||
player.connect('metadata', on_metadata, manager)
|
||||
update_song()
|
||||
manager.manage_player(player)
|
||||
on_metadata(player, player.props.metadata, manager)
|
||||
|
||||
@@ -72,7 +90,7 @@ def signal_handler(sig, frame):
|
||||
logger.debug('Received signal to stop, exiting')
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.flush()
|
||||
# loop.quit()
|
||||
loop.quit()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@@ -89,6 +107,7 @@ def parse_arguments():
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
arguments = parse_arguments()
|
||||
|
||||
# Initialize logging
|
||||
@@ -98,6 +117,7 @@ def main():
|
||||
# Logging is set by default to WARN and higher.
|
||||
# With every occurrence of -v it's lowered by one
|
||||
logger.setLevel(max((3 - arguments.verbose) * 10, 0))
|
||||
logger.setLevel(0)
|
||||
|
||||
# Log the sent command line arguments
|
||||
logger.debug('Arguments received {}'.format(vars(arguments)))
|
||||
@@ -120,8 +140,8 @@ def main():
|
||||
|
||||
init_player(manager, player)
|
||||
|
||||
update_song()
|
||||
loop.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
2
configs/waybar/recognize-song.sh
Normal file
2
configs/waybar/recognize-song.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
249
configs/waybar/song.json
Normal file
249
configs/waybar/song.json
Normal file
@@ -0,0 +1,249 @@
|
||||
{
|
||||
"location": {
|
||||
"altitude": 300.0,
|
||||
"latitude": 45.0,
|
||||
"longitude": 2.0
|
||||
},
|
||||
"matches": [
|
||||
{
|
||||
"channel": "0",
|
||||
"frequencyskew": 0.00008058548,
|
||||
"id": "341270538",
|
||||
"offset": 148.84515625,
|
||||
"timeskew": -0.0023667216
|
||||
}
|
||||
],
|
||||
"tagid": "68982327-bef9-4ff3-a426-7fea39f7997f",
|
||||
"timestamp": 95912955,
|
||||
"timezone": "Europe/Paris",
|
||||
"track": {
|
||||
"albumadamid": "1477092467",
|
||||
"artists": [
|
||||
{
|
||||
"adamid": "827504058",
|
||||
"id": "44445618"
|
||||
}
|
||||
],
|
||||
"genres": {
|
||||
"primary": "Alternative"
|
||||
},
|
||||
"highlightsurls": {
|
||||
"artisthighlightsurl": "https://cdn.shazam.com/video/v3/en/US/android/827504058/highlights?affiliate=mttnagencyid%3D769459046716559743%26mttnsiteid%3D125115%26mttn3pid%3Da_custom_779816081798873874%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am",
|
||||
"relatedhighlightsurl": "https://cdn.shazam.com/video/v3/en/US/android/44445618/artist-similarities-id-44445618/relatedhighlights?max_artists=5&affiliate=mttnagencyid%3D769459046716559743%26mttnsiteid%3D125115%26mttn3pid%3Da_custom_779816081798873874%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am"
|
||||
},
|
||||
"hub": {
|
||||
"actions": [
|
||||
{
|
||||
"id": "1477092472",
|
||||
"name": "apple",
|
||||
"type": "applemusicplay"
|
||||
},
|
||||
{
|
||||
"name": "apple",
|
||||
"type": "uri",
|
||||
"uri": "https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview115/v4/17/c4/ff/17c4ff80-8823-5ce9-fa5a-0c1892129e3b/mzaf_15603304596709002890.plus.aac.ep.m4a"
|
||||
}
|
||||
],
|
||||
"displayname": "APPLE MUSIC",
|
||||
"explicit": false,
|
||||
"image": "https://images.shazam.com/static/icons/hub/android/v5/applemusic_{scalefactor}.png",
|
||||
"options": [
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"name": "hub:applemusic:deeplink",
|
||||
"type": "intent",
|
||||
"uri": "intent://music.apple.com/us/album/nothings-older-than-yesterday/1477092467?i=1477092472&mttnagencyid=769459046716559743&mttnsiteid=125115&mttn3pid=a_custom_779816081798873874&mttnsub1=Shazam_android_am&mttnsub2=5348615A-616D-3235-3830-44754D6D5973&itscg=30201&app=music&itsct=Shazam_android_am#Intent;scheme=http;package=com.apple.android.music;action=android.intent.action.VIEW;end"
|
||||
},
|
||||
{
|
||||
"id": "1477092472",
|
||||
"name": "hub:applemusic:connect",
|
||||
"type": "applemusicconnect",
|
||||
"uri": "https://unsupported.shazam.com"
|
||||
},
|
||||
{
|
||||
"name": "hub:applemusic:androidstore",
|
||||
"type": "uri",
|
||||
"uri": "https://play.google.com/store/apps/details?id=com.apple.android.music&referrer=utm_source=https%3A%2F%2Fmusic.apple.com%2Fsubscribe%3Fmttnagencyid%3D769459046716559743%26mttnsiteid%3D125115%26mttn3pid%3Da_custom_779816081798873874%26mttnsub1%3DShazam_android_am%26mttnsub2%3D5348615A-616D-3235-3830-44754D6D5973%26itscg%3D30201%26app%3Dmusic%26itsct%3DShazam_android_am"
|
||||
}
|
||||
],
|
||||
"beacondata": {
|
||||
"providername": "applemusic",
|
||||
"type": "open"
|
||||
},
|
||||
"caption": "OPEN",
|
||||
"colouroverflowimage": false,
|
||||
"image": "https://images.shazam.com/static/icons/hub/android/v5/overflow-open-option_{scalefactor}.png",
|
||||
"listcaption": "Open in Apple Music",
|
||||
"overflowimage": "https://images.shazam.com/static/icons/hub/android/v5/applemusic-overflow_{scalefactor}.png",
|
||||
"providername": "applemusic",
|
||||
"type": "open"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"name": "hub:spotify:searchdeeplink",
|
||||
"type": "uri",
|
||||
"uri": "spotify:search:Nothing%27s%20Older%20Than%20Yesterday%20Cari%20Cari"
|
||||
}
|
||||
],
|
||||
"caption": "Open in Spotify",
|
||||
"images": {
|
||||
"default": "https://images.shazam.com/static/icons/hub/android/v5/spotify_{scalefactor}.png",
|
||||
"overflow": "https://images.shazam.com/static/icons/hub/android/v5/spotify-overflow_{scalefactor}.png"
|
||||
},
|
||||
"type": "SPOTIFY"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"name": "hub:youtubemusic:androiddeeplink",
|
||||
"type": "uri",
|
||||
"uri": "https://music.youtube.com/search?q=Nothings+Older+Than+Yesterday+Cari+Cari&feature=shazam"
|
||||
}
|
||||
],
|
||||
"caption": "Open in YouTube Music",
|
||||
"images": {
|
||||
"default": "https://images.shazam.com/static/icons/hub/android/v5/youtubemusic_{scalefactor}.png",
|
||||
"overflow": "https://images.shazam.com/static/icons/hub/android/v5/youtubemusic-overflow_{scalefactor}.png"
|
||||
},
|
||||
"type": "YOUTUBEMUSIC"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"name": "hub:deezer:searchdeeplink",
|
||||
"type": "uri",
|
||||
"uri": "deezer-query://www.deezer.com/play?query=%7Btrack%3A%27Nothing%5C%27s+Older+Than+Yesterday%27%20artist%3A%27Cari+Cari%27%7D"
|
||||
}
|
||||
],
|
||||
"caption": "Open in Deezer",
|
||||
"images": {
|
||||
"default": "https://images.shazam.com/static/icons/hub/android/v5/deezer_{scalefactor}.png",
|
||||
"overflow": "https://images.shazam.com/static/icons/hub/android/v5/deezer-overflow_{scalefactor}.png"
|
||||
},
|
||||
"type": "DEEZER"
|
||||
}
|
||||
],
|
||||
"type": "APPLEMUSIC"
|
||||
},
|
||||
"images": {
|
||||
"background": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg",
|
||||
"coverart": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg",
|
||||
"coverarthq": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg",
|
||||
"joecolor": "b:031827p:fdf0dfs:f7831et:cbc5baq:c66e1f"
|
||||
},
|
||||
"isrc": "ATT801713001",
|
||||
"key": "341270538",
|
||||
"layout": "5",
|
||||
"relatedtracksurl": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/track-similarities-id-341270538?startFrom=0&pageSize=20&connected=",
|
||||
"sections": [
|
||||
{
|
||||
"metadata": [
|
||||
{
|
||||
"text": "Anaana",
|
||||
"title": "Album"
|
||||
},
|
||||
{
|
||||
"text": "recordJet",
|
||||
"title": "Label"
|
||||
},
|
||||
{
|
||||
"text": "2017",
|
||||
"title": "Released"
|
||||
}
|
||||
],
|
||||
"metapages": [
|
||||
{
|
||||
"caption": "Cari Cari",
|
||||
"image": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg"
|
||||
},
|
||||
{
|
||||
"caption": "Nothing's Older Than Yesterday",
|
||||
"image": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg"
|
||||
}
|
||||
],
|
||||
"tabname": "Song",
|
||||
"type": "SONG"
|
||||
},
|
||||
{
|
||||
"beacondata": {
|
||||
"commontrackid": "70387093",
|
||||
"lyricsid": "19307144",
|
||||
"providername": "musixmatch"
|
||||
},
|
||||
"footer": "Writer(s): Stephanie Widmer, Alexander Koeck
|
||||
Lyrics powered by www.musixmatch.com",
|
||||
"tabname": "Lyrics",
|
||||
"text": [
|
||||
"Waves are rolling on the beach",
|
||||
"Sunlight is striking through the trees",
|
||||
"Heads up, don't look back",
|
||||
"On the coast of Jamaica, there ain't no looking back",
|
||||
"",
|
||||
"Move, nothing's older than yesterday",
|
||||
"'Cause we're riding, it's just the streets and you and me",
|
||||
"Heads up, don't look back!",
|
||||
"On the streets of Tokyo, no looking back",
|
||||
"C'mon baby, we can stay up all night",
|
||||
"I stay here till sunrise",
|
||||
"Come on, don't miss this ride"
|
||||
],
|
||||
"type": "LYRICS",
|
||||
"url": "https://cdn.shazam.com/lyrics/v1/en/US/android/musixmatch/subtitles/70387093/202/1?token=d3fe124c5cfcec867f24caddbb4fb700"
|
||||
},
|
||||
{
|
||||
"tabname": "Video",
|
||||
"type": "VIDEO",
|
||||
"youtubeurl": "https://cdn.shazam.com/video/v3/-/US/android/341270538/youtube/video?q=Cari+Cari+%22Nothing's+Older+Than+Yesterday%22&c=UCiL526VL2ZWT9pUuUQP52uw"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"id": "44445618",
|
||||
"type": "artistposts"
|
||||
},
|
||||
{
|
||||
"id": "44445618",
|
||||
"type": "artist"
|
||||
}
|
||||
],
|
||||
"avatar": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg",
|
||||
"id": "44445618",
|
||||
"name": "Cari Cari",
|
||||
"tabname": "Artist",
|
||||
"toptracks": {
|
||||
"url": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/artisttoptracks_44445618?startFrom=0&pageSize=20&connected="
|
||||
},
|
||||
"type": "ARTIST",
|
||||
"url": "https://cdn.shazam.com/digest/v1/en/US/android/artist/44445618/recentpost",
|
||||
"verified": false
|
||||
},
|
||||
{
|
||||
"tabname": "Related",
|
||||
"type": "RELATED",
|
||||
"url": "https://cdn.shazam.com/shazam/v3/en/US/android/-/tracks/track-similarities-id-341270538?startFrom=0&pageSize=20&connected="
|
||||
}
|
||||
],
|
||||
"share": {
|
||||
"avatar": "https://is3-ssl.mzstatic.com/image/thumb/Music114/v4/62/5c/d7/625cd78a-6d55-3128-1a55-894d244800c9/pr_source.png/800x800cc.jpg",
|
||||
"href": "https://www.shazam.com/track/341270538/nothings-older-than-yesterday",
|
||||
"html": "https://www.shazam.com/snippets/email-share/341270538?lang=en&country=US",
|
||||
"image": "https://is1-ssl.mzstatic.com/image/thumb/Music125/v4/b8/c5/3c/b8c53c9c-489f-3bec-1b25-c232368a1fac/rls00069784.jpg/400x400cc.jpg",
|
||||
"snapchat": "https://www.shazam.com/partner/sc/track/341270538",
|
||||
"subject": "Nothing's Older Than Yesterday - Cari Cari",
|
||||
"text": "I used Shazam to discover Nothing's Older Than Yesterday by Cari Cari.",
|
||||
"twitter": "I used @Shazam to discover Nothing's Older Than Yesterday by Cari Cari."
|
||||
},
|
||||
"subtitle": "Cari Cari",
|
||||
"title": "Nothing's Older Than Yesterday",
|
||||
"type": "MUSIC",
|
||||
"url": "https://www.shazam.com/track/341270538/nothings-older-than-yesterday",
|
||||
"urlparams": {
|
||||
"{trackartist}": "Cari+Cari",
|
||||
"{tracktitle}": "Nothing%27s+Older+Than+Yesterday"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user