stow
This commit is contained in:
46
config/scripts/.local/snippets/apply-color-helper
Normal file
46
config/scripts/.local/snippets/apply-color-helper
Normal file
@@ -0,0 +1,46 @@
|
||||
[ "$(basename "$0")" = "apply-color-helper" ] && {
|
||||
echo "This script is meant to be sourced, not executed directly."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -z "$1" ] && exit 1
|
||||
palette="$1"
|
||||
[ -z "$2" ] && exit 1
|
||||
colorName="$2"
|
||||
[ -z "$3" ] && exit 1
|
||||
colorHex="$3"
|
||||
|
||||
function log_error {
|
||||
printf "\033[0;31mError:\033[0m $1\n" >&2
|
||||
}
|
||||
|
||||
function log_info {
|
||||
printf "\033[0;32mInfo:\033[0m $1\n" >&2
|
||||
}
|
||||
|
||||
function color_ansi {
|
||||
colorHex="$1"
|
||||
|
||||
local r=$((16#${colorHex:0:2}))
|
||||
local g=$((16#${colorHex:2:2}))
|
||||
local b=$((16#${colorHex:4:2}))
|
||||
|
||||
# 24-bit true color ANSI escape code
|
||||
printf "\033[38;2;%d;%d;%dm" $r $g $b
|
||||
}
|
||||
|
||||
|
||||
# remove leading '#' if present
|
||||
if [[ $colorHex == \#* ]]; then
|
||||
colorHex="${colorHex#\#}"
|
||||
fi
|
||||
|
||||
# check if hex
|
||||
if ! [[ $colorHex =~ ^[0-9A-Fa-f]{6}$ ]]; then
|
||||
log_error "Invalid color hex: $colorHex"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function log_success {
|
||||
log_info "Applied palette \033[1;34m${palette}\033[0m with primary color $(color_ansi $colorHex)${colorName} (#${colorHex})\033[0m to \033[1;34m$1\033[0m"
|
||||
}
|
||||
11
config/scripts/.local/snippets/fetch-weather.service
Normal file
11
config/scripts/.local/snippets/fetch-weather.service
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Fetch Weather
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/home/Username_PLACEHOLDER/.config/eww/Main/scripts/weather --getdata
|
||||
WorkingDirectory=/home/Username_PLACEHOLDER/.config/eww/Main/scripts
|
||||
Environment=OPENWEATHER_API_KEY="Onecall_3.0_APIKey_PLACEHOLDER"
|
||||
Environment=OPENWEATHER_LAT="Latitude_PLACEHOLDER"
|
||||
Environment=OPENWEATHER_LON="Longitude_PLACEHOLDER"
|
||||
10
config/scripts/.local/snippets/fetch-weather.timer
Normal file
10
config/scripts/.local/snippets/fetch-weather.timer
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Fetch weather information every hour
|
||||
Requires=fetch-weather.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar=hourly
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
69
config/scripts/.local/snippets/set_display
Normal file
69
config/scripts/.local/snippets/set_display
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# AMD -> Nvidia -> Intel
|
||||
prefer_order=(amd nvidia intel)
|
||||
|
||||
# Get vendor and path of each GPU
|
||||
default_dri_path="$(find /dev/dri/card* 2>/dev/null | head -n 1)"
|
||||
[[ -z "$default_dri_path" ]] && default_dri_path="/dev/dri/card0"
|
||||
intel_path=""
|
||||
nvidia_path=""
|
||||
amd_path=""
|
||||
|
||||
for link in /dev/dri/by-path/*-card; do
|
||||
[[ -e "$link" ]] || continue
|
||||
card="$(readlink -f "$link")"
|
||||
vfile="/sys/class/drm/$(basename "$card")/device/vendor"
|
||||
[[ -r "$vfile" ]] || continue
|
||||
vendor="$(cat "$vfile")"
|
||||
case "$vendor" in
|
||||
0x10de) nvidia_path="$card" ;;
|
||||
0x8086) intel_path="$card" ;;
|
||||
0x1002) amd_path="$card" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Specify device for brightnessctl
|
||||
# Only tested on my laptop with Intel iGPU & Nvidia dGPU
|
||||
BRIGHTNESSCTL_DEVICE="auto"
|
||||
if [[ -n "$intel_path" ]]; then
|
||||
BRIGHTNESSCTL_DEVICE="intel_backlight"
|
||||
elif [[ -n "$nvidia_path" ]]; then
|
||||
BRIGHTNESSCTL_DEVICE="nvidia_0"
|
||||
fi
|
||||
export BRIGHTNESSCTL_DEVICE
|
||||
|
||||
# AQ_DRM_DEVICES allows multiple entries separated by colon
|
||||
devices=""
|
||||
for who in "${prefer_order[@]}"; do
|
||||
case "$who" in
|
||||
nvidia) [[ -n "$nvidia_path" ]] && devices="${devices:+$devices:}$nvidia_path" ;;
|
||||
intel) [[ -n "$intel_path" ]] && devices="${devices:+$devices:}$intel_path" ;;
|
||||
amd) [[ -n "$amd_path" ]] && devices="${devices:+$devices:}$amd_path" ;;
|
||||
esac
|
||||
done
|
||||
HYPR_AQ_DRM_DEVICES="${devices:-$default_dri_path}"
|
||||
export HYPR_AQ_DRM_DEVICES
|
||||
|
||||
# But niri only supports choosing one preferred render device
|
||||
primary_device="$default_dri_path"
|
||||
for who in "${prefer_order[@]}"; do
|
||||
case "$who" in
|
||||
nvidia) [[ -n "$nvidia_path" ]] && { primary_device="$nvidia_path"; break; } ;;
|
||||
intel) [[ -n "$intel_path" ]] && { primary_device="$intel_path"; break; } ;;
|
||||
amd) [[ -n "$amd_path" ]] && { primary_device="$amd_path"; break; } ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Update niri config
|
||||
for file in "$HOME/.config/niri/config.kdl" "$HOME/.config/niri/config.kdl.template"; do
|
||||
[[ -f "$file" ]] || continue
|
||||
|
||||
if grep -qE '^\s*render-drm-device\s+"[^"]+"' "$file"; then
|
||||
current="$(grep -E '^\s*render-drm-device\s+"[^"]+"' "$file" | sed -E 's/^\s*render-drm-device\s+"([^"]+)".*/\1/')"
|
||||
[[ "$current" == "$primary_device" ]] && continue
|
||||
sed -i -E "s|^(\s*render-drm-device\s+)\"[^\"]+\"|\1\"$primary_device\"|" "$file"
|
||||
else
|
||||
printf '\ndebug {\nrender-drm-device "%s"\n}\n' "$primary_device" >> "$file"
|
||||
fi
|
||||
done
|
||||
3
config/scripts/.local/snippets/set_nv_env
Normal file
3
config/scripts/.local/snippets/set_nv_env
Normal file
@@ -0,0 +1,3 @@
|
||||
export __NV_PRIME_RENDER_OFFLOAD=1
|
||||
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||
export __VK_LAYER_NV_optimus=NVIDIA_only
|
||||
4
config/scripts/.local/snippets/unset_nv_env
Normal file
4
config/scripts/.local/snippets/unset_nv_env
Normal file
@@ -0,0 +1,4 @@
|
||||
# __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only
|
||||
unset __NV_PRIME_RENDER_OFFLOAD
|
||||
unset __GLX_VENDOR_LIBRARY_NAME
|
||||
unset __VK_LAYER_NV_optimus
|
||||
Reference in New Issue
Block a user