initial commit

This commit is contained in:
pika 2025-03-08 19:35:35 +01:00
parent c6326a45e6
commit cebf404919
15 changed files with 757 additions and 0 deletions

3
.scripts/a.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash --norc
notify-send "TEST" "This is supposed to be a rather long testmessage, for testing stlying, and size configs for swaync. The notification daemon."

129
.scripts/init.sh Executable file
View file

@ -0,0 +1,129 @@
#!/bin/sh
pkill swaync
# Paths and configuration
SCRIPTS_DIR="$HOME/.config/hypr/.scripts"
# Logging helper
log_notify() {
level="$1" # e.g., low, normal, critical
title="$2"
message="$3"
notify-send -u "$level" "$title" "$message"
}
# Initialize system modules
initialize_modules() {
# ─< hyprpanel, waybar, gBar >────────────────────────────────────────────────────────────
bar="hyprpanel"
modules="
copyq
nwg-look
swww
$bar
wob
redshift
"
for module in $modules; do
if command -v "$module" >/dev/null 2>&1; then
log_notify "low" "$module" "Initializing..."
case $module in
waybar | flameshot)
pkill "$module" 2>/dev/null
"$module" &
;;
hyprpanel)
hyprpanel &
;;
copyq)
pkill copyq 2>/dev/null
copyq --start-server
sleep 1
if ! pgrep -x copyq >/dev/null; then
log_notify "critical" "ERROR" "CopyQ failed to start. Retrying..."
copyq --start-server
fi
;;
lxappearance)
lxappearance >/dev/null 2>&1 &
;;
swww)
swww-daemon &
if ! swww query; then
swww init
fi
;;
redshift)
pkill redshift 2>/dev/null
sh "$SCRIPTS_DIR/redshift.sh"
;;
wob)
fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob"
rm -f "$fifo"
mkfifo "$fifo"
tail -f "$fifo" | wob &
;;
esac
else
log_notify "critical" "ERROR" "$module not found!"
fi
sleep 0.5
done
log_notify "normal" "INFO" "System modules initialized."
}
# Start polkit authentication agent
initialize_polkit() {
agents="
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
/usr/lib/polkit-kde-authentication-agent-1
/usr/libexec/polkit-gnome-authentication-agent-1
/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
/usr/lib/polkit-1/polkit-agent-helper-1
"
for agent in $agents; do
if [ -x "$agent" ]; then
log_notify "normal" "INFO" "Starting Polkit agent: $(basename "$agent")"
"$agent" &
return 0
fi
done
log_notify "low" "WARNING" "No Polkit authentication agent found. Please install one."
return 1
}
# Initialize XDG desktop portals
initialize_xdg_portals() {
xdg_hyprland="/usr/lib/xdg-desktop-portal-hyprland"
xdg_portal="/usr/lib/xdg-desktop-portal"
if [ -x "$xdg_hyprland" ]; then
killall xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal 2>/dev/null
sleep 1
"$xdg_hyprland" &
sleep 1
"$xdg_portal" &
sleep 1
dbus-update-activation-environment --systemd --all &
log_notify "normal" "INFO" "XDG desktop portals initialized."
else
log_notify "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it."
fi
}
# Main initialization function
main() {
sleep 0.5
initialize_xdg_portals
initialize_modules
initialize_polkit
}
main

38
.scripts/looking-glass.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/sh
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
check_root() {
_sudo=""
if [ "$(id -u)" -ne 0 ]; then
if command_exists sudo; then
notify-send "looking-glass script" "User is not root. Using sudo for privileged operations."
_sudo="sudo"
else
notify-send "looking-glass script" "No sudo found and you're not root! Can't install packages."
return 1
fi
else
notify-send "looking-glass script" "Root access confirmed."
_sudo=""
fi
}
# Define the name of your VM
VM_NAME="win11"
connect="looking-glass-client -f /dev/shm/looking-glass -F -S input:rawMouse=yes -k"
# Check if the VM is running
if pgrep -f "qemu.*$VM_NAME" >/dev/null; then
notify-send "win11" "VM is already there, connecting now.."
sleep 1.5
$connect
else
notify-send "win11" "VM is currently DOWN. Starting it and connecting then.. Be patient.."
# Start the VM (adjust the command according to your setup)
# Example for starting with libvirt:
$_sudo virsh start "$VM_NAME"
# Example for starting with a direct QEMU command:
# qemu-system-x86_64 -enable-kvm -m 4G -cpu host -smp 4 -hda /path/to/win11.img &
# Wait a moment to ensure the VM starts properly
sleep 5 && $connect
fi

