This commit is contained in:
2023-10-22 06:12:10 +02:00
commit 314ff2f75d
69 changed files with 6951 additions and 0 deletions

76
.config/eww/scripts/audio.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
usage() {
echo "Usage:
$0 <action> <sink|source>
actions: vol"
}
if [ -z $1 ]; then
usage
exit 1
fi
if [ -z $2 ] && [ "$1" != "getdevices" ] && [ "$1" != "getdefaultsink" ]; then
usage
exit 1
fi
vol() {
if [ "$1" == "up" ]; then
vol="5%+"
else
vol="5%-"
fi
wpctl set-volume @DEFAULT_SINK@ $vol
eww update VOLUME_SINK=$(getvol @DEFAULT_SINK@)
}
getvol() {
wpctl get-volume $1 | awk '{print $2}'
}
ismutedsource() {
pactl get-source-mute $1 | awk '{print ($2 == "no"? "false" : "true")}'
}
ismutedsink() {
pactl get-sink-mute $1 | awk '{print ($2 == "no"? "false" : "true")}'
}
mutesink() {
pactl set-sink-mute $1 toggle
eww update IS_MUTED_SINK=$(ismutedsink $1)
}
mutesource() {
pactl set-source-mute $1 toggle
eww update IS_MUTED_SOURCE=$(ismutedsource $1)
}
isblue() {
wpctl inspect $1 | grep api.bluez -q -m 1 && echo true || echo false
}
if [ "$1" == "getdevices" ]; then
pactl -f json list sinks | jq -Mc '[.[] | {id: .index, name: .description, mute: .mute, default: (.state == "RUNNING")}]'
elif [ "$1" == "vol" ]; then
vol $2
elif [ "$1" == "getvol" ]; then
getvol $2
elif [ "$1" == "ismutedsource" ]; then
ismutedsource $2
elif [ "$1" == "ismutedsink" ]; then
ismutedsink $2
elif [ "$1" == "mutesink" ]; then
mutesink $2
elif [ "$1" == "mutesource" ]; then
mutesource $2
elif [ "$1" == "isblue" ]; then
isblue $2
elif [ "$1" == "getdefaultsink" ]; then
wpctl inspect @DEFAULT_SINK@ | grep 'node.description' | awk -F ' = ' '{print $2}' | sed 's/\"//g'
else
usage
fi

28
.config/eww/scripts/battery.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
bat=$(upower -e | grep BAT)
if [ -z $bat ]; then
echo '{}' | jq -Mc ".has_battery = false"
exit 0
fi
upower=$(upower -i $bat)
get_percentage() {
echo "$1" | grep percentage | awk '{print $2}'
}
get_time_remaining() {
echo "$1" | grep "time to empty" | awk -F: '{print $2}'
}
get_icon_name() {
echo "$1" | grep icon-name | awk '{print $2}'
}
is_charging() {
echo "$1" | grep state | awk '{print $2}'
}
echo '{}' | jq -Mc ".has_battery = true | .percentage = \"$(get_percentage "$upower")\" | .time_remaining= \"$(get_time_remaining "$upower")\" | .is_charging = \"$(is_charging "$upower")\" | .icon_name = \"$(get_icon_name "$upower")\" "

View File

@@ -0,0 +1,21 @@
#! /bin/bash
function clamp {
min=$1
max=$2
val=$3
python -c "print(max($min, min($val, $max)))"
}
direction=$1
current=$2
if test "$direction" = "down"
then
target=$(clamp 1 10 $(($current+1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
elif test "$direction" = "up"
then
target=$(clamp 1 10 $(($current-1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
fi

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'

View File

@@ -0,0 +1,3 @@
#!/bin/sh
hyprctl activewindow -j | jq --raw-output .title
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}'

View File

@@ -0,0 +1,10 @@
#!/bin/bash
spaces (){
hyprctl workspaces -j | jq -Mc '[.[] | {id: (.id | tostring), windows: (.windows | tostring)}] | sort_by(.id)'
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View File

@@ -0,0 +1,20 @@
#!/bin/bash
url=$(cat ~/.config/YouTube\ Music/config.json | jq --raw-output .url)
if [ -z "$url" ]; then
exit 1
fi
id="${url##*?v=}"
id="${id%%&*}"
#https://img.youtube.com/vi/$id/[option].jpg
#0
#1
#mqdefault
#hqdefault
#sddefault
#maxresdefault
url="https://img.youtube.com/vi/$id/sddefault.jpg"
curl -o ~/.config/eww/medi_art.jpg "$url"

63
.config/eww/scripts/net.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
usage() {
echo "Usage: $0 <func> [args]
func: islowest[INT], iswlan, ssid"
}
if [ -z $1 ]; then
usage
exit 1
fi
getlowest() {
lines=$(ip route | grep default)
# Initialize variables to store the highest metric and interface
lowest_metric=99999999999
lowest_interface=""
# Loop through the lines and compare metrics
while IFS= read -r line; do
interface=$(echo "$line" | awk '{print $5}')
metric=$(echo "$line" | awk '{for(i=1;i<=NF;i++) if($i=="metric") print $(i+1)}')
if [ "$metric" -lt "$lowest_metric" ]; then
lowest_metric="$metric"
lowest_interface="$interface"
fi
done <<< "$lines"
echo "$lowest_interface"
}
islowest() {
if [ "$(getlowest)" == "$1" ]; then
echo "true"
else
echo "false"
fi
}
iswlan(){
int=$(nmcli -t -f active,ssid,device dev wifi | grep -m 1 yes | awk -F ':' '{print $3}')
if ! [ -z $int ]; then
islowest $int
else
echo "false"
fi
}
if [ "$1" == "iswlan" ]; then
iswlan
elif [ "$1" == "islowest" ]; then
islowest $2
elif [ "$1" == "getint" ]; then
getlowest
elif [ "$1" == "ssid" ]; then
nmcli -t -f active,ssid dev wifi | grep -m 1 yes | awk -F: '{print $2}'
else
usage
fi