move some scripts to .nix

This commit is contained in:
2026-02-25 09:28:40 +01:00
parent 09e31ebfd8
commit 141ebd6150
7 changed files with 39 additions and 154 deletions

View File

@@ -45,9 +45,7 @@
set -l rel_file (realpath --relative-to=$config_dir $file) set -l rel_file (realpath --relative-to=$config_dir $file)
if nh home switch $config_dir -c ${ if nh home switch $config_dir -c ${if isNixOS then "nixos" else "arch"}
if isNixOS then "nixos" else "arch"
}" -b backup
git add -A git add -A
set commit_msg "update: $rel_file" set commit_msg "update: $rel_file"
git commit -m "$commit_msg" git commit -m "$commit_msg"
@@ -61,6 +59,11 @@
''; '';
}; };
reload_dotfiles = {
body = # fish
"nh home switch ~/.config/home-manager -c ${if isNixOS then "nixos" else "arch"}";
};
ls = { ls = {
body = # fish body = # fish
"eza --long --icons --group-directories-first --git $argv"; "eza --long --icons --group-directories-first --git $argv";

View File

@@ -5,7 +5,21 @@
pkgs, pkgs,
... ...
}: }:
let
exe = pkg: bin: if isNixOS then "${pkg}/bin/${bin}" else "/usr/bin/${bin}";
jq = exe pkgs.jq "jq";
grim = exe pkgs.grim "grim";
satty = exe pkgs.satty "satty";
wl_copy = exe pkgs.wl-clipboard "wl-copy";
notify_send = exe pkgs.libnotify "notify-send";
xdg-desktop-portal-hyprland =
if isNixOS then
"${pkgs.xdg-desktop-portal-hyprland}/libexec/xdg-desktop-portal-hyprland"
else
"/usr/lib/xdg-desktop-portal-hyprland";
hyprlock = exe pkgs.hyprlock "hyprlock";
in
{ {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = true; enable = true;
@@ -102,14 +116,9 @@
}; };
permission = [ permission = [
"${if isNixOS then "^${pkgs.grim}/bin/grim$" else "^/usr/bin/grim$"}" "^${grim}$, screencopy, allow"
"^${if isNixOS then "${pkgs.hyprlock}/bin/hyprlock" else "/usr/bin/hyprlock"}$, screencopy, allow" "^${hyprlock}$, screencopy, allow"
"^${ "^${xdg-desktop-portal-hyprland}$, screencopy, allow"
if isNixOS then
"${pkgs.xdg-desktop-portal-hyprland}/libexec/xdg-desktop-portal-hyprland"
else
"/usr/lib/xdg-desktop-portal-hyprland"
}$, screencopy, allow"
]; ];
input = { input = {
@@ -293,65 +302,32 @@
", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle" ", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle"
]; ];
bindl = [
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_SINK@ toggle && ${pkgs.writeShellScript "check-muted" ''
MUTED=$(${
if isNixOS then "${pkgs.wireplumber}/bin/wpctl" else "/usr/bin/wpctl"
} get-volume @DEFAULT_AUDIO_SINK@ | ${pkgs.gnugrep}/bin/grep -iq muted; echo $?)
if [[ $MUTED -eq 0 ]]; then
${pkgs.libnotify}/bin/notify-send "Audio muted" -a 'wp-vol' -t 1000
else
${pkgs.libnotify}/bin/notify-send "Audio unmuted" -a 'wp-vol' -t 1000
fi
''}"
", XF86AudioNext, exec, playerctl next"
", Pause, exec, playerctl play-pause"
"$mainMod, Pause, exec, playerctl play-pause --player spotify"
", XF86AudioPlay, exec, playerctl play-pause"
", XF86AudioPrev, exec, playerctl previous"
];
bindt = [ bindt = [
", PRINT, exec, ${pkgs.writeShellScript "region" '' ", PRINT, exec, ${pkgs.writeShellScript "screenshot-region" ''
"$mainMod, PRINT, exec, ${pkgs.writeShellScript "screenshot-region" '' MONITOR=$(hyprctl monitors -j | ${jq} -r '.[] | select(.focused == true) | .name')
MONITOR=$(hyprctl monitors -j | ${ ${grim} -o "$MONITOR" - | ${satty} -f -
if isNixOS then "${pkgs.jq}/bin/jq" else "/usr/bin/jq"
} -r '.[] | select(.focused == true) | .name')
${if isNixOS then "${pkgs.grim}/bin/grim" else "/usr/bin/grim"} -o "$MONITOR" - | ${
if isNixOS then "${pkgs.satty}/bin/satty" else "/usr/bin/satty"
} -f -
''}"
''}" ''}"
"$mainMod, PRINT, exec, ${pkgs.writeShellScript "screenshot-fullscreen" '' "$mainMod, PRINT, exec, ${pkgs.writeShellScript "screenshot-fullscreen" ''
target_path=${userConfig.pathConfig.screenshot}/$(date +'%d-%m-%Y_%H:%M:%S') target_path="$HOME/${userConfig.pathConfig.screenshot}/$(date +'%d-%m-%Y_%H-%M-%S').png"
MONITOR=$(hyprctl monitors -j | ${ mkdir -p "$(dirname "$target_path")"
if isNixOS then "${pkgs.jq}/bin/jq" else "/usr/bin/jq"
} -r '.[] | select(.focused == true) | .name') ${ MONITOR=$(hyprctl monitors -j | ${jq} -r '.[] | select(.focused == true) | .name')
if isNixOS then "${pkgs.grim}/bin/grim" else "/usr/bin/grim"
} -o "$MONITOR" "$target_path" ${grim} -o "$MONITOR" "$target_path"
${if isNixOS then "${pkgs.wl-clipboard}/bin/wl-copy" else "/usr/bin/wl-copy"} < "$target_path" ${wl_copy} < "$target_path"
${ ${notify_send} -i "$target_path" -u low -a "Screenshot" "Screenshot fullscreen" "Saved and copied"
if isNixOS then "${pkgs.libnotify}/bin/notify-send" else "/usr/bin/notify-send"
} -i "$target_path" -u low -a "Screenshot" "Screenshot fullscreen" "Saved and copied"
''}" ''}"
"alt_l, PRINT, exec, ${pkgs.writeShellScript "screenshot-window" '' "alt_l, PRINT, exec, ${pkgs.writeShellScript "screenshot-window" ''
target_path="~/${userConfig.pathConfig.screenshot}/$(date +'%d-%m-%Y_%H-%M-%S').png" target_path="$HOME/${userConfig.pathConfig.screenshot}/$(date +'%d-%m-%Y_%H-%M-%S').png"
mkdir -p "$(dirname "$target_path")" mkdir -p "$(dirname "$target_path")"
GEOMETRY=$(hyprctl activewindow -j | ${ GEOMETRY=$(hyprctl activewindow -j | ${jq} -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
if isNixOS then "${pkgs.jq}/bin/jq" else "/usr/bin/jq"
} -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
${if isNixOS then "${pkgs.grim}/bin/grim" else "/usr/bin/grim"} -g "$GEOMETRY" "$target_path" ${grim} -g "$GEOMETRY" "$target_path"
${wl_copy} < "$target_path"
${if isNixOS then "${pkgs.wl-clipboard}/bin/wl-copy" else "/usr/bin/wl-copy"} < "$target_path" ${notify_send} -i "$target_path" -u low -a "Screenshot" "Screenshot window" "Saved and copied"
${
if isNixOS then "${pkgs.libnotify}/bin/notify-send" else "/usr/bin/notify-send"
} -i "$target_path" -u low -a "Screenshot" "Screenshot window" "Saved and copied"
''}" ''}"
]; ];

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env bash
disturbed=$(makoctl mode | grep -i do-not-disturb) > /dev/null
mute_icon=""
unmute_icon="🕭"
case $1 in
"show")
if [[ $disturbed == "" ]]; then
echo "$unmute_icon"
else
echo "$mute_icon"
fi
;;
"change")
if [[ $disturbed == "" ]]; then
makoctl mode -a do-not-disturb > /dev/null
echo "$unmute_icon"
else
makoctl mode -r do-not-disturb > /dev/null
echo "$mute_icon"
fi
pkill -SIGRTMIN+2 waybar
;;
*)
echo "Arguments are: show, change"
;;
esac

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
MUTED=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -iq muted; echo $?)
if [[ $MUTED -eq 0 ]]; then
notify-send "Audio muted" -a 'wp-vol' -t 1000
else
notify-send "Audio unmuted" -a 'wp-vol' -t 1000
fi

