This commit is contained in:
2025-08-13 21:46:48 +02:00
commit c3e2e6509b
818 changed files with 54187 additions and 0 deletions

11
hypr/scripts/autostart/apps Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Apps
#spotify &
#vesktop &
#thunderbird &
#obsidian &
# Terminal Apps
#kitty --class btop btop &
#kitty --class nvtop nvtop &

38
hypr/scripts/autostart/services Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Automounter for removable media
udiskie &
# Wallpaper Backend
swww-daemon --format xrgb &
# Pyprland Daemon
pypr --debug /tmp/pypr.log &
# Bar
waybar &
# Notification Daemon
swaync &
# OSD Window
swayosd-server &
# Notify about devices connecting and disconnecting
devify &
# Idle daemon to screen lock
hypridle &
# Clipboard
wl-paste --watch cliphist store &
# Polkit authentication
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
# Screen sharing and portals
"$HOME"/.config/hypr/portal &
# xwaylandvideobridge & # Off when using Vesktop instead of Discord
# Audio
easyeffects --gapplication-service &

16
hypr/scripts/color_picker Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Simple Script To Pick Color Quickly.
# pick, autocopy and get the value
color=$(hyprpicker -a)
echo "$color"
if [[ "$color" ]]; then
image=/tmp/${color}.png
# generate preview
convert -size 48x48 xc:"$color" "$image"
# notify the color
notify-send -i "$image" "$color" "Copied to clipboard"
fi

5
hypr/scripts/current_song Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
song_info=$(playerctl metadata --format '󰎈 {{artist}} - {{title}} 󰎈')
echo "$song_info"

223
hypr/scripts/hyprfreeze Executable file
View File

@@ -0,0 +1,223 @@
#!/bin/bash
function printHelp() {
cat <<EOF
Usage: hyprfreeze (-a | -p <pid> | -n <name> | -r) [options]
Utility to suspend a game process (and other programs) in Hyprland.
Options:
-h, --help show help message
-a, --active toggle suspend by active window
-p, --pid toggle suspend by process id
-n, --name toggle suspend by process name/command
-r, --prop toggle suspend by clicking on window (hyprprop must be installed)
-s, --silent don't send notification
-t, --notif-timeout notification timeout in milliseconds (default 5000)
--info show information about the process
--dry-run doesn't actually suspend/resume a process, useful with --info
--debug enable debug mode
EOF
}
function debugPrint() {
if [ "$DEBUG" -eq 1 ]; then
echo "[DEBUG] $1"
fi
}
function toggleFreeze() {
# Skip this function if --dry-run flag was provided
if [[ $DRYRUN == "1" ]]; then return 0; fi
# Get pids of process tree
PIDS=$(pstree -p "$PID" | grep -oP '\(\K[^\)]+')
debugPrint "PIDs: $PIDS"
# Prevent suspending itself
local pid_of_script=$$
if echo "$PIDS" | grep -q "$pid_of_script"; then
echo "You are trying to suspend the hyprfreeze process."
exit 1
fi
# Suspend or resume processes
if [[ "$(ps -o state= "$PID")" == T ]]; then
debugPrint "Resuming processes..."
kill -CONT $PIDS 2>/dev/null && echo "Resumed $(ps -p "$PID" -o comm= 2>/dev/null) (PID $PID)" || exit 1
else
debugPrint "Suspending processes..."
kill -STOP $PIDS 2>/dev/null && echo "Suspended $(ps -p "$PID" -o comm= 2>/dev/null) (PID $PID)" || exit 1
fi
}
function getPidByActive() {
debugPrint "Getting PID by active window..."
PID=$(hyprctl activewindow -j | jq '.pid')
debugPrint "PID by active window: $PID"
}
function getPidByPid() {
debugPrint "Getting PID by PID: $1"
# Check if process pid exists
if ! ps -p "$1" &>/dev/null; then
echo "Process ID $1 not found"
exit 1
fi
PID=$1
}
function getPidByName() {
debugPrint "Getting PID by name: $1"
# Check if process name exists
if ! pidof -x "$1" >/dev/null; then
echo "Process name $1 not found"
exit 1
fi
# Get last process if there are multiple
PID=$(pidof "$1" | awk '{print $NF}')
debugPrint "PID by name: $PID"
}
function getPidByProp() {
debugPrint "Getting PID by prop..."
if ! command -v hyprprop; then
echo "You need to install 'hyprprop' to use this feature. (https://github.com/vilari-mickopf/hyprprop)"
exit 1
fi
PID=$(hyprprop | jq '.pid')
debugPrint "PID by prop: $PID"
}
function printInfo() {
debugPrint "Printing process info...\n"
echo -e "$(tput bold)Process tree:$(tput sgr0)"
ps -p "$PID" 2>/dev/null && pstree -p "$PID"
echo -e "\n$(tput bold)Process threads:$(tput sgr0)"
ps -eLo pid,tid,comm | grep "$PID" 2>/dev/null
echo -e "\n$(tput bold)Process ID$(tput sgr0) = $PID \
\n$(tput bold)Process name$(tput sgr0) = $(ps -p "$PID" -o comm= 2>/dev/null) \
\n$(tput bold)Process state$(tput sgr0) = $(ps -o state= -p "$PID" 2>/dev/null)\n"
}
function sendNotification() {
debugPrint "Sending notification..."
local title
title=$([[ "$(ps -p "$PID" -o state=)" == T ]] &&
echo "Suspended $(ps -p "$PID" -o comm= 2>/dev/null)" ||
echo "Resumed $(ps -p "$PID" -o comm= 2>/dev/null)")
local message="PID $PID"
notify-send "${title}" "${message}" -t "$NOTIF_TIMEOUT" -a Hyprfreeze
}
function args() {
# Track required flags
local required_flag_count=0
# Parse options
local options="hap:n:rst:"
local long_options="help,active,pid:,name:,prop,silent,notif-timeout:,info,dry-run,debug"
local parsed_args
parsed_args=$(getopt -o "$options" --long "$long_options" -n "$(basename "$0")" -- "$@")
eval set -- "$parsed_args"
while true; do
case $1 in
-h | --help)
printHelp
exit 0
;;
-a | --active)
((required_flag_count++))
FLAG_ACTIVE=true
;;
-p | --pid)
((required_flag_count++))
shift
FLAG_PID="$1"
;;
-n | --name)
((required_flag_count++))
shift
NAME_FLAG="$1"
;;
-r | --prop)
((required_flag_count++))
FLAG_PROP=true
;;
-s | --silent)
SILENT=1
;;
-t | --notif-timeout)
shift
NOTIF_TIMEOUT="$1"
;;
--info)
INFO=1
;;
--dry-run)
DRYRUN=1
;;
--debug)
DEBUG=1
;;
--)
shift # Skip -- argument
break
;;
*)
exit 1
;;
esac
shift
done
# Check if more than one required flag is provided, or if none was provided
if [ $required_flag_count -ne 1 ]; then
printHelp
exit 1
fi
}
function main() {
debugPrint "Starting main function..."
# Get pid by a required flag
if [ "$FLAG_ACTIVE" = true ]; then
getPidByActive
elif [ -n "$FLAG_PID" ]; then
getPidByPid "$FLAG_PID"
elif [ -n "$NAME_FLAG" ]; then
getPidByName "$NAME_FLAG"
elif [ "$FLAG_PROP" = true ]; then
getPidByProp
fi
# Suspend or resume process
toggleFreeze
# Run these functions after PID is obtained
if [ $INFO -eq 1 ]; then printInfo; fi
if [ $SILENT -ne 1 ]; then sendNotification; fi
debugPrint "End of main function."
}
SILENT=0
NOTIF_TIMEOUT=5000
INFO=0
DRYRUN=0
DEBUG=0
args "$@"
main

354
hypr/scripts/hyprshot Executable file
View File

@@ -0,0 +1,354 @@
#!/bin/bash
set -e
function Help() {
cat <<EOF
Usage: hyprshot [options ..] [-m [mode] ..] -- [command]
Hyprshot is an utility to easily take screenshot in Hyprland using your mouse.
It allows taking screenshots of windows, regions and monitors which are saved to a folder of your choosing and copied to your clipboard.
Examples:
capture a window \`hyprshot -m window\`
capture active window to clipboard \`hyprshot -m window -m active --clipboard-only\`
capture selected monitor \`hyprshot -m output -m DP-1\`
Options:
-h, --help show help message
-m, --mode one of: output, window, region, active, OUTPUT_NAME
-o, --output-folder directory in which to save screenshot
-f, --filename the file name of the resulting screenshot
-D, --delay how long to delay taking the screenshot after selection (seconds)
-z, --freeze freeze the screen on initialization
-d, --debug print debug information
-s, --silent don't send notification when screenshot is saved
-r, --raw output raw image data to stdout
-t, --notif-timeout notification timeout in milliseconds (default 5000)
--border-width width of the selection border in pixels (default 0)
--border-color color of the selection border (default #181926)
--background-color color around the selection (default #8087a25a)
--clipboard-only copy screenshot to clipboard and don't save image in disk
-- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage
Modes:
output take screenshot of an entire monitor
window take screenshot of an open window
region take screenshot of selected region
active take screenshot of active window|output
(you must use --mode again with the intended selection)
OUTPUT_NAME take screenshot of output with OUTPUT_NAME
(you must use --mode again with the intended selection)
(you can get this from \`hyprctl monitors\`)
EOF
}
function Print() {
if [ $DEBUG -eq 0 ]; then
return 0
fi
1>&2 printf "$@"
}
function send_notification() {
if [ $SILENT -eq 1 ]; then
return 0
fi
local message=$([ $CLIPBOARD -eq 1 ] &&
echo "Image copied to the clipboard" ||
echo "Image saved in <i>${1}</i> and copied to the clipboard.")
action=$(notify-send -i "$1" --action="view=View" --action="edit=Edit" --action="folder=Open on Folder" "Screenshot saved" \
"${message}" \
-t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot)
case $action in
"view")
xdg-open "$1"
;;
"edit")
if command -v satty &>/dev/null; then
satty -f "$1"
else
notify-send -u critical "Cannot Edit Image" "Install Satty"
fi
;;
"folder")
nemo "$1"
;;
esac
}
function trim() {
Print "Geometry: %s\n" "${1}"
local geometry="${1}"
local xy_str=$(echo "${geometry}" | cut -d' ' -f1)
local wh_str=$(echo "${geometry}" | cut -d' ' -f2)
local x=$(echo "${xy_str}" | cut -d',' -f1)
local y=$(echo "${xy_str}" | cut -d',' -f2)
local width=$(echo "${wh_str}" | cut -dx -f1)
local height=$(echo "${wh_str}" | cut -dx -f2)
local max_width=$(hyprctl monitors -j | jq -r '[.[] | if (.transform % 2 == 0) then (.x + .width) else (.x + .height) end] | max')
local max_height=$(hyprctl monitors -j | jq -r '[.[] | if (.transform % 2 == 0) then (.y + .height) else (.y + .width) end] | max')
local min_x=$(hyprctl monitors -j | jq -r '[.[] | (.x)] | min')
local min_y=$(hyprctl monitors -j | jq -r '[.[] | (.y)] | min')
local cropped_x=$x
local cropped_y=$y
local cropped_width=$width
local cropped_height=$height
if ((x + width > max_width)); then
cropped_width=$((max_width - x))
fi
if ((y + height > max_height)); then
cropped_height=$((max_height - y))
fi
if ((x < min_x)); then
cropped_x="$min_x"
cropped_width=$((cropped_width + x - min_x))
fi
if ((y < min_y)); then
cropped_y="$min_y"
cropped_height=$((cropped_height + y - min_y))
fi
local cropped=$(printf "%s,%s %sx%s\n" \
"${cropped_x}" "${cropped_y}" \
"${cropped_width}" "${cropped_height}")
Print "Crop: %s\n" "${cropped}"
echo ${cropped}
}
function save_geometry() {
local geometry="${1}"
local output=""
if [ $RAW -eq 1 ]; then
grim -g "${geometry}" -
return 0
fi
if [ $CLIPBOARD -eq 0 ]; then
mkdir -p "$SAVEDIR"
grim -g "${geometry}" "$SAVE_FULLPATH"
output="$SAVE_FULLPATH"
wl-copy --type image/png <"$output"
[ -z "$COMMAND" ] || {
"$COMMAND" "$output"
}
else
wl-copy --type image/png < <(grim -g "${geometry}" -)
fi
send_notification $output
}
function checkRunning() {
sleep 1
while [[ 1 == 1 ]]; do
if [[ $(pgrep slurp | wc -m) == 0 ]]; then
pkill hyprpicker
exit
fi
done
}
function begin_grab() {
if [ $FREEZE -eq 1 ] && [ "$(command -v "hyprpicker")" ] >/dev/null 2>&1; then
sleep 0.2
hyprpicker -r -z &
sleep 0.2
HYPRPICKER_PID=$!
fi
local option=$1
case $option in
output)
if [ $CURRENT -eq 1 ]; then
local geometry=$(grab_active_output)
elif [ -z $SELECTED_MONITOR ]; then
local geometry=$(grab_output)
else
local geometry=$(grab_selected_output $SELECTED_MONITOR)
fi
;;
region)
local geometry=$(grab_region)
;;
window)
if [ $CURRENT -eq 1 ]; then
local geometry=$(grab_active_window)
else
local geometry=$(grab_window)
fi
geometry=$(trim "${geometry}")
;;
esac
if [ ${DELAY} -gt 0 ] 2>/dev/null; then
sleep ${DELAY}
fi
save_geometry "${geometry}"
}
function grab_output() {
slurp -or
}
function grab_active_output() {
local active_workspace=$(hyprctl -j activeworkspace)
local monitors=$(hyprctl -j monitors)
Print "Monitors: %s\n" "$monitors"
Print "Active workspace: %s\n" "$active_workspace"
local current_monitor="$(echo $monitors | jq -r 'first(.[] | select(.activeWorkspace.id == '$(echo $active_workspace | jq -r '.id')'))')"
Print "Current output: %s\n" "$current_monitor"
echo $current_monitor | jq -r '"\(.x),\(.y) \(.width/.scale|round)x\(.height/.scale|round)"'
}
function grab_selected_output() {
local monitor=$(hyprctl -j monitors | jq -r '.[] | select(.name == "'$(echo $1)'")')
Print "Capturing: %s\n" "${1}"
echo $monitor | jq -r '"\(.x),\(.y) \(.width/.scale|round)x\(.height/.scale|round)"'
}
function grab_region() {
slurp -d -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH
}
function grab_window() {
local monitors=$(hyprctl -j monitors)
local clients=$(hyprctl -j clients | jq -r '[.[] | select(.workspace.id | contains('$(echo $monitors | jq -r 'map(.activeWorkspace.id) | join(",")')'))]')
Print "Monitors: %s\n" "$monitors"
Print "Clients: %s\n" "$clients"
# Generate boxes for each visible window and send that to slurp
# through stdin
local boxes="$(echo $clients | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1]) \(.title)"' | cut -f1,2 -d' ')"
Print "Boxes:\n%s\n" "$boxes"
slurp -r -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH <<<"$boxes"
}
function grab_active_window() {
local active_window=$(hyprctl -j activewindow)
local box=$(echo $active_window | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | cut -f1,2 -d' ')
Print "Box:\n%s\n" "$box"
echo "$box"
}
function parse_mode() {
local mode="${1}"
case $mode in
window | region | output)
OPTION=$mode
;;
active)
CURRENT=1
;;
*)
hyprctl monitors -j | jq -re '.[] | select(.name == "'$(echo $mode)'")' &>/dev/null
SELECTED_MONITOR=$mode
;;
esac
}
function args() {
local options=$(getopt -o hf:o:m:D:dszr:t: --long help,filename:,output-folder:,mode:,delay:,clipboard-only,debug,silent,freeze,raw,notif-timeout:,border-color:,background-color:,border-width: -- "$@")
eval set -- "$options"
while true; do
case "$1" in
-h | --help)
Help
exit
;;
-o | --output-folder)
shift
SAVEDIR=$1
;;
-f | --filename)
shift
FILENAME=$1
;;
-D | --delay)
shift
DELAY=$1
;;
-m | --mode)
shift
parse_mode $1
;;
--clipboard-only)
CLIPBOARD=1
;;
-d | --debug)
DEBUG=1
;;
-z | --freeze)
FREEZE=1
;;
-s | --silent)
SILENT=1
;;
-r | --raw)
RAW=1
;;
-t | --notif-timeout)
shift
NOTIF_TIMEOUT=$1
;;
--border-color)
shift
BORDER_COLOR=$1
;;
--background-color)
shift
BACKGROUND_COLOR=$1
;;
--border-width)
shift
BORDER_WIDTH=$1
;;
--)
shift # Skip -- argument
COMMAND=${@:2}
break
;;
esac
shift
done
if [ -z $OPTION ]; then
Print "A mode is required\n\nAvailable modes are:\n\toutput\n\tregion\n\twindow\n"
exit 2
fi
}
if [ -z $1 ]; then
Help
exit
fi
CLIPBOARD=0
DEBUG=0
SILENT=0
RAW=0
NOTIF_TIMEOUT=5000
CURRENT=0
FREEZE=0
BORDER_COLOR=\#181926
BACKGROUND_COLOR=\#8087a25a
BORDER_WIDTH=0
[ -z "$XDG_PICTURES_DIR" ] && type xdg-user-dir &>/dev/null && XDG_PICTURES_DIR=$(xdg-user-dir PICTURES)
FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')"
[ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR}
args $0 "$@"
SAVE_FULLPATH="$SAVEDIR/$FILENAME"
[ $CLIPBOARD -eq 0 ] && Print "Saving in: %s\n" "$SAVE_FULLPATH"
begin_grab $OPTION &
checkRunning

14
hypr/scripts/launch_app Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
if [ -z "$1" ]; then
exit 1
fi
program="$1"
if ! command -v "$program" >/dev/null 2>&1; then
notify-send "Program not found" "Make sure you have installed $program"
exit 1
else
exec $@
fi

19
hypr/scripts/lock Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/bash
swaylock --screenshots --indicator --clock \
--inside-wrong-color $(~/.config/hypr/scripts/color 1 -n) \
--ring-wrong-color $(~/.config/hypr/scripts/color background -n) \
--inside-clear-color $(~/.config/hypr/scripts/color 2 -n) \
--ring-clear-color $(~/.config/hypr/scripts/color background -n) \
--inside-ver-color $(~/.config/hypr/scripts/color 4 -n) \
--ring-ver-color $(~/.config/hypr/scripts/color background -n) \
--text-color $(~/.config/hypr/scripts/color 5 -un) \
--key-hl-color $(~/.config/hypr/scripts/color 4 -un) \
--indicator-radius 80 \
--indicator-thickness 5 \
--effect-blur 10x7 \
--effect-vignette 0.2:0.2 \
--ring-color 11111b \
--line-color 313244 \
--inside-color 0011111b \
--separator-color 00000000 \
--fade-in 0.1 &

23
hypr/scripts/move_by_rules Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Script created by: https://github.com/moguay
# Retrieve the active class of the window
active_class=$(hyprctl -j activewindow | jq '.class')
active_class=$(echo "$active_class" | tr -d \")
# Read the file and store lines containing 'workspace' in an array
grep 'workspace' ~/.config/hypr/themes/luna/rules.conf | while IFS= read -r line; do
workspace_value=$(echo "$line" | sed -n -e 's/^.*workspace \([0-9]*\)[ ,].*$/\1/p')
class_value=$(echo "$line" | sed -n -e 's/^.*class:\s*\(.*\)$/\1/p')
regex=$class_value
if [ -n "$workspace_value" ] && [ -n "$class_value" ]; then
# Compare the retrieved value with the active class of the window
if echo "$active_class" | grep -E "$regex"; then
#echo "The class matches the active class of the window. Workspace value to apply: $workspace_value"
hyprctl dispatch movetoworkspace "$workspace_value"
fi
fi
done
exit 1

29
hypr/scripts/performance Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env sh
HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==2{print $2}')
# Waybar performance
FILE="$HOME/.config/waybar/style.css"
sed -i 's/\/\* \(.*animation:.*\) \*\//\1/g' $FILE
if [ "$HYPRGAMEMODE" = 1 ]; then
sed -i 's/^\(.*animation:.*\)$/\/\* \1 \*\//g' $FILE
fi
killall waybar
waybar > /dev/null 2>&1 &
# Hyprland performance
if [ "$HYPRGAMEMODE" = 1 ]; then
hyprctl --batch "\
keyword animations:enabled 0;\
keyword decoration:drop_shadow 0;\
keyword decoration:blur:enabled 0;\
keyword general:gaps_in 0;\
keyword general:gaps_out 0;\
keyword general:border_size 1;\
keyword decoration:rounding 0"
exit
fi
hyprctl reload > /dev/null 2>&1 &

9
hypr/scripts/portal Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
sleep 1
killall -e xdg-desktop-portal-hyprland
killall -e xdg-desktop-portal-wlr
killall xdg-desktop-portal
/usr/lib/xdg-desktop-portal-hyprland &
sleep 2
/usr/lib/xdg-desktop-portal &

11
hypr/scripts/random_wallpaper Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/bash
random=$(fd --base-directory "$HOME/.config/hypr/theme/walls/" --type f . | shuf -n 1)
wallpaper="$HOME/.config/hypr/theme/walls/$random"
swww img "$wallpaper" \
--transition-bezier 0.5,1.19,.8,.4 \
--transition-type wipe \
--transition-duration 2 \
--transition-fps 75 && notify-send "Wallpaper Changed" -i "$wallpaper" --app-name=Wallpaper

31
hypr/scripts/toggle_floating Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
floating=$(hyprctl activewindow -j | jq '.floating')
window=$(hyprctl activewindow -j | jq '.initialClass' | tr -d "\"")
function toggle() {
width=$1
height=$2
hyprctl --batch "dispatch togglefloating; dispatch resizeactive exact ${width} ${height}; dispatch centerwindow"
}
function untoggle() {
hyprctl dispatch togglefloating
}
function handle() {
width=$1
height=$2
if [ "$floating" == "false" ]; then
toggle "$width" "$height"
else
untoggle
fi
}
case $window in
kitty) handle "50%" "55%" ;;
*) handle "70%" "70%" ;;
esac