86
.scripts/random_swww.sh Executable file
View file

@ -0,0 +1,86 @@
#!/bin/bash --norc
# ╭───────────────╮
# │ SWWW-settings │
# ╰───────────────╯
export SWWW_TRANSITION_FPS=60
export SWWW_TRANSITION_STEP=60
export SWWW_TRANSITION=center
# ╭───────────────────────────────────────────────────────────────────────────╮
# │ Set default excluded directories if SWWW_EXCLUDED_DIRS is not already set │
# │ Dirs to exclude: Anime, Colorful, Gaming, Gifs, Gruvbox, Logos, Muted, │
# │ Nordic, Windoof │
# ╰───────────────────────────────────────────────────────────────────────────╯
: "${SWWW_EXCLUDED_DIRS:=Anime,Colorful,Gaming,Gifs,Logos,Nordic,Windoof}"
_swww() {
if [ -z "$1" ]; then
# ─< random wallpaper selection >─────────────────────────────────────────────────────────
local wall_dir="$HOME/.wallpapers"
# ─< Create an array of directories to exclude >──────────────────────────────────────────
IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS"
# ─< Build the find command with exclusions >─────────────────────────────────────────────
local find_cmd="find \"$wall_dir\" -type f \( -iname \"*.png\" -o -iname \"*.jpg\" -o -iname \"*.gif\" -o -iname \"*.PNG\" -o -iname \"*.JPG\" -o -iname \"*.GIF\" \) -not -path \"*/\.git/*\""
for dir in "${EXCLUDED_DIRS[@]}"; do
find_cmd+=" -not -path \"$wall_dir/$dir/*\""
done
# ─< Select a random picture >────────────────────────────────────────────────────────────
local pic=$(eval $find_cmd | shuf -n 1)
# ─< checking for swww >──────────────────────────────────────────────────────────────────
if command -v swww >/dev/null 2>&1; then
# ─< Check if swww daemon is running, start if not >─────────────────────────────────────
if ! pgrep -x "swww" >/dev/null; then
notify-send "SWWW" "swww not running - starting it now"
swww-daemon
sleep 1 # Give the daemon a second to start
if pgrep -x "swww" >/dev/null; then
notify-send "SWWW" "started successfully"
else
notify-send "ERROR" "seems like swww didn't come up as exspected"
fi
fi
# ─< checking the wall_dir variable >─────────────────────────────────────────────────────
if [[ -d "$wall_dir" ]]; then
# ─< executing swww with the random $pic >────────────────────────────────────────────────
swww img "$pic"
# --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"
notify-send "󰸉 " "Changed wallpaper to $pic"
notify-send " " "Not sourcing from: $SWWW_EXCLUDED_DIRS"
else
notify-send "ERROR" "$wall_dir path not found"
fi
else
notify-send "ERROR" "swww was not found on the system"
fi
else
if command -v swww >/dev/null 2>&1; then
# ─< Check if swww daemon is running, start if not >─────────────────────────────────────
if ! pgrep -x "swww" >/dev/null; then
notify-send "SWWW" "swww not running - starting it now"
swww-daemon
sleep 1 # Give the daemon a second to start
if pgrep -x "swww" >/dev/null; then
notify-send "SWWW" "started successfully"
else
notify-send "ERROR" "seems like swww didn't come up as exspected"
fi
fi
# ─< executing swww with the random $pic >────────────────────────────────────────────────
swww img "$1"
# --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"
notify-send "󰸉 " "Changed wallpaper to $1"
else
notify-send "ERROR" "$1 not found"
fi
fi
}
_swww "$@"

31
.scripts/redshift.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash --norc
# Check if the given command exists silently
command_exists() {
command -v "$@" >/dev/null 2>&1
}
_rdshft() {
# color temperature for redshift
local temp="5200"
if command_exists redshift; then
pkill redshift redshift
sleep 1
pkill redshift redshift-gtk &&
redshift -P -O "$temp"
# redshift -P -O "$temp"
# Check if redshift is running
sleep 2
if ! pgrep -x redshift-gtk >/dev/null && ! pgrep -x redshift >/dev/null; then
notify-send -u critical "ERROR" "Redshift failed to start. Please check your configuration."
else
notify-send -u normal "INFO" "Redshift started successfully."
fi
else
notify-send -u critical "ERROR" "Redshift is not installed. Please install it for better screen color management."
fi
}
_rdshft

