mirror of
https://github.com/szymon-jozef/amazing-dotfiles.git
synced 2026-09-07 12:10:45 +02:00
move some scripts to .nix
This commit is contained in:
@@ -45,9 +45,7 @@
|
||||
|
||||
set -l rel_file (realpath --relative-to=$config_dir $file)
|
||||
|
||||
if nh home switch $config_dir -c ${
|
||||
if isNixOS then "nixos" else "arch"
|
||||
}" -b backup
|
||||
if nh home switch $config_dir -c ${if isNixOS then "nixos" else "arch"}
|
||||
git add -A
|
||||
set commit_msg "update: $rel_file"
|
||||
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 = {
|
||||
body = # fish
|
||||
"eza --long --icons --group-directories-first --git $argv";
|
||||
|
||||
@@ -5,7 +5,21 @@
|
||||
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 = {
|
||||
enable = true;
|
||||
@@ -102,14 +116,9 @@
|
||||
};
|
||||
|
||||
permission = [
|
||||
"${if isNixOS then "^${pkgs.grim}/bin/grim$" else "^/usr/bin/grim$"}"
|
||||
"^${if isNixOS then "${pkgs.hyprlock}/bin/hyprlock" else "/usr/bin/hyprlock"}$, screencopy, allow"
|
||||
"^${
|
||||
if isNixOS then
|
||||
"${pkgs.xdg-desktop-portal-hyprland}/libexec/xdg-desktop-portal-hyprland"
|
||||
else
|
||||
"/usr/lib/xdg-desktop-portal-hyprland"
|
||||
}$, screencopy, allow"
|
||||
"^${grim}$, screencopy, allow"
|
||||
"^${hyprlock}$, screencopy, allow"
|
||||
"^${xdg-desktop-portal-hyprland}$, screencopy, allow"
|
||||
];
|
||||
|
||||
input = {
|
||||
@@ -293,65 +302,32 @@
|
||||
", 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 = [
|
||||
", PRINT, exec, ${pkgs.writeShellScript "region" ''
|
||||
"$mainMod, PRINT, exec, ${pkgs.writeShellScript "screenshot-region" ''
|
||||
MONITOR=$(hyprctl monitors -j | ${
|
||||
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 -
|
||||
''}"
|
||||
", PRINT, exec, ${pkgs.writeShellScript "screenshot-region" ''
|
||||
MONITOR=$(hyprctl monitors -j | ${jq} -r '.[] | select(.focused == true) | .name')
|
||||
${grim} -o "$MONITOR" - | ${satty} -f -
|
||||
''}"
|
||||
|
||||
"$mainMod, PRINT, exec, ${pkgs.writeShellScript "screenshot-fullscreen" ''
|
||||
target_path=${userConfig.pathConfig.screenshot}/$(date +'%d-%m-%Y_%H:%M:%S')
|
||||
MONITOR=$(hyprctl monitors -j | ${
|
||||
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" "$target_path"
|
||||
${if isNixOS then "${pkgs.wl-clipboard}/bin/wl-copy" else "/usr/bin/wl-copy"} < "$target_path"
|
||||
${
|
||||
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"
|
||||
target_path="$HOME/${userConfig.pathConfig.screenshot}/$(date +'%d-%m-%Y_%H-%M-%S').png"
|
||||
mkdir -p "$(dirname "$target_path")"
|
||||
|
||||
MONITOR=$(hyprctl monitors -j | ${jq} -r '.[] | select(.focused == true) | .name')
|
||||
|
||||
${grim} -o "$MONITOR" "$target_path"
|
||||
${wl_copy} < "$target_path"
|
||||
${notify_send} -i "$target_path" -u low -a "Screenshot" "Screenshot fullscreen" "Saved and copied"
|
||||
''}"
|
||||
|
||||
"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")"
|
||||
|
||||
GEOMETRY=$(hyprctl activewindow -j | ${
|
||||
if isNixOS then "${pkgs.jq}/bin/jq" else "/usr/bin/jq"
|
||||
} -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
||||
GEOMETRY=$(hyprctl activewindow -j | ${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"
|
||||
|
||||
${if isNixOS then "${pkgs.wl-clipboard}/bin/wl-copy" else "/usr/bin/wl-copy"} < "$target_path"
|
||||
|
||||
${
|
||||
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"
|
||||
${grim} -g "$GEOMETRY" "$target_path"
|
||||
${wl_copy} < "$target_path"
|
||||
${notify_send} -i "$target_path" -u low -a "Screenshot" "Screenshot window" "Saved and copied"
|
||||
''}"
|
||||
];
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
killall -q waybar
|
||||
|
||||
while pgrep -x waybar >/dev/null; do sleep 1; done
|
||||
|
||||
uwsm app waybar
|
||||
@@ -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.
Reference in New Issue
Block a user