cleanup and fixes

- hypridle
- fastfetch
This commit is contained in:
shinya 2025-02-15 21:00:13 +01:00
parent 330bcee0b6
commit da01ac5190
5 changed files with 261 additions and 161 deletions

View File

@ -16,7 +16,7 @@
editor = "neovim"; # neovim, vscode editor = "neovim"; # neovim, vscode
# List all themes: $ nix build nixpkgs#base16-schemes && ls result/share/themes # List all themes: $ nix build nixpkgs#base16-schemes && ls result/share/themes
theme = "evangelion-blood"; # catppuccin-mocha, tokyo-night-dark, one-dark theme = "catppuccin-mocha"; # catppuccin-mocha, tokyo-night-dark, one-dark
background = background =
if userSettings.theme == "catppuccin-mocha" if userSettings.theme == "catppuccin-mocha"
then "aurora_borealis.png" then "aurora_borealis.png"

View File

@ -6,7 +6,42 @@
# Keyboard image for keyboard switch layout # Keyboard image for keyboard switch layout
home.file = { home.file = {
".local/share/icons/kogami/keyboard.svg".source = ../../../../config/icons/keyboard.svg; ".local/share/icons/kogami/keyboard.svg".source = ../../../../config/icons/keyboard.svg;
".config/hypr/hypridle.conf".source = ./hypridle.conf; };
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "hyprctl switchxkblayout at-translated-set-2-keyboard 0 ; pidof hyprlock || hyprlock"; # avoid starting multiple hyprlock instances.
before_sleep_cmd = "loginctl lock-session"; # lock before suspend.
after_sleep_cmd = "hyprctl dispatch dpms on"; # to avoid having to press a key twice to turn on the display.
};
listener = [
{
timeout = 90; # 1.5min.
on-timeout = "brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor.
on-resume = "brightnessctl -r"; # monitor backlight restore.
}
# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight.
{
timeout = 120; # 3min
on-timeout = "loginctl lock-session"; # lock screen when timeout has passed
}
{
timeout = 210; # 3.5min
on-timeout = "hyprctl dispatch dpms off"; # screen off when timeout has passed
on-resume = "hyprctl dispatch dpms on"; # screen on when activity is detected after timeout has fired.
}
{
timeout = 1800; # 30min
on-timeout = "systemctl suspend"; # suspend pc
}
];
};
}; };
home.packages = home.packages =
@ -88,131 +123,131 @@
'') '')
(writeShellScriptBin "battery-notify" '' (writeShellScriptBin "battery-notify" ''
# Configuration variables (with default values) # Configuration variables (with default values)
dock="''${BATTERY_NOTIFY_DOCK:-true}" dock="''${BATTERY_NOTIFY_DOCK:-true}"
batterynotify_conf="$HYDE_STATE_HOME/staterc" batterynotify_conf="$HYDE_STATE_HOME/staterc"
battery_full_threshold="''${BATTERY_NOTIFY_THRESHOLD_FULL:-100}" battery_critical_threshold="''${BATTERY_NOTIFY_THRESHOLD_CRITICAL:-5}"
battery_critical_threshold="''${BATTERY_NOTIFY_THRESHOLD_CRITICAL:-5}" battery_low_threshold="''${BATTERY_NOTIFY_THRESHOLD_LOW:-20}"
unplug_charger_threshold="''${BATTERY_NOTIFY_THRESHOLD_UNPLUG:-80}" timer="''${BATTERY_NOTIFY_TIMER:-120}"
battery_low_threshold="''${BATTERY_NOTIFY_THRESHOLD_LOW:-20}" interval="''${BATTERY_NOTIFY_INTERVAL:-5}"
timer="''${BATTERY_NOTIFY_TIMER:-120}" execute_critical="''${BATTERY_NOTIFY_EXECUTE_CRITICAL:-systemctl suspend}"
notify="''${BATTERY_NOTIFY_NOTIFY:-1140}" execute_low="''${BATTERY_NOTIFY_EXECUTE_LOW:-}"
interval="''${BATTERY_NOTIFY_INTERVAL:-5}" verbose=false
execute_critical="''${BATTERY_NOTIFY_EXECUTE_CRITICAL:-systemctl suspend}" state_file="/tmp/battery_notify_state"
execute_low="''${BATTERY_NOTIFY_EXECUTE_LOW:-}"
execute_unplug="''${BATTERY_NOTIFY_EXECUTE_UNPLUG:-}"
execute_charging="''${BATTERY_NOTIFY_EXECUTE_CHARGING:-}"
execute_discharging="''${BATTERY_NOTIFY_EXECUTE_DISCHARGING:-}"
verbose=false
# Display configuration info # Display configuration info
config_info() { config_info() {
cat <<EOF cat <<EOF
Modify $batterynotify_conf to set options. Modify $batterynotify_conf to set options.
STATUS THRESHOLD INTERVAL STATUS THRESHOLD
Full $battery_full_threshold $notify Minutes Critical $battery_critical_threshold then '$execute_critical'
Critical $battery_critical_threshold $timer Seconds then '$execute_critical' Low $battery_low_threshold then '$execute_low'
Low $battery_low_threshold $interval Percent then '$execute_low'
Unplug $unplug_charger_threshold $interval Percent then '$execute_unplug'
Charging: $execute_charging Notifications at: 80%, 90%, 100% (charging only).
Discharging: $execute_discharging EOF
EOF }
}
# Check if system is a laptop # Check if system is a laptop
is_laptop() { is_laptop() {
if ! grep -q "Battery" /sys/class/power_supply/BAT*/type 2>/dev/null; then if ! grep -q "Battery" /sys/class/power_supply/BAT*/type 2>/dev/null; then
echo "No battery detected. Exiting." echo "No battery detected. Exiting."
exit 0 exit 0
fi fi
} }
# Display verbose information # Display verbose information
fn_verbose() { fn_verbose() {
if $verbose; then if $verbose; then
echo "=============================================" echo "============================================="
echo "Battery Status: $battery_status" echo "Battery Status: $battery_status"
echo "Battery Percentage: $battery_percentage" echo "Battery Percentage: $battery_percentage"
echo "=============================================" echo "============================================="
fi fi
} }
# Handle battery notifications # Handle battery notifications
notify_user() { notify_user() {
local urgency=$1 local urgency=$1
local title=$2 local title=$2
local message=$3 local message=$3
notify-send -a "HyDE Power" -t 5000 -u "$urgency" "$title" "$message" notify-send -a "HyDE Power" -t 5000 -u "$urgency" "$title" "$message"
} }
# Get battery status and percentage # Get battery status and percentage
get_battery_info() { get_battery_info() {
local total_percentage=0 battery_count=0 local total_percentage=0 battery_count=0
for battery in /sys/class/power_supply/BAT*; do for battery in /sys/class/power_supply/BAT*; do
battery_status=$(<"$battery/status") battery_status=$(<"$battery/status")
battery_percentage=$(<"$battery/capacity") battery_percentage=$(<"$battery/capacity")
total_percentage=$((total_percentage + battery_percentage)) total_percentage=$((total_percentage + battery_percentage))
battery_count=$((battery_count + 1)) battery_count=$((battery_count + 1))
done done
battery_percentage=$((total_percentage / battery_count)) battery_percentage=$((total_percentage / battery_count))
} }
# Check battery thresholds # Manage notifications for charging thresholds
check_thresholds() { manage_charging_notifications() {
if [[ "$battery_percentage" -ge "$unplug_charger_threshold" && "$battery_status" != "Discharging" ]]; then local thresholds=(80 90 100)
notify_user "NORMAL" "Battery Charged" "Battery is at $battery_percentage%. You can unplug the charger!" for threshold in "''${thresholds[@]}"; do
elif [[ "$battery_percentage" -le "$battery_critical_threshold" ]]; then if [[ "$battery_percentage" -ge "$threshold" && "$battery_status" == "Charging" ]]; then
notify_user "CRITICAL" "Battery Critically Low" "$battery_percentage% remaining. Executing critical action." if ! grep -q "$threshold" "$state_file" 2>/dev/null; then
$execute_critical notify_user "NORMAL" "Battery Charging" "Battery has reached $threshold%. Consider unplugging the charger."
elif [[ "$battery_percentage" -le "$battery_low_threshold" && "$battery_status" == "Discharging" ]]; then echo "$threshold" >> "$state_file"
notify_user "NORMAL" "Battery Low" "$battery_percentage% remaining. Connect the charger." fi
$execute_low fi
fi done
} }
# Monitor battery status changes # Reset state when discharging
monitor_battery() { reset_state_if_discharging() {
while :; do if [[ "$battery_status" == "Discharging" ]]; then
get_battery_info > "$state_file"
check_thresholds fi
sleep $interval }
done
}
# Main function # Monitor battery status changes
main() { monitor_battery() {
is_laptop while :; do
config_info get_battery_info
if $verbose; then reset_state_if_discharging
echo "Verbose Mode is ON." manage_charging_notifications
fi sleep $interval
monitor_battery done
} }
# Parse script arguments # Main function
case "$1" in main() {
-i|--info) is_laptop
config_info config_info
exit 0 if $verbose; then
;; echo "Verbose Mode is ON."
-v|--verbose) fi
verbose=true monitor_battery
;; }
-h|--help|*)
cat <<HELP
Usage: $0 [options]
[-i|--info] Display configuration information # Parse script arguments
[-v|--verbose] Enable verbose mode case "$1" in
[-h|--help] Show this help message -i|--info)
HELP config_info
exit 0 exit 0
;; ;;
esac -v|--verbose)
verbose=true
;;
-h|--help|*)
cat <<HELP
Usage: $0 [options]
main [-i|--info] Display configuration information
[-v|--verbose] Enable verbose mode
[-h|--help] Show this help message
HELP
exit 0
;;
esac
main
'') '')
#(writeShellScriptBin "windowpin") #(writeShellScriptBin "windowpin")

