👽
This commit is contained in:
1 parent
0b17aa140b
commit
dde4ef218a
136 files changed
+9796
No files matched your search
Executable
+281
@@ -0,0 +1,281 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ╔╦╗ ╦ ╦ ╔═╗ ╦ ╔═╗
|
||||
# ║║║ ║ ║ ╚═╗ ║ ║
|
||||
# ╩ ╩ ╚═╝ ╚═╝ ╩ ╚═╝
|
||||
|
||||
# author Niraj
|
||||
# github niraj998
|
||||
|
||||
# ┌─┐┌─┐┌┐┌┌─┐┬┌─┐┬ ┬┬─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
|
||||
# │ │ ││││├┤ ││ ┬│ │├┬┘├─┤ │ ││ ││││└─┐
|
||||
# └─┘└─┘┘└┘└ ┴└─┘└─┘┴└─┴ ┴ ┴ ┴└─┘┘└┘└─┘
|
||||
|
||||
# uncomment your music players below.
|
||||
#
|
||||
|
||||
Control="MPD"
|
||||
[ -n "$(pgrep spotify)" ] && Control="spotify"
|
||||
# [ -n "$(pgrep brave-bin)" ] && Control="brave-bin"
|
||||
# [ -n "$(pgrep rhythmbox)" ] && Control="rhythmbox"
|
||||
# [ -n "$(pgrep audacious)" ] && Control="audacious"
|
||||
# [ -n "$(pgrep clementine)" ] && Control="clementine"
|
||||
# [ -n "$(pgrep strawberry)" ] && Control="strawberry"
|
||||
|
||||
|
||||
|
||||
# saves covers here
|
||||
Cover=/tmp/cover.png
|
||||
# if cover not found in metadata use this instead
|
||||
bkpCover=~/.config/eww/images/music.jpg
|
||||
# mpd music directory
|
||||
mpddir=~/Music
|
||||
|
||||
# ┌─┐┬ ┌─┐┬ ┬┌─┐┬─┐┌─┐┌┬┐┬ ┌─┐┌─┐┬─┐┬┌─┐┌┬┐┌─┐
|
||||
# ├─┘│ ├─┤└┬┘├┤ ├┬┘│ │ │ └─┐│ ├┬┘│├─┘ │ └─┐
|
||||
# ┴ ┴─┘┴ ┴ ┴ └─┘┴└─└─┘ ┴ ┴─┘ └─┘└─┘┴└─┴┴ ┴ └─┘
|
||||
|
||||
########################## Title ##########################
|
||||
title() {
|
||||
title=$(playerctl --player=$Control metadata --format {{title}})
|
||||
[ -z "$title" ] && title="Play Something"
|
||||
echo "$title"
|
||||
}
|
||||
|
||||
########################## Artist ##########################
|
||||
artist() {
|
||||
artist=$(playerctl --player=$Control metadata --format {{artist}})
|
||||
[ -z "$artist" ] && artist="Artist"
|
||||
echo "$artist"
|
||||
}
|
||||
|
||||
########################## Album ##########################
|
||||
album() {
|
||||
album=$(playerctl --player=$Control metadata --format {{album}})
|
||||
[ -z "$album" ] && album="Album"
|
||||
echo "$album"
|
||||
}
|
||||
|
||||
########################## Status ##########################
|
||||
status() {
|
||||
status=$(playerctl --player=$Control status)
|
||||
[ -z "$status" ] && status="Stopped"
|
||||
echo "$status"
|
||||
}
|
||||
|
||||
########################## Time ##########################
|
||||
ctime() {
|
||||
time=$(playerctl --player=$Control position --format "{{ duration(position) }}")
|
||||
[ -z "$time" ] && time="0:00"
|
||||
echo "$time"
|
||||
}
|
||||
|
||||
########################## Length ##########################
|
||||
length() {
|
||||
length=$(playerctl --player=$Control metadata --format "{{ duration(mpris:length) }}")
|
||||
[ -z "$length" ] && length="0:00"
|
||||
echo "$length"
|
||||
}
|
||||
|
||||
########################## trackNumber ##########################
|
||||
playlist() {
|
||||
playlist=$(playerctl --player=$Control metadata xesam:trackNumber)
|
||||
[ -z "$playlist" ] && playlist="0"
|
||||
echo "$playlist"
|
||||
}
|
||||
|
||||
########################## Cover ##########################
|
||||
cover() {
|
||||
albumart="$(playerctl --player=$Control metadata mpris:artUrl | sed -e 's/open.spotify.com/i.scdn.co/g')"
|
||||
[ $(playerctl --player=$Control metadata mpris:artUrl) ] && curl -s "$albumart" --output $Cover || cp $bkpCover $Cover
|
||||
echo "$Cover"
|
||||
}
|
||||
|
||||
########################## Statusicon ##########################
|
||||
statusicon() {
|
||||
icon=""
|
||||
[ $(playerctl --player=$Control status) = "Playing" ] && icon=""
|
||||
[ $(playerctl --player=$Control status) = "Paused" ] && icon=""
|
||||
echo "$icon"
|
||||
}
|
||||
|
||||
########################## Lyrics ##########################
|
||||
lyrics() {
|
||||
Title=$(playerctl --player=$Control metadata --format {{title}})
|
||||
Artist=$(playerctl --player=$Control metadata --format {{artist}})
|
||||
URL="https://api.lyrics.ovh/v1/$Artist/$Title"
|
||||
lyrics=$(curl -s "$( echo "$URL" | sed s/" "/%20/g | sed s/"&"/%26/g | sed s/,/%2C/g | sed s/-/%2D/g)" | jq '.lyrics' )
|
||||
[ "$lyrics" = "null" ] && lyrics=$( curl -s --get "https://makeitpersonal.co/lyrics" --data-urlencode "artist=$Artist" --data-urlencode "title=$Title")
|
||||
printf "$lyrics" | less
|
||||
}
|
||||
|
||||
# ┌┬┐┌─┐┌┬┐ ┌─┐┌─┐┬─┐┬┌─┐┌┬┐┌─┐
|
||||
# │││├─┘ ││ └─┐│ ├┬┘│├─┘ │ └─┐
|
||||
# ┴ ┴┴ ─┴┘ └─┘└─┘┴└─┴┴ ┴ └─┘
|
||||
|
||||
########################## Title ##########################
|
||||
mpctitle() {
|
||||
title=$(mpc -f %title% current)
|
||||
[ -z "$title" ] && title="Play Something"
|
||||
echo "$title"
|
||||
}
|
||||
|
||||
########################## Artist ##########################
|
||||
mpcartist() {
|
||||
artist=$(mpc -f %artist% current)
|
||||
[ -z "$artist" ] && artist="Artist"
|
||||
echo "$artist"
|
||||
}
|
||||
|
||||
########################## Album ##########################
|
||||
mpcalbum() {
|
||||
album=$(mpc -f %album% current)
|
||||
[ -z "$album" ] && album="Album"
|
||||
echo "$album"
|
||||
}
|
||||
|
||||
########################## Cover ##########################
|
||||
mpccover() {
|
||||
ffmpeg -i "$mpddir"/"$(mpc current -f %file%)" -vf scale=500:500 "${Cover}" -y || cp $bkpCover $Cover
|
||||
echo "$Cover" && exit
|
||||
}
|
||||
|
||||
## Cover for ncmpcpp ##
|
||||
ncmpcppcover() {
|
||||
ffmpeg -i "$mpddir"/"$(mpc current -f %file%)" -vf scale=500:500 "${Cover}" -y || cp $bkpCover $Cover
|
||||
exit
|
||||
}
|
||||
|
||||
########################## Time ##########################
|
||||
mpctime() {
|
||||
time=$(mpc status %currenttime%)
|
||||
[ -z "$time" ] && time="0:00"
|
||||
echo "$time"
|
||||
}
|
||||
|
||||
########################## Length ##########################
|
||||
mpclength() {
|
||||
length=$(mpc status %totaltime%)
|
||||
[ -z "$length" ] && length="0:00"
|
||||
echo "$length"
|
||||
}
|
||||
|
||||
########################## Icon ##########################
|
||||
mpcicon() {
|
||||
status=$(mpc status | head -2 | tail -1 | cut -c2-7 )
|
||||
icon=""
|
||||
[ "$status" = "playin" ] && icon=""
|
||||
[ "$status" = "paused" ] && icon=""
|
||||
echo "$icon"
|
||||
}
|
||||
|
||||
########################## Status ##########################
|
||||
mpcstatus() {
|
||||
stat=$(mpc status | head -2 | tail -1 | cut -c2-7 )
|
||||
status="Stopped"
|
||||
[ "$stat" = "playin" ] && status="Playing"
|
||||
[ "$stat" = "paused" ] && status="Paused"
|
||||
echo "$status"
|
||||
}
|
||||
|
||||
########################## Percent ##########################
|
||||
mpcperc() {
|
||||
perc=$(mpc status | grep "%)" | awk '{ print $4 }' | awk -F% '{ print $1 }' | awk 'sub(/^.{1}/,"")')
|
||||
[ -z "$perc" ] && perc="0"
|
||||
echo "$perc"
|
||||
}
|
||||
|
||||
########################## Playlist ##########################
|
||||
mpcsongpos() {
|
||||
playlist=$(mpc status %songpos%/%length%)
|
||||
[ -z "$playlist" ] && playlist="0/0"
|
||||
echo "$playlist"
|
||||
}
|
||||
|
||||
########################## Lyrics ##########################
|
||||
mpclyrics() {
|
||||
Title=$(mpc -f %title% current)
|
||||
Artist=$(mpc -f %artist% current)
|
||||
URL="https://api.lyrics.ovh/v1/$Artist/$Title"
|
||||
lyrics=$(curl -s "$( echo "$URL" | sed s/" "/%20/g | sed s/"&"/%26/g | sed s/,/%2C/g | sed s/-/%2D/g)" | jq '.lyrics' )
|
||||
[ "$lyrics" = "null" ] && lyrics=$( curl -s --get "https://makeitpersonal.co/lyrics" --data-urlencode "artist=$Artist" --data-urlencode "title=$Title")
|
||||
printf "$lyrics" | less
|
||||
}
|
||||
|
||||
# ┬ ┬┌─┐┬ ┌─┐
|
||||
# ├─┤├┤ │ ├─┘
|
||||
# ┴ ┴└─┘┴─┘┴
|
||||
|
||||
doc() {
|
||||
echo "Usage:
|
||||
MediaControl [Options]
|
||||
|
||||
Options:
|
||||
--previous previous song
|
||||
--next next song
|
||||
--toggle toggle between play-pause song
|
||||
--stop stop song
|
||||
title shows title of current song
|
||||
album shows album of current song
|
||||
artist shows artist of current song
|
||||
status music status (playing/paused/stopped)
|
||||
statusicon music status icons (playing/paused/stopped)
|
||||
coverloc saves cover and shows location to cover of current song
|
||||
showcover opens cover using feh
|
||||
time shows current time of song
|
||||
length shows length of song
|
||||
percent shows percent song
|
||||
playlist shows playlist position of current song
|
||||
lyrics shows lyrics"
|
||||
}
|
||||
|
||||
# ┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
|
||||
# │ │├─┘ │ ││ ││││└─┐
|
||||
# └─┘┴ ┴ ┴└─┘┘└┘└─┘
|
||||
|
||||
case $Control in
|
||||
MPD)
|
||||
case $1 in
|
||||
--next) mpc -q next ;;
|
||||
--previous) mpc -q prev ;;
|
||||
--toggle) mpc -q toggle ;;
|
||||
--stop) mpc -q stop ;;
|
||||
title) mpctitle ;;
|
||||
artist) mpcartist ;;
|
||||
album) mpcalbum ;;
|
||||
status) mpcstatus ;;
|
||||
statusicon) mpcicon ;;
|
||||
player) echo "$Control" ;;
|
||||
coverloc) mpccover ;;
|
||||
nccover) ncmpcppcover ;;
|
||||
showcover) mpccover | xargs feh ;;
|
||||
time) mpctime ;;
|
||||
length) mpclength ;;
|
||||
percent) mpcperc ;;
|
||||
playlist) mpcsongpos ;;
|
||||
lyrics) mpclyrics ;;
|
||||
*) doc ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
case $1 in
|
||||
--next) playerctl --player=$Control next ;;
|
||||
--previous) playerctl --player=$Control previous ;;
|
||||
--toggle) playerctl --player=$Control play-pause ;;
|
||||
--stop) playerctl --player=$Control stop ;;
|
||||
title) title ;;
|
||||
artist) artist ;;
|
||||
album) album ;;
|
||||
status) status ;;
|
||||
statusicon) statusicon ;;
|
||||
player) echo "$Control" ;;
|
||||
coverloc) cover ;;
|
||||
showcover) cover | xargs feh ;;
|
||||
time) ctime ;;
|
||||
length) length ;;
|
||||
percent) echo "0" ;;
|
||||
playlist) playlist ;;
|
||||
lyrics) lyrics ;;
|
||||
*) doc ;;
|
||||
esac
|
||||
esac 2>/dev/null
|
||||
@@ -0,0 +1,69 @@
|
||||
*
|
||||
{
|
||||
all: unset;
|
||||
}
|
||||
|
||||
/* Music player */
|
||||
|
||||
.music-player{
|
||||
background-color: #1f1d29;
|
||||
padding: 0 1rem 1rem 1rem;
|
||||
border-radius: 12px;
|
||||
margin: .5rem;
|
||||
}
|
||||
.album_art {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
border-radius: 12px;
|
||||
margin: 2rem 1rem 1.5rem 1rem;
|
||||
padding: 7rem;
|
||||
}
|
||||
|
||||
.artist {
|
||||
font-family: Cartograph CF;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
color: #FDFDFD;
|
||||
font-size : 13px;
|
||||
}
|
||||
.song{
|
||||
font-family: Cartograph CF;
|
||||
font-style: italic;
|
||||
font-size: 15px;
|
||||
color: #FDFDFD;
|
||||
margin-top: -5px;
|
||||
}
|
||||
.btn_prev, .btn_play, .btn_next {
|
||||
font-family: JetBrainsMono Nerd Font;
|
||||
}
|
||||
.btn_prev {
|
||||
color: #FDFDFD;
|
||||
font-size : 2.6em;
|
||||
}
|
||||
.btn_play {
|
||||
color: #FDFDFD;
|
||||
font-size : 2.6em;
|
||||
font-weight : bold;
|
||||
}
|
||||
.btn_next {
|
||||
color: #FDFDFD;
|
||||
font-size : 2.6em;
|
||||
}
|
||||
.metric-player scale trough highlight {
|
||||
all: unset;
|
||||
border-radius: 10px;
|
||||
background-color: #c3a5e6;
|
||||
}
|
||||
|
||||
.metric-player scale trough {
|
||||
all: unset;
|
||||
background-color: #1D1F28;
|
||||
border:2px solid #454545;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.metric-player scale trough {
|
||||
min-width: 200px;
|
||||
min-height: 10px;
|
||||
margin: .5rem 1rem 0 1rem;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
;; Music Variables
|
||||
(defpoll art :interval "0s" "~/.config/polybar/widgets/MusicPlayer/MediaControl coverloc")
|
||||
(defpoll title :interval "0s" "~/.config/polybar/widgets/MusicPlayer/MediaControl title")
|
||||
(defpoll artist :interval "0s" "~/.config/polybar/widgets/MusicPlayer/MediaControl artist")
|
||||
(defpoll album :interval "0s" "~/.config/polybar/widgets/MusicPlayer/MediaControl album")
|
||||
(defpoll playpause :interval "0s" "~/.config/polybar/widgets/MusicPlayer/MediaControl statusicon")
|
||||
(defpoll songtime :interval "0s" "~/.config/polybar/widgets/MusicPlayer/MediaControl percent")
|
||||
|
||||
;; Music Widgets
|
||||
(defwidget music []
|
||||
(box :class "music-player"
|
||||
:orientation "v"
|
||||
:space-evenly "false"
|
||||
:halign "center"
|
||||
(box :class "album_art"
|
||||
:style "background-image: url('${art}');")
|
||||
(box :orientation "v"
|
||||
:space-evenly "false"
|
||||
:halign "center"
|
||||
:spacing 10
|
||||
(label :class "artist"
|
||||
:limit-width 15
|
||||
:text artist)
|
||||
(label :class "song"
|
||||
:limit-width 20
|
||||
:text title)
|
||||
(box :orientation "h"
|
||||
:space-evenly "false"
|
||||
:halign "center"
|
||||
:spacing 30
|
||||
(button :class "btn_prev" :onclick "~/.config/polybar/widgets/MusicPlayer/MediaControl --previous" "ﭣ")
|
||||
(button :class "btn_play" :onclick "~/.config/polybar/widgets/MusicPlayer/MediaControl --toggle" playpause)
|
||||
(button :class "btn_next" :onclick "~/.config/polybar/widgets/MusicPlayer/MediaControl --next" "ﭡ"))
|
||||
(box :orientation "h"
|
||||
:class "metric-player"
|
||||
:space-evenly "false"
|
||||
(scale :min 0
|
||||
:max 101
|
||||
:active "false"
|
||||
:value {songtime != "" ? "${songtime}" : "0"}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;windows
|
||||
|
||||
(defwindow music
|
||||
:geometry (geometry :x "-470px"
|
||||
:y "-45px"
|
||||
:width "18%"
|
||||
:height "30%"
|
||||
:anchor "bottom right")
|
||||
(music))
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the metadata of the currently playing track
|
||||
metadata=$(playerctl metadata)
|
||||
|
||||
# Extract the required information from the metadata
|
||||
artist=$(echo "$metadata" | grep "xesam:artist" | sed 's/xesam:artist: //')
|
||||
title=$(echo "$metadata" | grep "xesam:title" | sed 's/xesam:title: //')
|
||||
album=$(echo "$metadata" | grep "xesam:album" | sed 's/xesam:album: //')
|
||||
art=$(echo "$metadata" | grep "xesam:artUrl" | sed 's/xesam:artUrl: //')
|
||||
status=$(playerctl status)
|
||||
|
||||
# Determine the playback status
|
||||
if [ "$status" = "Playing" ]; then
|
||||
playback_status=""
|
||||
elif [ "$status" = "Paused" ]; then
|
||||
playback_status=""
|
||||
else
|
||||
playback_status=""
|
||||
fi
|
||||
|
||||
# Calculate the progress of the current track
|
||||
position=$(playerctl position)
|
||||
duration=$(echo "$metadata" | grep "mpris:length" | sed 's/mpris:length: //')
|
||||
progress_bar=$(echo "$position / $duration * 100" | bc -l | awk -F. '{print $1}')
|
||||
|
||||
# Calculate the time elapsed and remaining time
|
||||
time_elapsed=$(printf "%.0f:%.2d" $(echo "$position/60" | bc -l) $(echo "$position%60" | bc -l))
|
||||
time_remaining=$(printf "%.0f:%.2d" $(echo "($duration - $position)/60" | bc -l) $(echo "($duration - $position)%60" | bc -l))
|
||||
|
||||
# Output the music information in JSON format
|
||||
cat <<-EOF
|
||||
{
|
||||
"artist": "$artist",
|
||||
"title": "$title",
|
||||
"album": "$album",
|
||||
"album_art": "$art",
|
||||
"playback_status": "$playback_status",
|
||||
"progress_bar": "$progress_bar",
|
||||
"time_elapsed": "$time_elapsed",
|
||||
"time_remaining": "$time_remaining"
|
||||
}
|
||||
EOF
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
mplayer() {
|
||||
LOCKFILE="$HOME/.cache/eww-cris-mplayer.lock"
|
||||
|
||||
if [[ ! -f "$LOCKFILE" ]]; then
|
||||
touch "$LOCKFILE"
|
||||
eww open music -c ~/.config/polybar/widgets/MusicPlayer/
|
||||
elif [[ -f "$LOCKFILE" ]]; then
|
||||
eww close music -c ~/.config/polybar/widgets/MusicPlayer/
|
||||
rm "$LOCKFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
mplayer
|
||||
Reference in new issue
Block a user