From c49a69e6ac7c4da458101fa544ea2431fa134558 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Tue, 29 Dec 2020 17:15:50 -0700 Subject: Fix bugs --- .config/dunst/dunstrc | 4 +- .config/mpd/mpd.conf | 1 + .config/ncmpcpp/config | 78 +--------------- .local/bin/pa_control | 4 +- .local/bin/pctl_status | 110 +++++++++++++++++++---- .local/bin/statusbar/player_mpris_zscroll_module | 51 +++++++---- 6 files changed, 138 insertions(+), 110 deletions(-) diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index 43ca4b6..1a8b231 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -39,13 +39,13 @@ show_indicators = yes ## Icons. - icon_position = off + icon_position = on max_icon_size = 32 icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ ## History. sticky_history = yes - history_length = 20 + history_length = 100 ## Misc advanced. dmenu = /usr/bin/dmenu -p dunst: diff --git a/.config/mpd/mpd.conf b/.config/mpd/mpd.conf index 59ef90e..4ac7cd0 100644 --- a/.config/mpd/mpd.conf +++ b/.config/mpd/mpd.conf @@ -1,3 +1,4 @@ +# Configuration for mpd. db_file "~/.config/mpd/database" music_directory "~/mus" diff --git a/.config/ncmpcpp/config b/.config/ncmpcpp/config index e988b9f..940f16a 100644 --- a/.config/ncmpcpp/config +++ b/.config/ncmpcpp/config @@ -1,6 +1,6 @@ # Directories #ncmpcpp_directory = ~/.config/ncmpcpp -#lyrics_directory = ~/.lyrics +lyrics_directory = ~/.config/ncmpcpp/lyrics # Connection settings mpd_host = localhost @@ -158,104 +158,65 @@ visualizer_color = blue, cyan, green, yellow, magenta, red #song_columns_list_format = (20)[]{a} (6f)[green]{NE} (50)[white]{t|f:Title} (20)[cyan]{b} (7f)[magenta]{l} # Various settings -#execute_on_song_change = "" -# +execute_on_song_change = notify-send -u low " $(mpc --format '[%albumartist% (%album%)]|[%albumartist%]|[%artist% (%album%)]|[%artist%]' current)" "$(mpc --format '%title%' current)" ## ## Note: Custom command that will be executed each time player state ## changes. The environment variable MPD_PLAYER_STATE is set to the current ## state (either unknown, play, pause, or stop) for its duration. ## -# #execute_on_player_state_change = "" -# #playlist_show_mpd_host = no -# #playlist_show_remaining_time = no -# #playlist_shorten_total_times = no -# #playlist_separate_albums = no -# ## ## Note: Possible display modes: classic, columns. ## #playlist_display_mode = columns -# #browser_display_mode = classic -# #search_engine_display_mode = classic -# #playlist_editor_display_mode = classic -# #discard_colors_if_item_is_selected = yes -# #show_duplicate_tags = yes -# #incremental_seeking = yes -# #seek_time = 1 -# #volume_change_step = 2 -# #autocenter_mode = no -# #centered_cursor = no -# ## ## Note: You can specify third character which will be used to build 'empty' ## part of progressbar. ## #progressbar_look = => -# ## Available values: database, playlist. ## #default_place_to_search_in = database -# ## Available values: classic, alternative. ## #user_interface = classic -# #data_fetching_delay = yes -# ## Available values: artist, album_artist, date, genre, composer, performer. ## #media_library_primary_tag = artist -# #media_library_albums_split_by_date = yes -# #media_library_hide_album_dates = no -# ## Available values: wrapped, normal. ## #default_find_mode = wrapped -# #default_tag_editor_pattern = %n - %t -# #header_visibility = yes -# #statusbar_visibility = yes -# ## Show the "Connected to ..." message on startup #connected_message_on_startup = yes -# #titles_visibility = yes -# #header_text_scrolling = yes -# #cyclic_scrolling = no -# -#lyrics_fetchers = azlyrics, genius, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet -# +lyrics_fetchers = azlyrics, genius, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet #follow_now_playing_lyrics = no -# -#fetch_lyrics_for_current_song_in_background = no -# +fetch_lyrics_for_current_song_in_background = yes #store_lyrics_in_song_dir = no -# #generate_win32_compatible_filenames = yes -# #allow_for_physical_item_deletion = no -# ## ## Note: If you set this variable, ncmpcpp will try to get info from last.fm in ## language you set and if it fails, it will fall back to english. Otherwise it @@ -264,11 +225,8 @@ visualizer_color = blue, cyan, green, yellow, magenta, red ## Note: Language has to be expressed as an ISO 639 alpha-2 code. ## #lastfm_preferred_language = en -# #space_add_mode = add_remove -# #show_hidden_files_in_local_browser = no -# ## ## How shall screen switcher work? ## @@ -280,75 +238,50 @@ visualizer_color = blue, cyan, green, yellow, magenta, red ## lyrics, last_fm. ## #screen_switcher_mode = playlist, browser -# ## ## Note: You can define startup screen by choosing screen from the list above. ## #startup_screen = playlist -# ## ## Note: You can define startup slave screen by choosing screen from the list ## above or an empty value for no slave screen. ## #startup_slave_screen = "" -# #startup_slave_screen_focus = no -# ## ## Default width of locked screen (in %). Acceptable values are from 20 to 80. ## -# #locked_screen_width_part = 50 -# #ask_for_locked_screen_width_part = yes -# #jump_to_now_playing_song_at_start = yes -# #ask_before_clearing_playlists = yes -# #clock_display_seconds = no -# #display_volume_level = yes -# #display_bitrate = no -# #display_remaining_time = no -# ## Available values: none, basic, extended, perl. ## #regular_expressions = perl -# ## ## Note: if below is enabled, ncmpcpp will ignore leading "The" word while ## sorting items in browser, tags in media library, etc. ## #ignore_leading_the = no -# ## ## Note: if below is enabled, ncmpcpp will ignore diacritics while searching and ## filtering lists. This takes an effect only if boost was compiled with ICU ## support. ## #ignore_diacritics = no -# #block_search_constraints_change_if_items_found = yes -# #mouse_support = yes -# #mouse_list_scroll_whole_page = no -# #lines_scrolled = 5 -# #empty_tag_marker = -# #tags_separator = " | " -# #tag_editor_extended_numeration = no -# #media_library_sort_by_mtime = no -# #enable_window_title = yes -# ## ## Note: You can choose default search mode for search engine. Available modes ## are: @@ -362,11 +295,8 @@ visualizer_color = blue, cyan, green, yellow, magenta, red ## - 3 - match only exact values (this mode uses mpd function for searching in ## database and local one for searching in current playlist) ## -# #search_engine_default_search_mode = 1 -# #external_editor = nano -# ## Note: set to yes if external editor is a console application. ## #use_console_editor = yes diff --git a/.local/bin/pa_control b/.local/bin/pa_control index b3d566a..1109064 100755 --- a/.local/bin/pa_control +++ b/.local/bin/pa_control @@ -91,10 +91,10 @@ EOF case "$1" in get-sink) - notify-send "Current sink" "$(get_default_sink_nickname)" + notify-send -u low "Current sink" "$(get_default_sink_nickname)" ;; next-sink) set_next_sink - notify-send "Changed to sink" "$(get_default_sink_nickname)" + notify-send -u low "Changed sink" "$(get_default_sink_nickname)" ;; esac diff --git a/.local/bin/pctl_status b/.local/bin/pctl_status index 0eccfb8..bc6af6e 100755 --- a/.local/bin/pctl_status +++ b/.local/bin/pctl_status @@ -1,30 +1,110 @@ -#!/bin/bash +#!/bin/sh -playerctl_status=$(playerctl status 2>/dev/null) -exit_code=$? +get_pctl_status () { + player="$(check_for_mpd)" -if [ $exit_code -eq 0 ]; then - status=$playerctl_status -else - status="NPF" -fi + if [ "$player" = "" ]; then + playerctl_status=$(playerctl status 2>/dev/null) + else + playerctl_status=$(playerctl -p "$player" status 2>/dev/null) + fi + exit_code=$? -case $1 in - status) - echo "$status" - ;; - text) - artist="$(playerctl metadata artist 2>/dev/null)" - title="$(playerctl metadata title 2>/dev/null)" + if [ $exit_code -eq 0 ]; then + echo "$playerctl_status" + else + echo "NPF" + fi +} + +check_for_mpd () { + pctl_players="$(playerctl -l)" + + while IFS= read line; do + line="$(echo $line | sed -e 's/\ //')" + + if [ "$line" = "mpd" ]; then + echo "$line" + fi + done <$artist>$album>$title" + fi + else + if [ "$status" = "Playing" ] || [ "$status" = "Paused" ]; then + artist="$(playerctl metadata artist)" + album="$(playerctl metadata album)" + title="$(playerctl metadata title)" + + if [ "$album" = "" ]; then + echo "no>$artist>$title" + else + echo "yes>$artist>$album>$title" + fi + fi + fi +} + +case $1 in + status) + get_pctl_status + ;; + text) + get_display_text + ;; + get-metadata) + get_metadata ;; esac diff --git a/.local/bin/statusbar/player_mpris_zscroll_module b/.local/bin/statusbar/player_mpris_zscroll_module index 6645e4c..ffe8f36 100755 --- a/.local/bin/statusbar/player_mpris_zscroll_module +++ b/.local/bin/statusbar/player_mpris_zscroll_module @@ -23,29 +23,46 @@ show_panel (){ } send_notification (){ - player_status=$(playerctl status 2> /dev/null) - if [ "$player_status" = "Playing" ]; then - artist="$(playerctl metadata artist)" - album="$(playerctl metadata album)" - title="$(playerctl metadata title)" - - if [ $album = "\n"]; then - notify-send "$icon $artist - $album" "$title" + player_status="$(pctl_status status)" + + metadata="$(pctl_status get-metadata)" + contains_album="$(echo $metadata | cut -d'>' -f1)" + + artist= + album= + title= + + summary= + body= + + pp_icon= + + if [ "$player_status" = "Playing" ] || [ "$player_status" = "Paused" ]; then + if [ "$contains_album" = "yes" ]; then + artist="$(echo $metadata | cut -d'>' -f2)" + album="$(echo $metadata | cut -d'>' -f3)" + title="$(echo $metadata | cut -d'>' -f4)" + + summary="$artist ($album)" + body="$title" + else - notify-send "$icon $artist" "$title" + artist="$(echo $metadata | cut -d'>' -f2)" + title="$(echo $metadata | cut -d'>' -f3)" + + summary="$artist" + body="$title" fi - elif [ "$player_status" = "Paused" ]; then - artist="$(playerctl metadata artist)" - album="$(playerctl metadata album)" - title="$(playerctl metadata title)" - if [ $album = "\n"]; then - notify-send "$icon (Paused) $artist - $album" "$title" + if [ "$player_status" = "Playing" ]; then + pp_icon="" else - notify-send "$icon (Paused) $artist" "$title" + pp_icon="" fi + + notify-send -u low "$icon $pp_icon $summary" "$body" else - notify-send "$icon Nothing playing" + notify-send -u low "$icon Nothing playing" fi } -- cgit v1.2.3-54-g00ecf