View File

@ -1,28 +0,0 @@
general {
lock_cmd = hyprctl switchxkblayout at-translated-set-2-keyboard 0 ; pidof hyprlock || hyprlock # avoid starting multiple hyprlock instances.
before_sleep_cmd = loginctl lock-session # lock before suspend.
after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
}
listener {
timeout = 90 # 1.5min.
on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor.
on-resume = brightnessctl -r # monitor backlight restore.
}
# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight.
listener {
timeout = 120 # 3min
on-timeout = loginctl lock-session # lock screen when timeout has passed
}
listener {
timeout = 210 # 3.5min
on-timeout = hyprctl dispatch dpms off # screen off when timeout has passed
on-resume = hyprctl dispatch dpms on # screen on when activity is detected after timeout has fired.
}
listener {
timeout = 1800 # 30min
on-timeout = systemctl suspend # suspend pc
}

View File

@ -20,27 +20,119 @@
"source" = "/home/shinya/.config/fastfetch/logo.png"; "source" = "/home/shinya/.config/fastfetch/logo.png";
"width" = 34; "width" = 34;
"height" = 18; "height" = 18;
"padding" = {
"top" = 1;
};
}; };
"modules" = [ "modules" = [
"break" "break"
"title" {
"separator" "type" = "title";
"os" "format" = "{#1} EVA 02 - {#}{user-name-colored}";
"host" }
"kernel" {
"uptime" "type" = "custom";
"packages" "format" = "{#1} {#}System Information";
"shell" }
"de" {
"wm" "type" = "os";
"icons" "key" = "{#separator} {#keys}󰍹 OS";
"font" }
"cursor" {
"terminalfont" "type" = "kernel";
"cpu" "key" = "{#separator} {#keys}󰒋 Kernel";
"gpu" }
"disk" {
"break" "type" = "uptime";
"key" = "{#separator} {#keys}󰅐 Uptime";
}
{
"type" = "packages";
"key" = "{#separator} {#keys}󰏖 Packages";
"format" = "{all}";
}
{
"type" = "custom";
"format" = "{#1}";
}
{
"type" = "custom";
"format" = "{#1} {#}Desktop Environment";
}
{
"type" = "de";
"key" = "{#separator} {#keys}󰧨 DE";
}
{
"type" = "wm";
"key" = "{#separator} {#keys}󱂬 WM";
}
{
"type" = "wmtheme";
"key" = "{#separator} {#keys}󰉼 Theme";
}
{
"type" = "display";
"key" = "{#separator} {#keys}󰹑 Resolution";
}
{
"type" = "shell";
"key" = "{#separator} {#keys}󰞷 Shell";
}
{
"type" = "terminalfont";
"key" = "{#separator} {#keys}󰛖 Font";
}
{
"type" = "custom";
"format" = "{#1}";
}
{
"type" = "custom";
"format" = "{#1} {#}Hardware Information";
}
{
"type" = "cpu";
"key" = "{#separator} {#keys}󰻠 CPU";
}
{
"type" = "gpu";
"key" = "{#separator} {#keys}󰢮 GPU";
}
{
"type" = "memory";
"key" = "{#separator} {#keys}󰍛 Memory";
}
{
"type" = "disk";
"key" = "{#separator} {#keys}󰋊 Disk (/)";
"folders" = "/";
}
{
"type" = "custom";
"format" = "{#1}";
}
{
"type" = "custom";
"format" = "{#1}";
}
#"separator"
#"os"
#"host"
#"kernel"
#"uptime"
#"packages"
#"shell"
#"de"
#"wm"
#"icons"
#"font"
#"cursor"
#"terminalfont"
#"cpu"
#"gpu"
#"disk"
#"break"
]; ];
}; };
}; };

View File

@ -58,7 +58,8 @@ in {
initExtra = '' initExtra = ''
${pkgs.pfetch}/bin/pfetch ${pkgs.pfetch}/bin/pfetch
set -o emacs''; set -o emacs
bindkey "^[[3~" delete-char'';
}; };
}) })
]; ];