From 371032027034f028bb4ddb000efc88286ab4bf13 Mon Sep 17 00:00:00 2001 From: OCbwoy3 Date: Mon, 7 Apr 2025 11:46:19 +0300 Subject: [PATCH] wip --- config/hypr/hyprlock.conf | 215 ++++++++++++++++++++++++------- scripts/modules/hyprlock/info.sh | 111 ++++++++++++++++ 2 files changed, 279 insertions(+), 47 deletions(-) create mode 100755 scripts/modules/hyprlock/info.sh diff --git a/config/hypr/hyprlock.conf b/config/hypr/hyprlock.conf index 5fe2a57..aa5c7cd 100644 --- a/config/hypr/hyprlock.conf +++ b/config/hypr/hyprlock.conf @@ -1,56 +1,177 @@ +# GENERAL general { - ignore_empty_input = true - immediate_render = true - no_fade_in = tue - no_fade_out = true + no_fade_in = true + disable_loading_bar = false + hide_cursor = true + ignore_empty_input = true + text_trim = true } +#BACKGROUND background { - blur_size = 3 - blur_passes = 1 + monitor = +# path = ~/wallpaper.png + path = screenshot + blur_passes = 2 + contrast = 0.8916 + brightness = 0.7172 + vibrancy = 0.1696 + vibrancy_darkness = 0 } +# TIME HR +label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%H")" + color = rgba(255, 255, 255, 1) + shadow_pass = 2 + shadow_size = 3 + shadow_color = rgb(0,0,0) + shadow_boost = 1.2 + font_size = 150 +# font_family = JetBrains Mono Nerd Font Mono ExtraBold + font_family = Symbols Nerd Font, Geist Mono + position = 0, -250 + halign = center + valign = top +} + +# TIME +label { + monitor = + text = cmd[update:1000] echo -e "$(date +"%M")" +# color = 0xff$color0 + color = rgba(255, 255, 255, 1) + font_size = 150 +# font_family = JetBrains Mono Nerd Font Mono ExtraBold + font_family = Symbols Nerd Font, Geist Mono + position = 0, -420 + halign = center + valign = top +} + +# DATE +label { + monitor = + text = cmd[update:1000] echo -e "$(LC_TIME=lv_LV.UTF-8 date +"%A, %-d. %B" | sed 's/./\U&/1')" + color = rgba(255, 255, 255, 1) + font_size = 14 + font_family = Symbols Nerd Font, Geist + position = 0, -130 + halign = center + valign = center +} + +# Music +image { + monitor = + path = + size = 80 # lesser side if not 1:1 ratio + rounding = 5 # negative values mean circle + border_size = 0 + rotate = 0 # degrees, counter-clockwise + reload_time = 2 + reload_cmd = bash ~/config/scripts/modules/hyprlock/info.sh --arturl + position = -150, -300 + halign = center + valign = center + opacity=0.5 +} + +# PLAYER TITTLE +label { + monitor = +# text = cmd[update:1000] echo "$(playerctl metadata --format "{{ xesam:title }}" 2>/dev/null | cut -c1-25)" + text = cmd[update:1000] echo "$(bash ~/config/scripts/modules/hyprlock/info.sh --title)" + color = rgba(255, 255, 255, 0.8) + font_size = 12 + font_family = Symbols Nerd Font, Geist + position = 880, -290 + halign = left + valign = center +} + +# PLAYER Length +label { + monitor = +# text= cmd[update:1000] echo "$(( $(playerctl metadata --format "{{ mpris:length }}" 2>/dev/null) / 60000000 ))m" + text = cmd[update:1000] echo "$(bash ~/config/scripts/modules/hyprlock/info.sh --length) " + color = rgba(255, 255, 255, 1) + font_size = 11 + font_family = Symbols Nerd Font, Geist + position = -730, -310 + halign = right + valign = center +} + +# PLAYER STATUS +label { + monitor = +# text= cmd[update:1000] echo "$(( $(playerctl metadata --format "{{ mpris:length }}" 2>/dev/null) / 60000000 ))m" + text = cmd[update:1000] echo "$(bash ~/config/scripts/modules/hyprlock/info.sh --status)" + color = rgba(255, 255, 255, 1) + font_size = 14 + font_family = Symbols Nerd Font, Geist + position = -740, -290 + halign = right + valign = center +} +# PLAYER SOURCE +label { + monitor = +# text= cmd[update:1000] echo "$(playerctl metadata --format "{{ mpris:trackid }}" 2>/dev/null | grep -Eo "chromium|firefox|spotify")" + text = cmd[update:1000] echo "$(bash ~/config/scripts/modules/hyprlock/info.sh --source)" + color = rgba(255, 255, 255, 0.6) + font_size = 10 + font_family = Symbols Nerd Font, Geist + position = -740, -330 + halign = right + valign = center +} + +# PLAYER ALBUM +label { + monitor = +# text= cmd[update:1000] echo "$(~/.config/hypr/bin/album.sh)" + text = cmd[update:1000] echo "$(bash ~/config/scripts/modules/hyprlock/info.sh --album)" + color = rgba(255, 255, 255, 1) + font_size = 10 + font_family = Symbols Nerd Font, Geist + position = 880, -330 + halign = left + valign = center +} +# PLAYER Artist +label { + monitor = +# text = cmd[update:1000] echo "$(playerctl metadata --format "{{ xesam:artist }}" 2>/dev/null | cut -c1-30)" + text = cmd[update:1000] echo "$(bash ~/config/scripts/modules/hyprlock/info.sh --artist)" + color = rgba(255, 255, 255, 0.8) + font_size = 10 + font_family = Symbols Nerd Font, Geist + position = 880, -310 + halign = left + valign = center +} + +# INPUT FIELD input-field { - monitor = - rounding = 0 - size = 800, 100 - outline_thickness = 4 - dots_size = 0.5 - dots_rounding = 0 - dots_spacing = 0.2 - dots_center = true - fade_on_empty = false - placeholder_text = LOGIN - hide_input = false - fail_text = Wrong password! - position = 0, 0 - dots_fade_time = 0 - dots_text_format = 0 - halign = center - valign = center - font_family = Geist Mono - outer_color = rgba(0, 0, 0, 0) - inner_color = rgba(0, 0, 0, 0) - font_color = rgb(255, 0, 0) -} - -label { - text = cmd[update:1000] if [[ $ATTEMPTS -gt 0 ]]; then echo "Password hint: Favourite Regretevator character"; else echo "$TIME - $LAYOUT"; fi - font_family = Geist - color = rgb(255, 0, 0) - position = 10, -10 - halign = center - font_size = 12 - valign = top -} - -label { - text = cmd[update:1000] playerctl metadata -sf "{{artist}} - {{title}}
{{album}}" - font_family = Geist - color = rgb(255, 0, 0) - position = 10, -10 - halign = left - font_size = 12 - valign = top + monitor = + size = 250, 60 + outline_thickness = 0 + outer_color = rgba(0, 0, 0, 1) + dots_size = 0.1 # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 1 # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true + inner_color = rgba(0, 0, 0, 1) + font_color = rgba(200, 200, 200, 1) + fade_on_empty = false + font_family = Symbols Nerd Font, Geist Mono + placeholder_text =  $USER + hide_input = false + position = 0, -470 + halign = center + valign = center + zindex = 10 } diff --git a/scripts/modules/hyprlock/info.sh b/scripts/modules/hyprlock/info.sh new file mode 100755 index 0000000..8072f01 --- /dev/null +++ b/scripts/modules/hyprlock/info.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +# https://gist.github.com/ashish-kus/dd562b0bf5e8488a09e0b9c289f4574c + +if [ $# -eq 0 ]; then + echo "Usage: $0 --title | --arturl | --artist | --length | --album | --source" + exit 1 +fi + +# Function to get metadata using playerctl +get_metadata() { + key=$1 + playerctl metadata --format "{{ $key }}" 2>/dev/null +} + +# Check for arguments + +# Function to determine the source and return an icon and text +get_source_info() { + trackid=$(get_metadata "mpris:trackid") + if [[ "$trackid" == *"firefox"* ]]; then + echo -e "Firefox 󰈹" + elif [[ "$trackid" == *"spotify"* ]]; then + echo -e "Spotify " + elif [[ "$trackid" == *"chromium"* ]]; then + echo -e "Chrome " + elif [[ "$trackid" == *"cider"* ]]; then + echo -e "Apple Music " # added + else + echo "" + fi +} + +# Parse the argument +case "$1" in +--title) + title=$(get_metadata "xesam:title") + if [ -z "$title" ]; then + echo "" + else + echo "${title:0:28}" # Limit the output to 50 characters + fi + ;; +--arturl) + url=$(get_metadata "mpris:artUrl") + if [ -z "$url" ]; then + echo "" + else + if [[ "$url" == file://* ]]; then + url=${url#file://} + elif [[ "$url" == http* ]]; then + url="${url/640x640/1024x1024}" + hash=$(echo -n "$url" | sha256sum | awk '{print $1}') + file_path="/tmp/${hash}.jpg" + if [[ ! -f "$file_path" ]]; then + curl -s --compressed --connect-timeout 2 -m 5 -o "$file_path" "$url" & + fi + url="file://$file_path" + fi + echo "$url" + fi + ;; +--artist) + artist=$(get_metadata "xesam:artist") + if [ -z "$artist" ]; then + echo "" + else + echo "${artist:0:30}" # Limit the output to 50 characters + fi + ;; +--length) + length=$(get_metadata "mpris:length") + if [ -z "$length" ]; then + echo "" + else + # Convert length from microseconds to a more readable format (seconds) + echo "$(echo "scale=2; $length / 1000000 / 60" | bc) m" + fi + ;; +--status) + status=$(playerctl status 2>/dev/null) + if [[ $status == "Playing" ]]; then + echo "󰎆" + elif [[ $status == "Paused" ]]; then + echo "󱑽" + else + echo "" + fi + ;; +--album) + album=$(playerctl metadata --format "{{ xesam:album }}" 2>/dev/null) + if [[ -n $album ]]; then + echo "$album" + else + status=$(playerctl status 2>/dev/null) + if [[ -n $status ]]; then + echo "Not album" + else + echo "" + fi + fi + ;; +--source) + get_source_info + ;; +*) + echo "Invalid option: $1" + echo "Usage: $0 --title | --url | --artist | --length | --album | --source" + exit 1 + ;; +esac