View File

@@ -1,7 +0,0 @@
#!/usr/bin/env bash
killall -q waybar
while pgrep -x waybar >/dev/null; do sleep 1; done
uwsm app waybar

View File

@@ -1,50 +0,0 @@
#!/usr/bin/env bash
# variables
## path vars
date="$(date +'%d-%m-%Y_%H:%M:%S')"
fname="$date.png"
target_path="$HOME/Obrazy/zrzuty/$fname"
## stdout
error_wrong_type="The first argument needs to be \"fullscreen\", \"window\" or \"region\". Exiting..."
notification_succes="$target_path saved and copied"
# validate input
case "$1" in
"fullscreen" | "window" | "region")
type=$1
;;
*)
echo "$error_wrong_type"
exit
;;
esac
notification() {
notify-send -i "$target_path" -u low -a "Screenshot" "Screenshot $type" "$notification_succes"
}
case $type in
"fullscreen")
grim -o $(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name') "$target_path"
wl-copy < "$target_path"
notification
;;
"window")
active_window_position="$(hyprctl clients -j | jq -r '.[] | select(.focusHistoryID == 0) | .at')"
active_window_size="$(hyprctl clients -j | jq -r '.[] | select(.focusHistoryID == 0) | .size')"
x=$(echo "$active_window_position" | jq '.[0]')
y=$(echo "$active_window_position" | jq '.[1]')
width=$(echo "$active_window_size" | jq '.[0]')
height=$(echo "$active_window_size" | jq '.[1]')
grim -g "${x},${y} ${width}x${height}" "$target_path"
wl-copy < "$target_path"
notification
;;
"region")
grim -o $(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name') - | satty -f -
;;
esac

Binary file not shown.