Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spotify and weather script #87

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bin/pping.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function _ping() {
local url="$1"
local ping_output=$(ping -c 1 $url 2>/dev/null | sed -n '2p')
if [[ $ping_output =~ time=([0-9.]+) ]]; then

local ping_time=${BASH_REMATCH[1] }
ping_time=$(echo "$ping_time" | tr -d ',' | awk -F '.' '{print $1}')
echo '󰇖 '"${url}" "${ping_time}ms"
else
echo '󰇖 '"${url}" "Error"
fi
}

# Comprobamos si se ha proporcionado la ciudad como argumento
if [ -z "$1" ]; then
echo "Por favor, proporciona el nombre de la ciudad como argumento."
exit 1
fi

result=$(_ping "$1")
echo $result
11 changes: 11 additions & 0 deletions bin/spotify.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if application "Spotify" is running then
tell application "Spotify"
set theName to name of the current track
set theArtist to artist of the current track
set theAblum to album of the current track
try
return "♫ " & theName & " - " & theArtist
on error err
end try
end tell
end if
22 changes: 22 additions & 0 deletions bin/weather.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#v1.0

get_weather() {
local city="$1"
local url="wttr.in/$city?format=%c%t%20%h%20%p%20"
local weather_output=$(curl -s "$url")
echo "$weather_output"
}

# Comprobamos si se ha proporcionado la ciudad como argumento
if [ -z "$1" ]; then
echo "Por favor, proporciona el nombre de la ciudad como argumento."
exit 1
fi

# Llamamos a la función pasando la ciudad proporcionada como argumento
result=$(get_weather "$1")

# Imprimimos el resultado
#echo "Pronóstico del tiempo en $1:"
echo "$result"
Binary file added img/nord_status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions nord.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ NORD_TMUX_COLOR_THEME_FILE=src/nord.conf
NORD_TMUX_VERSION=0.3.0
NORD_TMUX_STATUS_CONTENT_FILE="src/nord-status-content.conf"
NORD_TMUX_STATUS_CONTENT_NO_PATCHED_FONT_FILE="src/nord-status-content-no-patched-font.conf"
# NORD_TMUX_STATUS_CONTENT_SPOTIFY_SCRIPT="bin/spotify.scpt"
# NORD_TMUX_STATUS_SHOW_SPOTIFY="@nord_tmux_show_spotify"
NORD_TMUX_STATUS_CONTENT_OPTION="@nord_tmux_show_status_content"
NORD_TMUX_STATUS_CONTENT_DATE_FORMAT="@nord_tmux_date_format"
NORD_TMUX_NO_PATCHED_FONT_OPTION="@nord_tmux_no_patched_font"
Expand All @@ -15,10 +17,12 @@ __cleanup() {
unset -v NORD_TMUX_STATUS_CONTENT_FILE NORD_TMUX_STATUS_CONTENT_NO_PATCHED_FONT_FILE
unset -v NORD_TMUX_STATUS_CONTENT_OPTION NORD_TMUX_NO_PATCHED_FONT_OPTION
unset -v NORD_TMUX_STATUS_CONTENT_DATE_FORMAT
# unset -v NORD_TMUX_STATUS_CONTENT_SPOTIFY_SCRIPT NORD_TMUX_STATUS_SHOW_SPOTIFY
unset -v _current_dir
unset -f __load __cleanup
tmux set-environment -gu NORD_TMUX_STATUS_TIME_FORMAT
tmux set-environment -gu NORD_TMUX_STATUS_DATE_FORMAT
# tmux set-environment -gu NORD_TMUX_STATUS_SHOW_SPOTIFY
}

