This commit is contained in:
jjohnstondev 2023-01-19 17:54:30 -08:00
commit 47b1fb41e9
5 changed files with 129 additions and 0 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2023 abs3nt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

51
README.md Normal file
View File

@ -0,0 +1,51 @@
# Tmux Spotify-TUI plugin
Plugin that shows current playing song with [gospt](https://gitea.asdf.cafe/abs3nt/gospt).
![Screenshot](https://user-images.githubusercontent.com/86447830/213586650-1a1d67c6-c029-4724-b8c2-f027deb16bb4.png)
### Usage
```tmux.conf
set -g status-right '#{now_playing}'
```
### Installation with Tmux Plugin Manager (Recommended)
Add plugin to the list of TPM plugins:
```tmux.conf
set -g @plugin 'abs3ntdev/tmux-gospt'
```
Press prefix + I to install it.
### Manual Installation
Clone the repo:
```bash
$ git clone https://github.com/abs3ntdev/tmux-gospt ~/clone/path
```
Add this line to your .tmux.conf:
```tmux.conf
run-shell ~/clone/path/actual_song.tmux
```
Reload TMUX environment with:
```bash
$ tmux source-file ~/.tmux.conf
```
or:
Press prefix + R to install it.
___
### License
[MIT](LICENSE)

27
actual_song.tmux Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
now_playing="#($CURRENT_DIR/scripts/get_now_playing.sh)"
now_playing_interpolation_string="\#{now_playing}"
source $CURRENT_DIR/scripts/shared.sh
do_interpolation() {
local string="$1"
local interpolated="${string/$now_playing_interpolation_string/$now_playing}"
echo "$interpolated"
}
update_tmux_option() {
local option="$1"
local option_value="$(get_tmux_option "$option")"
local new_option_value="$(do_interpolation "$option_value")"
set_tmux_option "$option" "$new_option_value"
}
main() {
update_tmux_option "status-right"
update_tmux_option "status-left"
}
main

14
scripts/get_now_playing.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
song="$(gospt nowplaying)"
if [[ $song =~ ['⏸'] ]]; then
echo$song | sed 's/[⏸▶]//g'
else
echo $song | sed 's/[⏸▶]//g'
fi

16
scripts/shared.sh Normal file
View File

@ -0,0 +1,16 @@
get_tmux_option() {
local option=$1
local default_value=$2
local option_value=$(tmux show-option -gqv "$option")
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}
set_tmux_option() {
local option="$1"
local value="$2"
tmux set-option -gq "$option" "$value"
}