wip!: init home-manager configs

This commit is contained in:
Zhongheng Liu 2026-01-06 20:27:52 +01:00
commit 43f1ce3c05
Signed by untrusted user who does not match committer: steven
GPG key ID: 805A28B071DAD84B
10 changed files with 87 additions and 19 deletions

77
home/home.nix Normal file
View file

@ -0,0 +1,77 @@
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "steven";
home.homeDirectory = "/home/steven";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "25.11"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = [
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
# # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
import ./scripts
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. These will be explicitly sourced when using a
# shell provided by Home Manager. If you don't want to manage your shell
# through Home Manager then you have to manually source 'hm-session-vars.sh'
# located at either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/steven/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
# EDITOR = "emacs";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

1
home/scripts/batman.sh Executable file
View file

@ -0,0 +1 @@
echo "$(calc -p round\($(cat /sys/class/power_supply/BAT1/charge_now)/$(cat /sys/class/power_supply/BAT1/charge_full)\*100, 1\))%"

7
home/scripts/default.nix Normal file
View file

@ -0,0 +1,7 @@
{
pkgs,
}: [
(pkgs.writeShellApplication {
name = "vol.sh";
}
]

View file

@ -0,0 +1,5 @@
#!/usr/bin/sh
IFS=""
file="$HOME/Screenshots/$(date '+%Y-%m-%d-%H-%M-%S.png')"
echo $file
slurp | grim -g - $file

1
home/scripts/screenshot.sh Executable file
View file

@ -0,0 +1 @@
slurp | grim -g - - | wl-copy

4
home/scripts/setup.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/bash
systemctl --user import-environment WAYLAND_DISPLAY
. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
swaybg -i $HOME/wallpaper.jpg

2
home/scripts/startup.sh Executable file
View file

@ -0,0 +1,2 @@
dwlb -ipc -font "BlexMono Nerd Font:size=16" &
someblocks -p | dwlb -status-stdin all

115
home/scripts/vol.sh Executable file
View file

@ -0,0 +1,115 @@
#!/usr/bin/env bash
#
# volume-notify.sh — adjust volume via wpctl + show notification via dunstify
#
# Usage:
# volume-notify.sh up → raise volume
# volume-notify.sh down → lower volume
# volume-notify.sh mute → toggle mute
#
# Adjust the step size and icons as desired.
# Which sink to use — default audio sink
SINK="@DEFAULT_SINK@"
# Step percent (use percentage step)
STEP="5%"
# Notification stack tag (so dunst replaces same notification)
STACK_TAG="volume-notify"
# Icons (set your paths or icon names)
ICON_HIGH="audio-volume-high"
ICON_MED="audio-volume-medium"
ICON_LOW="audio-volume-low"
ICON_MUTED="audio-volume-muted"
# Increase volume
vol_up() {
wpctl set-volume $SINK $STEP+ -l 1
}
# Decrease volume
vol_down() {
wpctl set-volume $SINK $STEP- -l 1
}
# Toggle mute
vol_mute() {
wpctl set-mute $SINK toggle
}
# Get current volume (floating between 0.0-∞, where 1.0 = 100%) and compute percent
get_volume_percent() {
# Example output: “Volume: 0.50” or “Volume: 0.50 [50%]”
local raw
raw=$(wpctl get-volume $SINK 2>/dev/null | awk '/Volume:/ {print $2}')
# convert to percent
# float *100
local pct
pct=$(awk "BEGIN { printf \"%d\", ($raw * 100) }")
echo "$pct"
}
# Get mute state (yes/no)
get_mute_state() {
local m
m=$(wpctl get-volume $SINK 2>/dev/null | awk '/Mute:/ {print $2}')
echo "$m"
}
# Send the notification
send_notification() {
local pct mute icon bar
pct=$(get_volume_percent)
mute=$(get_mute_state)
if [[ "$mute" == "yes" ]]; then
icon="$ICON_MUTED"
# we can treat volume as 0
pct=0
else
# pick icon based on level
if (( pct >= 66 )); then
icon="$ICON_HIGH"
elif (( pct >= 33 )); then
icon="$ICON_MED"
else
icon="$ICON_LOW"
fi
fi
# Optional: build a simple textual bar (e.g., █ or ░)
# e.g., length 20, filled proportionally
local barlen=20
local filled=$(( (pct * barlen) / 100 ))
bar=$(printf '%*s' "$filled" '' | tr ' ' '█')
bar+=$(printf '%*s' "$((barlen - filled))" '' | tr ' ' '░')
# Send notification: use value hint for progress bar
dunstify -i "$icon" \
-u normal \
-h string:x-dunst-stack-tag:$STACK_TAG \
-h int:value:$pct "Volume: ${pct}%"
}
# Main logic
case "$1" in
up)
vol_up
send_notification
;;
down)
vol_down
send_notification
;;
mute)
vol_mute
send_notification
;;
*)
echo "Usage: $0 {up|down|mute}"
exit 1
;;
esac