118
.scripts/refresh.sh Executable file
View file

@ -0,0 +1,118 @@
#!/bin/bash
# ─< scriptdir declaration >──────────────────────────────────────────────────────────────
_scripts="$HOME/.config/hypr/.scripts"
# ─< Check if the given command exists silently >─────────────────────────────────────────
command_exists() {
command -v "$@" >/dev/null 2>&1
}
_wallpaper() {
if command -v swww >/dev/null 2>&1; then
if [ -e "$_scripts/random_swww.sh" ]; then
$_scripts/random_swww.sh
else
notify-send -u normal "" "script for initializing wallpaper with swww is missing.."
fi
else
notify-send -u low "" "There may be no wallpaper bc swww is missing!"
fi
}
_kill_() {
# ─< Kill already running processes >─────────────────────────────────────────────────────
hyprpanel="gjs" # since hyprpanel has so many different wordings, making it clear that this is currently the hyprpanel service name
_ps=(gBar wofi swaync waybar $hyprpanel)
for _prs in "${_ps[@]}"; do
if pidof "${_prs}" >/dev/null; then
pkill "${_prs}"
fi
done
}
_redshift() {
. $_scripts/redshift.sh && notify-send -u low "󰴅" "Redshift active"
}
# ─< Relaunch waybar >────────────────────────────────────────────────────────────────────
pywall_waybar() {
notify-send -u low "Bar" "waybar is launching with wal.."
waybar --style $HOME/.config/waybar/pywal_style.css
}
_hyprpanel() {
notify-send -u low "Bar" "hyprpanel is loading.."
hyprpanel &
}
_waybar() {
if command_exists wal; then
pywall_waybar
else
notify-send -u normal "Bar" "waybar is loading.."
waybar --config $HOME/.config/waybar/ai_config.jsonc --style $HOME/.config/waybar/ai_style.css &
fi
}
# ─< Relaunch gBar >──────────────────────────────────────────────────────────────────────
_gBar() {
notify-send -u low "Bar" "gBar is loading.."
gBar bar 0 &
gBar bar 1 &
}
_bar() {
if command_exists hyprpanel; then
_hyprpanel
elif command_exists gBar; then
_gBar
elif command_exists waybar; then
_waybar
else
notify-send -u critical "ERROR" "No 'bar'-provider found! Install either hyprpanel, gBar or waybar!"
fi
}
# # for cava-pywal (note, need to manually restart cava once wallpaper changes)
# # ln -sf "$HOME/.cache/wal/cava-colors" "$HOME/.config/cava/config" || true
# if [ -d "$HOME/.cache/wal/" ]; then
# ln -sf "$HOME/.cache/wal/colors-rofi-dark.rasi" "$HOME/.config/rofi/pywal-color/pywal-theme.rasi" || true
# if [ -e "$HOME/.config/waybar/pywal.css" ]; then
# rm $HOME/.config/waybar/pywal.css
# command cat $HOME/.cache/wal/colors.css >$HOME/.config/waybar/pywal.css
# # pywall_waybar || _waybar
# _gBar
# else
# # _waybar
# _gBar
# fi
# else
# # _waybar
# _gBar
# notify-send -u critical "ERROR" "critical failure! wal is not present!!"
# fi
main() {
notify-send "low" "terminating main wm elements"
_kill_
# relaunch swaync
sleep 0.3
# swaync >/dev/null 2>&1 &
notify-send "low" "bar" "launching.."
_bar
notify-send "low" "wallpaper" "loading.."
_wallpaper
if command_exists redshift; then
notify-send "low" "redshift" "protecting your eyes from the blue light.."
_redshift
fi
exit 0
}
main

3
.scripts/screenshot Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/bash
grim -g "$(slurp)" -o $HOME/.config/screenshots/ - | wl-copy -t image/png
notify-send "Screenshot copied to clipboard"

3
.scripts/screenshot_area Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/bash
grimshot copy area || exit
notify-send "Screenshot copied to clipboard"

3
.scripts/screenshot_full Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/bash
grimshot copy output || exit
notify-send "Screenshot copied to clipboard"

4
.scripts/wlogout.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
grim /tmp/shot.png
magick /tmp/shot.png -blur 0x8 /tmp/shot_blurred.png
wlogout --css $HOME/.config/wlogout/style.css