mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-26 15:14:58 +08:00
media: Optionally use rofi to save the current song in the chosen playlist
This commit is contained in:
parent
3934007c53
commit
fc678f1766
4 changed files with 19 additions and 5 deletions
|
|
@ -42,6 +42,7 @@ case "$eww_sidebar_page" in
|
||||||
declare -A keybinds=(
|
declare -A keybinds=(
|
||||||
["q"]="$eww/playerctl-current stop"
|
["q"]="$eww/playerctl-current stop"
|
||||||
["f"]="$eww/media-add-to-favorites.sh"
|
["f"]="$eww/media-add-to-favorites.sh"
|
||||||
|
["F"]="$eww/media-add-to-favorites.sh select-playlist"
|
||||||
["space"]="$eww/playerctl-current play-pause"
|
["space"]="$eww/playerctl-current play-pause"
|
||||||
["p"]="playerctl -a pause"
|
["p"]="playerctl -a pause"
|
||||||
["slash"]="$eww/rofi-playerctl-switch.sh"
|
["slash"]="$eww/rofi-playerctl-switch.sh"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,18 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# This script assumes you are saving your favorite songs in a text file like a
|
# This script assumes you are saving your favorite songs in text files like a
|
||||||
# caveman.
|
# caveman.
|
||||||
favorites_file="$HOME/mus/playlists/songs"
|
rofi="$HOME/.config/eww/scripts/rofi-with-mode-restore sidebar"
|
||||||
|
playlists_dir="$HOME/mus/playlists"
|
||||||
|
if [ "$1" == "select-playlist" ]; then
|
||||||
|
selected="$(find "$playlists_dir" -mindepth 1 -type f -exec basename {} \; | $rofi -dmenu -p "Select playlist to save to >")"
|
||||||
|
if [[ "$selected" == "" ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
selected="songs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
full_path="$playlists_dir/$selected"
|
||||||
|
|
||||||
# Get current media information displayed in eww
|
# Get current media information displayed in eww
|
||||||
eww_media_json="$(eww get media-json)"
|
eww_media_json="$(eww get media-json)"
|
||||||
|
|
@ -9,6 +20,6 @@ artist="$(jq -r '.artist' <<< "$eww_media_json")"
|
||||||
title="$(jq -r '.title' <<< "$eww_media_json")"
|
title="$(jq -r '.title' <<< "$eww_media_json")"
|
||||||
|
|
||||||
line="${artist} - ${title}"
|
line="${artist} - ${title}"
|
||||||
echo "$line" >> "$favorites_file"
|
echo "$line" >> "$full_path"
|
||||||
|
|
||||||
notify-send.sh -u low -R /tmp/eww-media-favorites-notif "Added to favorites" "$line"
|
notify-send.sh -u low -R /tmp/eww-media-favorites-notif "Added to $selected playlist" "$line"
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,8 @@
|
||||||
(box :class "container gameboy-a"
|
(box :class "container gameboy-a"
|
||||||
(eventbox
|
(eventbox
|
||||||
:cursor "hand2"
|
:cursor "hand2"
|
||||||
:onclick "${eww-scripts}/media-add-to-favorites.sh"
|
:onclick "${eww-scripts}/media-add-to-favorites.sh &"
|
||||||
|
:onrightclick "${eww-scripts}/media-add-to-favorites.sh select-playlist &"
|
||||||
(box :class "button favorite"
|
(box :class "button favorite"
|
||||||
:valign "center"
|
:valign "center"
|
||||||
(box :class "symbol" "")))))))))
|
(box :class "symbol" "")))))))))
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ mode "_sidebar" {
|
||||||
o exec "$eww/do-sidebar-keybind o"
|
o exec "$eww/do-sidebar-keybind o"
|
||||||
q exec "$eww/do-sidebar-keybind q"
|
q exec "$eww/do-sidebar-keybind q"
|
||||||
f exec "$eww/do-sidebar-keybind f"
|
f exec "$eww/do-sidebar-keybind f"
|
||||||
|
Shift+f exec "$eww/do-sidebar-keybind F"
|
||||||
m exec "$eww/do-sidebar-keybind m"
|
m exec "$eww/do-sidebar-keybind m"
|
||||||
v exec "$eww/do-sidebar-keybind v"
|
v exec "$eww/do-sidebar-keybind v"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue