add hyprland configs

This commit is contained in:
2025-07-06 17:59:26 +03:00
parent efc031f339
commit f85000910a
102 changed files with 5841 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#!/bin/bash
# Get the current battery percentage
battery_percentage=$(cat /sys/class/power_supply/BAT0/capacity)
# Get the battery status (Charging or Discharging)
battery_status=$(cat /sys/class/power_supply/BAT0/status)
# Define the battery icons for each 10% segment
battery_icons=("󰂃" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰁹")
# Define the charging icon
charging_icon="󰂄"
# Calculate the index for the icon array
icon_index=$((battery_percentage / 10))
# Get the corresponding icon
battery_icon=${battery_icons[icon_index]}
# Check if the battery is charging
if [ "$battery_status" = "Charging" ]; then
battery_icon="$charging_icon"
fi
# Output the battery percentage and icon
echo "$battery_percentage% $battery_icon"

View File

@@ -0,0 +1,28 @@
#!/bin/env bash
THUMB=/tmp/hyde-mpris
THUMB_BLURRED=/tmp/hyde-mpris-blurred
THUMB_RECTANGLE=/tmp/blurred_rectangle.png
fetch_thumb() {
artUrl=$(playerctl -p spotify metadata --format '{{mpris:artUrl}}')
[[ "${artUrl}" = "$(cat "${THUMB}.inf")" ]] && return 0
printf "%s\n" "$artUrl" > "${THUMB}.inf"
curl -so "${THUMB}.png" "$artUrl"
magick "${THUMB}.png" -quality 50 "${THUMB}.png"
# Create blurred version
magick "${THUMB}.png" -blur 200x7 -resize 1920x^ -gravity center -extent 1920x1080\! "${THUMB_BLURRED}.png"
magick -size 800x200 xc:none -fill black -draw "rectangle 0,0 800,200" -blur 0x3 "${THUMB_RECTANGLE}"
# fi
pkill -USR2 hyprlock
}
# if [ ! -f "${THUMB_RECTANGLE}" ]; then
# magick -size 800x200 xc:none -fill black -draw "rectangle 0,0 800,200" -blur 0x3 "${THUMB_RECTANGLE}"
# fi
# Run fetch_thumb function in the background
{ playerctl -p spotify metadata --format '{{title}}  {{artist}}' && fetch_thumb ;} || { rm -f "${THUMB}*" && exit 1;} &

View File

@@ -0,0 +1,9 @@
#! /bin/bash
if [[ "$(playerctl -p spotify status)" = "Playing" ]]; then
hyprlock --config ~/.config/hyprlock/music.conf
else :
hyprlock
fi

View File

@@ -0,0 +1,27 @@
#!/bin/bash
# Get the current battery percentage
battery_percentage=$(cat /sys/class/power_supply/BAT0/capacity)
# Get the battery status (Charging or Discharging)
battery_status=$(cat /sys/class/power_supply/BAT0/status)
# Define the battery icons for each 10% segment
battery_icons=("󰂃" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰁹")
# Define the charging icon
charging_icon="󰂄"
# Calculate the index for the icon array
icon_index=$((battery_percentage / 10))
# Get the corresponding icon
battery_icon=${battery_icons[icon_index]}
# Check if the battery is charging
if [ "$battery_status" = "Charging" ]; then
battery_icon="$charging_icon"
fi
# Output the battery percentage and icon
echo "$battery_percentage% $battery_icon"

View File

@@ -0,0 +1,23 @@
#!/bin/bash
cache_file="$HOME/.cache/ip_cache.txt"
if [ ! -f "$cache_file" ]; then
mkdir -p "$(dirname "$cache_file")" # Create .cache directory if it doesn't exist
touch "$cache_file"
fi
last_modified=$(stat -c %Y "$cache_file")
current_date=$(date +%s)
time_diff=$((current_date - last_modified))
expiry_time=86400
cached_data=$(<"$cache_file")
if [ $time_diff -lt $expiry_time ] && [ -n "$cached_data" ]; then
echo "$cached_data"
exit
fi
response=$(curl -s ipinfo.io 2>/dev/null | jq -r '.country + ", " + .city' 2>/dev/null)
city=$response
echo "$city" >"$cache_file"

View File

@@ -0,0 +1,150 @@
#!/bin/env bash
THUMB=/tmp/hyde-mpris
THUMB_BLURRED=/tmp/hyde-mpris-blurred
if [ $# -eq 0 ]; then
echo "Usage: $0 --title | --arturl | --artist | --position | --length | --album | --source"
exit 1
fi
# Function to get metadata using playerctl
get_metadata() {
key=$1
playerctl metadata --format "{{ $key }}" 2>/dev/null
}
# 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" == *"YoutubeMusic"* ]]; then
echo -e "YouTubeMusic "
else
echo ""
fi
}
# Function to get position using playerctl
get_position() {
playerctl position 2>/dev/null
}
# Function to convert microseconds to minutes and seconds
convert_length() {
local length=$1
local seconds=$((length / 1000000))
local minutes=$((seconds / 60))
local remaining_seconds=$((seconds % 60))
printf "%d:%02d m" $minutes $remaining_seconds
}
# Function to convert seconds to minutes and seconds
convert_position() {
local position=$1
local seconds=${position%.*} # Remove fractional part if exists
local minutes=$((seconds / 60))
local remaining_seconds=$((seconds % 60))
printf "%d:%02d" $minutes $remaining_seconds
}
# Function to fetch album art and create blurred version
fetch_thumb() {
artUrl=$(playerctl -p spotify metadata --format '{{mpris:artUrl}}')
[[ "${artUrl}" = "$(cat "${THUMB}.inf")" ]] && return 0
printf "%s\n" "$artUrl" > "${THUMB}.inf"
curl -so "${THUMB}.png" "$artUrl"
magick "${THUMB}.png" -quality 50 "${THUMB}.png"
# Create blurred version
magick "${THUMB}.png" -blur 200x7 -resize 1920x^ -gravity center -extent 1920x1080\! "${THUMB_BLURRED}.png"
pkill -USR2 hyprlock
}
# Run fetch_thumb function in the background
{ fetch_thumb ;} || { rm -f "${THUMB}*" && exit 1;} &
# Parse the argument
case "$1" in
--title)
title=$(get_metadata "xesam:title")
if [ -z "$title" ]; then
echo ""
else
echo "${title:0:50}" # Limit the output to 50 characters
fi
;;
# --arturl)
# fetch_thumb & # Run fetch_thumb in the background
# url=$(get_metadata "mpris:artUrl")
# if [[ "$(playerctl -p status)" != "Playing" ]]; then
# rm -f /tmp/hyde-mpris*
# fi
# ;;
--artist)
artist=$(get_metadata "xesam:artist")
if [ -z "$artist" ]; then
echo ""
else
echo "${artist:0:50}" # Limit the output to 50 characters
fi
;;
--position)
position=$(get_position)
length=$(get_metadata "mpris:length")
if [ -z "$position" ] || [ -z "$length" ]; then
echo ""
else
position_formatted=$(convert_position "$position")
length_formatted=$(convert_length "$length")
echo "$position_formatted/$length_formatted"
fi
;;
--length)
length=$(get_metadata "mpris:length")
if [ -z "$length" ]; then
echo ""
else
convert_length "$length"
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 | --arturl | --artist | --position | --length | --album | --source" ; exit 1
;;
esac

View File

@@ -0,0 +1,148 @@
#!/bin/env bash
THUMB=/tmp/hyde-mpris
THUMB_BLURRED=/tmp/hyde-mpris-blurred
if [ $# -eq 0 ]; then
echo "Usage: $0 --title | --arturl | --artist | --position | --length | --album | --source"
exit 1
fi
# Function to get metadata using playerctl
get_metadata() {
key=$1
playerctl metadata --format "{{ $key }}" 2>/dev/null
}
# 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" == *"YoutubeMusic"* ]]; then
echo -e "YouTubeMusic "
else
echo ""
fi
}
# Function to get position using playerctl
get_position() {
playerctl position 2>/dev/null
}
# Function to convert microseconds to minutes and seconds
convert_length() {
local length=$1
local seconds=$((length / 1000000))
local minutes=$((seconds / 60))
local remaining_seconds=$((seconds % 60))
printf "%d:%02d m" $minutes $remaining_seconds
}
# Function to convert seconds to minutes and seconds
convert_position() {
local position=$1
local seconds=${position%.*} # Remove fractional part if exists
local minutes=$((seconds / 60))
local remaining_seconds=$((seconds % 60))
printf "%d:%02d" $minutes $remaining_seconds
}
# Function to fetch album art and create blurred version
fetch_thumb() {
artUrl=$(playerctl -p spotify metadata --format '{{mpris:artUrl}}')
[[ "${artUrl}" = "$(cat "${THUMB}.inf")" ]] && return 0
printf "%s\n" "$artUrl" > "${THUMB}.inf"
curl -so "${THUMB}.png" "$artUrl"
magick "${THUMB}.png" -quality 50 "${THUMB}.png"
# Create blurred version
pkill -USR2 hyprlock
}
# Run fetch_thumb function in the background
{ fetch_thumb ;} || { rm -f "${THUMB}*" && exit 1;} &
# Parse the argument
case "$1" in
--title)
title=$(get_metadata "xesam:title")
if [ -z "$title" ]; then
echo ""
else
echo "${title:0:50}" # Limit the output to 50 characters
fi
;;
# --arturl)
# fetch_thumb & # Run fetch_thumb in the background
# url=$(get_metadata "mpris:artUrl")
# if [[ "$(playerctl -p status)" != "Playing" ]]; then
# rm -f /tmp/hyde-mpris*
# fi
# ;;
--artist)
artist=$(get_metadata "xesam:artist")
if [ -z "$artist" ]; then
echo ""
else
echo "${artist:0:50}" # Limit the output to 50 characters
fi
;;
--position)
position=$(get_position)
length=$(get_metadata "mpris:length")
if [ -z "$position" ] || [ -z "$length" ]; then
echo ""
else
position_formatted=$(convert_position "$position")
length_formatted=$(convert_length "$length")
echo "$position_formatted/$length_formatted"
fi
;;
--length)
length=$(get_metadata "mpris:length")
if [ -z "$length" ]; then
echo ""
else
convert_length "$length"
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 | --arturl | --artist | --position | --length | --album | --source" ; exit 1
;;
esac

View File

@@ -0,0 +1,23 @@
#!/bin/bash
cache_file="$HOME/.cache/wttr_cache.txt"
if [ ! -f "$cache_file" ]; then
mkdir -p "$(dirname "$cache_file")" # Create .cache directory if it doesn't exist
touch "$cache_file"
fi
last_modified=$(stat -c %Y "$cache_file")
current_date=$(date +%s)
time_diff=$((current_date - last_modified))
expiry_time=86400
cached_data=$(<"$cache_file")
if [ $time_diff -lt $expiry_time ] && [ -n "$cached_data" ]; then
echo "$cached_data"
exit
fi
response=$(curl -s wttr.in?format=%c+%C+%t 2>/dev/null)
city=$response
echo "$city" >"$cache_file"