__load() {
Expand All @@ -27,6 +31,9 @@ __load() {
local status_content=$(tmux show-option -gqv "$NORD_TMUX_STATUS_CONTENT_OPTION")
local no_patched_font=$(tmux show-option -gqv "$NORD_TMUX_NO_PATCHED_FONT_OPTION")
local date_format=$(tmux show-option -gqv "$NORD_TMUX_STATUS_CONTENT_DATE_FORMAT")
# local show_spotify=$(tmux show-option -gqv "$NORD_TMUX_STATUS_SHOW_SPOTIFY")
# local os_type=$(uname)
# local spotify_song=$(osascript $_current_dir/$NORD_TMUX_STATUS_CONTENT_SPOTIFY_SCRIPT)

if [ "$(tmux show-option -gqv "clock-mode-style")" == '12' ]; then
tmux set-environment -g NORD_TMUX_STATUS_TIME_FORMAT "%I:%M %p"
Expand All @@ -40,6 +47,23 @@ __load() {
tmux set-environment -g NORD_TMUX_STATUS_DATE_FORMAT "$date_format"
fi

# :()
# It only runs once, doesn't update when changing the track on Spotify, the idea is abandoned.
# if [ "$show_spotify" != "0" ]; then # show song
# if [ "$os_type" = "Darwin" ]; then # os type
# if ! [ -z "$spotify_song" ]; then # playing song
# tmux set-environment -g NORD_TMUX_STATUS_SPOTIFY "$spotify_song"
# else
# tmux set-environment -g NORD_TMUX_STATUS_SPOTIFY "󰝛" #music off
# fi
# else
# tmux set-environment -g NORD_TMUX_STATUS_SPOTIFY "Sorry, only macOS plugin" #show message
# fi
# else
# tmux set-environment -g NORD_TMUX_STATUS_SPOTIFY "♫" #no show
# fi


if [ "$status_content" != "0" ]; then
if [ "$no_patched_font" != "1" ]; then
tmux source-file "$_current_dir/$NORD_TMUX_STATUS_CONTENT_FILE"
Expand Down
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@
</a>
</p>


## Personalization
* Display currently playing track: The script can retrieve and display information about the currently playing track on Spotify, such as the song name, artist, and album.
* Display weather: wttr.in is a popular open-source weather service that provides weather information.
* Pomodoro timer can be a great way to manage your time effectively while working on tasks or projects.

<p align="center">
<a href="https://www.nordtheme.com/ports/tmux" target="_blank">
<img src="./img/nord_status.png"/>
</a>
</p>


## Getting Started

Visit the [official website][nord-home] to learn all about the [fluidly merging appearance][nord-home#intro] features, details and elements of [UI elements][nord-home#ui-elements], the [various theme configurations][nord-home#configurations] and the [support for plugins][nord-home#plugin-support].
Expand Down
16 changes: 9 additions & 7 deletions src/nord-status-content.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
#+----------------+
#+ Plugin Support +
#+----------------+
#+--- tmux-prefix-highlight ---+
set -g @prefix_highlight_output_prefix "#[fg=brightcyan]#[bg=black]#[nobold]#[noitalics]#[nounderscore]#[bg=brightcyan]#[fg=black]"
set -g @prefix_highlight_output_suffix ""
set -g @prefix_highlight_copy_mode_attr "fg=brightcyan,bg=black,bold"
#+--- tmux-prefix-highlight ---+
set -g @prefix_highlight_output_prefix "#[fg=brightcyan]#[bg=black]#[nobold]#[noitalics]#[nounderscore]#[bg=brightcyan]#[fg=black]"
set -g @prefix_highlight_output_suffix ""
set -g @prefix_highlight_copy_mode_attr "fg=brightcyan,bg=black,bold"

#+--------+
#+ Status +
#+--------+
#+--- Bars ---+
set -g status-left "#[fg=black,bg=blue,bold] #S #[fg=blue,bg=black,nobold,noitalics,nounderscore]"
set -g status-right "#{prefix_highlight}#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_DATE_FORMAT} #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_TIME_FORMAT} #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]#[fg=black,bg=cyan,bold] #H "
set -g status-left "#[fg=black,bg=blue,bold] #S #[fg=blue,bg=black,nobold,noitalics,nounderscore] "
#set -g status-right "#{prefix_highlight}#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] #(~/.config/tmux/plugins/nord-tmux/bin/weather.sh Buenos+Aires)#[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] #(osascript ~/.config/tmux/plugins/nord-tmux/bin/spotify.scpt) #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] #{pomodoro_status} #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_DATE_FORMAT} #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_TIME_FORMAT} #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]#[fg=black,bg=cyan,bold] #H "
set -g status-right "#{prefix_highlight}#[fg=brightblack,bg=black,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#(osascript ~/.config/tmux/plugins/nord-tmux/bin/spotify.scpt) #[fg=white,bg=brightblack]#{pomodoro_status}#[fg=brightblack,bg=brightblack,nobold,noitalics,nounderscore] #[fg=white,bg=brightblack]#(~/.config/tmux/plugins/nord-tmux/bin/weather.sh Buenos+Aires)#[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_DATE_FORMAT} #[fg=white,bg=brightblack,nobold,noitalics,nounderscore]#[fg=white,bg=brightblack] ${NORD_TMUX_STATUS_TIME_FORMAT} #[fg=cyan,bg=brightblack,nobold,noitalics,nounderscore]#[fg=black,bg=cyan,bold] #H "


#+--- Windows ---+
set -g window-status-format "#[fg=black,bg=brightblack,nobold,noitalics,nounderscore] #[fg=white,bg=brightblack]#I #[fg=white,bg=brightblack,nobold,noitalics,nounderscore] #[fg=white,bg=brightblack]#W #F #[fg=brightblack,bg=black,nobold,noitalics,nounderscore]"
set -g window-status-current-format "#[fg=black,bg=cyan,nobold,noitalics,nounderscore] #[fg=black,bg=cyan]#I #[fg=black,bg=cyan,nobold,noitalics,nounderscore] #[fg=black,bg=cyan]#W #F #[fg=cyan,bg=black,nobold,noitalics,nounderscore]"
set -g window-status-separator ""
set -g window-status-separator ""