Skip to content

Commit

Permalink
added spotify
Browse files Browse the repository at this point in the history
  • Loading branch information
j4n-r committed Aug 11, 2024
1 parent 028f72e commit 4e4948e
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 7 deletions.
39 changes: 39 additions & 0 deletions .config/gtk-4.0/gtk.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

@define-color accent_bg_color #c4a7e7;
@define-color accent_fg_color #191724;
@define-color accent_color #c4a7e7;

@define-color destructive_bg_color #eb6f92;
@define-color destructive_fg_color #191724;
@define-color destructive_color #eb6f92;

@define-color success_bg_color #9ccfd8;
@define-color success_fg_color #e0def4;
@define-color success_color #9ccfd8;

@define-color warning_bg_color #f6c177;
@define-color warning_fg_color #e0def4;
@define-color warning_color #f6c177;

@define-color error_bg_color #eb6f92;
@define-color error_fg_color #e0def4;
@define-color error_color #eb6f92;

@define-color window_bg_color #191724;
@define-color window_fg_color #e0def4;

@define-color view_bg_color #26233a;
@define-color view_fg_color #e0def4;

@define-color headerbar_bg_color #191724;
@define-color headerbar_fg_color #e0def4;
@define-color headerbar_backdrop_color @window_bg_color;
@define-color headerbar_shade_color #191724;


@define-color card_bg_color #1f1d2e;
@define-color card_fg_color #e0def4;
@define-color card_shade_color #1f1d2e;

@define-color popover_bg_color #26233a;
@define-color popover_fg_color #e0def4;
40 changes: 40 additions & 0 deletions .config/scripts/now-playing
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Default maximum length
default_max_length=26

# Function to trim the info if it exceeds 'max_length' characters
trim_info() {
local info="$1"
local max_length="$2"

if [ ${#info} -gt $max_length ]; then
info="${info:0:$max_length}"
fi

echo "$info"
}

# Parse the command-line argument for max_length
if [[ $1 =~ max_length=([0-9]+) ]]; then
max_length="${BASH_REMATCH[1]}"
else
max_length=$default_max_length
fi

# Check if Spotify is playing
spotify_status=$(playerctl --player=spotify status 2>/dev/null)

if [ "$spotify_status" == "Playing" ]; then
# Get currently playing song from Spotify
info=$(playerctl metadata --player=spotify --format ' {{title}} • {{artist}}')
else
# Get currently playing song from Musikcube
info=$(playerctl metadata --player=musikcube --format ' {{title}} • {{artist}}')
fi

# Add seperator for waybar

# Trim info if necessary and display it
trimmed_info=$(trim_info "$info" "$max_length")
echo "$trimmed_info"
9 changes: 9 additions & 0 deletions .config/scripts/play-next
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

spotify_status=$(playerctl --player=spotify status 2>/dev/null)

if [ "$spotify_status" == "Playing" ]; then
playerctl --player=spotify next
else
playerctl --player=musikcube next
fi
9 changes: 9 additions & 0 deletions .config/scripts/play-previous
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

spotify_status=$(playerctl --player=spotify status 2>/dev/null)

if [ "$spotify_status" == "Playing" ]; then
playerctl --player=spotify previous
else
playerctl --player=musikcube previous
fi
9 changes: 8 additions & 1 deletion .config/waybar/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"spacing": 1,


"modules-left": ["custom/power", "hyprland/workspaces"],
"modules-left": ["custom/power", "hyprland/workspaces", "custom/spotify"],
"modules-center": ["clock"],
"modules-right": ["cpu", "temperature", "memory","battery", "disk", "pulseaudio", "network", "tray"],

Expand All @@ -17,6 +17,13 @@
"format": "{icon}",
"all-outputs": true,
},
"custom/spotify": {
"interval": 1,
"exec": "~/.config/scripts/now-playing",
"on-click": "~/.config/scripts/play-next",
"on-click-right": "~/.config/scripts/play-previous",
"escape": true
},
"tray": {
"icon-size": 18,
"spacing": 5,
Expand Down
22 changes: 22 additions & 0 deletions .config/waybar/modules/spotify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

class=$(playerctl metadata --player=spotify --format '{{lc(status)}}')
icon=""

if [[ $class == "playing" ]]; then
info=$(playerctl metadata --player=spotify --format '{{artist}} - {{title}}')

# Check if the info length exceeds 28 characters
if (( ${#info} > 28 )); then
# Trim info to 28 characters and add ".."
info="${info:0:28}.."
fi

text="$icon $info"
elif [[ $class == "paused" ]]; then
text="$icon"
else
text=""
fi

echo -e "{\"text\":\"$text\", \"class\":\"$class\"}"
3 changes: 1 addition & 2 deletions .config/waybar/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ window#waybar.empty {
background: none;
}


#custom-power {
}

Expand All @@ -56,7 +55,7 @@ window#waybar.empty {
color: @foam;
}


#custom-spotify,
#cpu,
#temperature,
#memory,
Expand Down
6 changes: 3 additions & 3 deletions .config/wofi/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
background: #191724;
margin: auto;
padding: 10px;
border-radius: 20px;
border-radius: 15;
/* border: 2px solid #89b4fa; */
opacity: 0.9;
}

#input {
padding: 10px 20px;
margin-bottom: 10px;
border-radius: 90px;
border-radius: 15;
}

#img {
Expand All @@ -33,7 +33,7 @@

#entry {
padding: 10px;
border-radius: 90px;
border-radius: 15;
border: none;
}

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ is_pacman_available() {
install_packages() {
echo "Installing packages" | tee -a "$LOG_FILE"
# Essentials
sudo pacman -Syu --noconfirm wofi-wayland waybar swaync alacritty tmux ly fzf brightnessctl meson gcc pipewire wireplumber polkit-kde-agent qt5-wayland qt6-wayland gtk4 gtk3 lxappearance acpi tlp tlp-rdw sudo thermald pulseaudio pavucontrol man-db man-pages wl-clipboard curl less openssh reflector unzip wget zip tree base-devel ffmpeg nwg-look stow 2>&1 | tee -a "$LOG_FILE"
sudo pacman -Syu --noconfirm wofi-wayland waybar swaync alacritty tmux ly fzf brightnessctl meson gcc pipewire wireplumber polkit-kde-agent qt5-wayland qt6-wayland gtk4 gtk3 lxappearance acpi tlp tlp-rdw sudo thermald pulseaudio pavucontrol man-db man-pages wl-clipboard curl less openssh reflector unzip wget zip tree base-devel ffmpeg nwg-look stow pulseaudio-bluetooth playerctl spotify-tui spotifyd spotify-launcher2>&1 | tee -a "$LOG_FILE"

echo "Installing development tools..." | tee -a "$LOG_FILE"
sudo pacman -S --noconfirm neovim python ninja cmake clang sqlite postgresql nodejs npm jdk-openjdk maven docker 2>&1 | tee -a "$LOG_FILE"
Expand Down

0 comments on commit 4e4948e

Please sign in to comment.