removed mkbackup script, refactored all script files to use pkgs.writeShellApplication rather than pkgs.writeShellScriptBin
This commit is contained in:
@@ -1,6 +1,23 @@
|
|||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "icanhazip" ''
|
pkgs.writeShellApplication {
|
||||||
echo "Public IP: $(curl -s icanhazip.com -4)"
|
name = "icanhazip";
|
||||||
ip route | awk '/default/ {print "Default Gateway: " $3} /src/ {print "Local IP: " $9}' | head -n 2
|
runtimeInputs = with pkgs; [
|
||||||
''
|
iproute2
|
||||||
|
curl
|
||||||
|
gawk
|
||||||
|
coreutils
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Public IP: $(curl -s icanhazip.com -4)"
|
||||||
|
ip route | awk '/default/ {print "Default Gateway: " $3} /src/ {print "Local IP: " $9}' | head -n 2
|
||||||
|
else case $1 in
|
||||||
|
"-p" ) echo "Public IP: $(curl -s icanhazip.com -4)";;
|
||||||
|
"-d" ) ip route | awk '/default/ {print $3}';;
|
||||||
|
"-l" ) ip route | awk '/src/ {print $9}';;
|
||||||
|
* ) echo "Options: -p, -d or -l for public ip, default gateway, and local ip respectively"; echo "i.e. icanhazip -p"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
self,
|
pkgs
|
||||||
pkgs,
|
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "invoke" ''
|
pkgs.writeShellApplication {
|
||||||
cmd="$1"
|
name = "invoke";
|
||||||
shift
|
text = ''
|
||||||
nix run nixpkgs#"$cmd" -- "$@"
|
cmd="$1"
|
||||||
''
|
shift
|
||||||
|
nix run nixpkgs#"$cmd" -- "$@"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
{ pkgs }:
|
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "mkbackup" ''
|
|
||||||
if ! findmnt | grep share; then
|
|
||||||
echo "Mounting shared filesystem..."
|
|
||||||
if ! sshfs pagedmov@192.168.1.200:/home/pagedmov/share $HOME/share; then
|
|
||||||
echo "failed to mount shared storage to $HOME/share" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Done"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Copying files..."
|
|
||||||
if printf '%s\0' "$@" | xargs -0 -I {} cp {} -v "$HOME/share"; then
|
|
||||||
echo "Done"
|
|
||||||
else
|
|
||||||
echo "Failed to copy files to shared directory."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Moving files to backup folder on serverside..."
|
|
||||||
if ssh pagedmov@192.168.1.200 "IFS=' ' read -rA files <<< \"$@\"; for file in \''${files[@]}; do echo -n \"\$(whoami)@\$(hostname): \"; mv -v ~/share/\"\$file\" ~/backup; done"; then
|
|
||||||
echo "Backup completed."
|
|
||||||
umount $HOME/share
|
|
||||||
else
|
|
||||||
echo "Failed to move files on serverside. Unmounting shared filesystem."
|
|
||||||
umount $HOME/share
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
''
|
|
||||||
@@ -1,22 +1,29 @@
|
|||||||
{
|
{
|
||||||
self,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "runbg" ''
|
pkgs.writeShellApplication {
|
||||||
#!/usr/bin/env bash
|
name = "runbg";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
coreutils # Provides `basename`, `which`, etc.
|
||||||
|
bash # Provides the Bash shell
|
||||||
|
util-linux # Provides `tty`
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
[ $# -eq 0 ] && { # $# is number of args
|
[ $# -eq 0 ] && { # $# is number of args
|
||||||
echo "$(basename $0): missing command" >&2
|
echo "$(basename "$0"): missing command" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
prog="$(which "$1")" # see below
|
prog="$(which "$1")" # see below
|
||||||
[ -z "$prog" ] && {
|
[ -z "$prog" ] && {
|
||||||
echo "$(basename $0): unknown command: $1" >&2
|
echo "$(basename "$0"): unknown command: $1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
shift # remove $1, now $prog, from args
|
shift # remove $1, now $prog, from args
|
||||||
tty -s && exec </dev/null # if stdin is a terminal, redirect from null
|
tty -s && exec </dev/null # if stdin is a terminal, redirect from null
|
||||||
tty -s <&1 && exec >/dev/null # if stdout is a terminal, redirect to null
|
tty -s <&1 && exec >/dev/null # if stdout is a terminal, redirect to null
|
||||||
tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null)
|
tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null)
|
||||||
"$prog" "$@" & # $@ is all args
|
"$prog" "$@" & # $@ is all args
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
{
|
{
|
||||||
self,
|
pkgs
|
||||||
pkgs,
|
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "splash" ''
|
pkgs.writeShellApplication {
|
||||||
#!/bin/bash
|
name = "splash";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
echo "NixOS kernel ver. $(uname -a | awk '{print $3}') x86_64 GNU/Linux"
|
lolcat
|
||||||
date +"%A %B %-d %Y"
|
toilet
|
||||||
echo
|
coreutils
|
||||||
echo " NixOS" | toilet -f 3d | lolcat -S 25
|
];
|
||||||
echo
|
text = ''
|
||||||
''
|
echo "NixOS kernel ver. $(uname -a | awk '{print $3}') x86_64 GNU/Linux"
|
||||||
|
date +"%A %B %-d %Y"
|
||||||
|
echo
|
||||||
|
echo " NixOS" | toilet -f 3d | lolcat -S 25
|
||||||
|
echo
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,81 +1,95 @@
|
|||||||
{pkgs, ...}:
|
{pkgs}:
|
||||||
pkgs.writeShellScriptBin "toolbelt" ''
|
pkgs.writeShellApplication {
|
||||||
cliphistory() {
|
name = "toolbelt";
|
||||||
selection=$(cliphist list | fzf --preview="
|
runtimeInputs = with pkgs; [
|
||||||
index=\$(echo {} | awk '{print \$1}'); \
|
cliphist
|
||||||
mime=\$(cliphist decode \$index | file -i -); \
|
fzf
|
||||||
if echo \"\$mime\" | grep -q 'image'; then \
|
ripgrep
|
||||||
echo \$(cliphist list | rg \"^\$index\" | cut -d ' ' -f 2- | fmt -w 30); \
|
gawk
|
||||||
else \
|
wl-clipboard
|
||||||
cliphist decode \"\$index\" | fmt -w 30; \
|
hyprland
|
||||||
fi" --prompt="> " | awk '{print $1}')
|
alsa-utils
|
||||||
[ -z "$selection" ] && return 1
|
btop
|
||||||
cliphist decode "$selection" | wl-copy
|
coreutils
|
||||||
}
|
];
|
||||||
btop_cmd() {
|
text = ''
|
||||||
local hostname=$(cat /etc/hostname)
|
cliphistory() {
|
||||||
if [ "$hostname" = "oganesson" ]; then
|
selection=$(cliphist list | fzf --preview="
|
||||||
hyprctl dispatch resizeactive 20% 155% &&
|
index=\$(echo {} | awk '{print \$1}'); \
|
||||||
moveonscreen --center &&
|
mime=\$(cliphist decode \$index | file -i -); \
|
||||||
btop &&
|
if echo \"\$mime\" | grep -q 'image'; then \
|
||||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
echo \$(cliphist list | rg \"^\$index\" | cut -d ' ' -f 2- | fmt -w 30); \
|
||||||
moveonscreen
|
else \
|
||||||
else
|
cliphist decode \"\$index\" | fmt -w 30; \
|
||||||
hyprctl dispatch resizeactive exact 60% 68% &&
|
fi" --prompt="> " | awk '{print $1}')
|
||||||
moveonscreen --center &&
|
[ -z "$selection" ] && return 1
|
||||||
btop &&
|
cliphist decode "$selection" | wl-copy
|
||||||
hyprctl dispatch resizeactive exact 40% 25% &&
|
}
|
||||||
moveonscreen
|
btop_cmd() {
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
running=true
|
if [ "$(cat /etc/hostname)" = "oganesson" ]; then
|
||||||
|
hyprctl dispatch resizeactive 20% 155% &&
|
||||||
|
moveonscreen --center &&
|
||||||
|
btop &&
|
||||||
|
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||||
|
moveonscreen
|
||||||
|
else
|
||||||
|
hyprctl dispatch resizeactive exact 60% 68% &&
|
||||||
|
moveonscreen --center &&
|
||||||
|
btop &&
|
||||||
|
hyprctl dispatch resizeactive exact 40% 25% &&
|
||||||
|
moveonscreen
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
declare -A commands=(
|
running=true
|
||||||
["Change Wallpaper"]="moveonscreen --center && if chpaper; then running=false; else moveonscreen; fi"
|
|
||||||
["Change System Color Scheme"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && if chscheme; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
|
||||||
["Open System Monitor"]="btop_cmd"
|
|
||||||
["Open Volume Controls"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && alsamixer && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
|
||||||
["Open Keyring"]="hyprctl dispatch resizeactive -300 0 && moveonscreen && if keyring; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
|
||||||
["View Clipboard History"]="hyprctl dispatch resizeactive 45% 120% && moveonscreen --center && if cliphistory;then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
|
||||||
)
|
|
||||||
|
|
||||||
ordered_commands=(
|
declare -A commands=(
|
||||||
"Open Keyring"
|
["Change Wallpaper"]="moveonscreen --center && if chpaper; then running=false; else moveonscreen; fi"
|
||||||
"Open System Monitor"
|
["Change System Color Scheme"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && if chscheme; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||||
"Open Volume Controls"
|
["Open System Monitor"]="btop_cmd"
|
||||||
"Change Wallpaper"
|
["Open Volume Controls"]="hyprctl dispatch resizeactive 10% 80% && moveonscreen --center && alsamixer && hyprctl dispatch resizeactive exact 40% 25% && moveonscreen"
|
||||||
"Change System Color Scheme"
|
["Open Keyring"]="hyprctl dispatch resizeactive -300 0 && moveonscreen && if keyring; then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||||
"View Clipboard History"
|
["View Clipboard History"]="hyprctl dispatch resizeactive 45% 120% && moveonscreen --center && if cliphistory;then running=false; else hyprctl dispatch resizeactive exact 40% 25% && moveonscreen; fi"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Use fzf to select a command with preview
|
ordered_commands=(
|
||||||
while $running; do
|
"Open Keyring"
|
||||||
selected_command=$(printf "%s\n" "''${ordered_commands[@]}" | fzf --preview="
|
"Open System Monitor"
|
||||||
cleaned_key=\$(echo {} | tr -d \"'\"); \
|
"Open Volume Controls"
|
||||||
echo \"Cleaned key: \$cleaned_key\"; \
|
"Change Wallpaper"
|
||||||
declare -A descriptions=(
|
"Change System Color Scheme"
|
||||||
[\"Change Wallpaper\"]=\"Choose a wallpaper to switch to from the assets/wallpapers folder in the system flake directory. Requires rebuilding the system and restarting hyprpaper.\"
|
"View Clipboard History"
|
||||||
[\"Change System Color Scheme\"]=\"Changes the base16 color scheme used by stylix to color system applications.\"
|
)
|
||||||
[\"Open System Monitor\"]=\"Opens a btop window.\"
|
|
||||||
[\"Open Volume Controls\"]=\"Opens alsamixer.\"
|
# Use fzf to select a command with preview
|
||||||
[\"Open Keyring\"]=\"Opens a fuzzy finder with all of the paths held in ~/.password-store. Selecting one uses pass to copy that password to the clipboard. Password is cleared from clipboard after 45 seconds, and isn't saved to clipboard history.\"
|
while $running; do
|
||||||
[\"View Clipboard History\"]=\"Opens clipboard history. Selecting an item copies it to the clipboard.\"
|
selected_command=$(printf "%s\n" "''${ordered_commands[@]}" | fzf --preview="
|
||||||
); \
|
cleaned_key=\$(echo {} | tr -d \"'\"); \
|
||||||
if [[ -v descriptions[\$cleaned_key] ]]; then \
|
echo \"Cleaned key: \$cleaned_key\"; \
|
||||||
clear; \
|
declare -A descriptions=(
|
||||||
echo \''${descriptions[\$cleaned_key]} | fmt -w 28; \
|
[\"Change Wallpaper\"]=\"Choose a wallpaper to switch to from the assets/wallpapers folder in the system flake directory. Requires rebuilding the system and restarting hyprpaper.\"
|
||||||
else \
|
[\"Change System Color Scheme\"]=\"Changes the base16 color scheme used by stylix to color system applications.\"
|
||||||
clear; \
|
[\"Open System Monitor\"]=\"Opens a btop window.\"
|
||||||
echo \"No description available\"; \
|
[\"Open Volume Controls\"]=\"Opens alsamixer.\"
|
||||||
fi" --prompt="> ")
|
[\"Open Keyring\"]=\"Opens a fuzzy finder with all of the paths held in ~/.password-store. Selecting one uses pass to copy that password to the clipboard. Password is cleared from clipboard after 45 seconds, and isn't saved to clipboard history.\"
|
||||||
|
[\"View Clipboard History\"]=\"Opens clipboard history. Selecting an item copies it to the clipboard.\"
|
||||||
|
); \
|
||||||
|
if [[ -v descriptions[\$cleaned_key] ]]; then \
|
||||||
|
clear; \
|
||||||
|
echo \''${descriptions[\$cleaned_key]} | fmt -w 28; \
|
||||||
|
else \
|
||||||
|
clear; \
|
||||||
|
echo \"No description available\"; \
|
||||||
|
fi" --prompt="> ")
|
||||||
|
|
||||||
|
|
||||||
#Execute the selected command if selection is not empty
|
#Execute the selected command if selection is not empty
|
||||||
if [[ -n $selected_command ]]; then
|
if [[ -n $selected_command ]]; then
|
||||||
eval "''${commands[$selected_command]}"
|
eval "''${commands[$selected_command]}"
|
||||||
else
|
else
|
||||||
running=false
|
running=false
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,22 +1,31 @@
|
|||||||
{pkgs}:
|
{pkgs}:
|
||||||
pkgs.writeShellScriptBin "viconf" ''
|
pkgs.writeShellApplication {
|
||||||
#!/usr/bin/env bash
|
name = "viconf";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
coreutils
|
||||||
|
fd
|
||||||
|
ripgrep
|
||||||
|
fzf
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
[ ! $# -eq 1 ] && echo "Usage: viconf <*.nix>" && exit 1
|
[ ! $# -eq 1 ] && echo "Usage: viconf <*.nix>" && exit 1
|
||||||
|
|
||||||
results=$(find "$FLAKEPATH" -wholename "*$1*" -exec find {} \; | sort | uniq | rg '\.nix$')
|
results=$(find "$FLAKEPATH" -wholename "*$1*" -exec find {} \; | sort | uniq | rg '\.nix$')
|
||||||
numresults=$(echo "$results" | wc -l)
|
numresults=$(echo "$results" | wc -l)
|
||||||
|
|
||||||
[ "$numresults" -eq 0 ] && echo "$1 not found in \$FLAKEPATH" && exit 1
|
[ "$numresults" -eq 0 ] && echo "$1 not found in \$FLAKEPATH" && exit 1
|
||||||
|
|
||||||
if [ "$numresults" -gt 1 ]; then
|
if [ "$numresults" -gt 1 ]; then
|
||||||
# cut up the paths to give shorter path names to fuzzy finder
|
# cut up the paths to give shorter path names to fuzzy finder
|
||||||
results_prefix=$(echo "$results" | tail -n 1 | cut -d'/' -f-3)
|
results_prefix=$(echo "$results" | tail -n 1 | cut -d'/' -f-3)
|
||||||
results=$(echo "$results" | cut -d'/' -f4-)
|
results=$(echo "$results" | cut -d'/' -f4-)
|
||||||
results=$(echo "$results" | grep "$1")
|
results=$(echo "$results" | grep "$1")
|
||||||
|
|
||||||
echo "$results" | tr ' ' '\n' | fzf | xargs -I {} nvim "$results_prefix"/{}
|
echo "$results" | tr ' ' '\n' | fzf | xargs -I {} nvim "$results_prefix"/{}
|
||||||
else
|
else
|
||||||
nvim "$results"
|
nvim "$results"
|
||||||
fi
|
fi
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,16 +6,15 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
keyring = import ./wm-controls/keyring.nix { inherit self pkgs; };
|
keyring = import ./wm-controls/keyring.nix { inherit pkgs; };
|
||||||
invoke = import ./commands/invoke.nix { inherit self pkgs; };
|
invoke = import ./commands/invoke.nix { inherit pkgs; };
|
||||||
splash = import ./commands/splash.nix { inherit self pkgs; };
|
splash = import ./commands/splash.nix { inherit pkgs; };
|
||||||
runbg = import ./commands/runbg.nix { inherit self pkgs; };
|
runbg = import ./commands/runbg.nix { inherit pkgs; };
|
||||||
mkbackup = import ./commands/mkbackup.nix { inherit pkgs; };
|
|
||||||
icanhazip = import ./commands/icanhazip.nix { inherit pkgs; };
|
icanhazip = import ./commands/icanhazip.nix { inherit pkgs; };
|
||||||
garbage-collect = import ./nix/garbage-collect.nix { inherit self pkgs; };
|
garbage-collect = import ./nix/garbage-collect.nix { inherit pkgs; };
|
||||||
nsp = import ./nix/nsp.nix { inherit self pkgs; };
|
nsp = import ./nix/nsp.nix { inherit pkgs; };
|
||||||
scheck = import ./wm-controls/s_check.nix { inherit self pkgs; };
|
scheck = import ./wm-controls/s_check.nix { inherit pkgs; };
|
||||||
switchmon = import ./wm-controls/switchmon.nix { inherit self pkgs; };
|
switchmon = import ./wm-controls/switchmon.nix { inherit pkgs; };
|
||||||
rebuild = import ./nix/rebuild.nix { inherit host self pkgs; };
|
rebuild = import ./nix/rebuild.nix { inherit host self pkgs; };
|
||||||
moveonscreen = import ./wm-controls/moveonscreen.nix { inherit pkgs; };
|
moveonscreen = import ./wm-controls/moveonscreen.nix { inherit pkgs; };
|
||||||
toolbelt = import ./commands/toolbelt.nix { inherit pkgs; };
|
toolbelt = import ./commands/toolbelt.nix { inherit pkgs; };
|
||||||
@@ -44,8 +43,6 @@ in {
|
|||||||
lib.mkEnableOption "Enables all Nix shortcut scripts";
|
lib.mkEnableOption "Enables all Nix shortcut scripts";
|
||||||
|
|
||||||
# Individual options using scriptOverride or mkEnableOption directly
|
# Individual options using scriptOverride or mkEnableOption directly
|
||||||
movScripts.commandScripts.mkbackup.enable =
|
|
||||||
scriptOverride "Enables the mkbackup command" "commandScripts" "mkbackup";
|
|
||||||
movScripts.commandScripts.icanhazip.enable =
|
movScripts.commandScripts.icanhazip.enable =
|
||||||
scriptOverride "Enables the icanhazip command" "commandScripts" "icanhazip";
|
scriptOverride "Enables the icanhazip command" "commandScripts" "icanhazip";
|
||||||
movScripts.commandScripts.invoke.enable =
|
movScripts.commandScripts.invoke.enable =
|
||||||
@@ -86,7 +83,6 @@ in {
|
|||||||
config = lib.mkIf config.movScripts.enable {
|
config = lib.mkIf config.movScripts.enable {
|
||||||
home.packages = lib.optionals config.movScripts.commandScripts.invoke.enable [ invoke ]
|
home.packages = lib.optionals config.movScripts.commandScripts.invoke.enable [ invoke ]
|
||||||
++ lib.optionals config.movScripts.commandScripts.runbg.enable [ runbg ]
|
++ lib.optionals config.movScripts.commandScripts.runbg.enable [ runbg ]
|
||||||
++ lib.optionals config.movScripts.commandScripts.mkbackup.enable [ mkbackup ]
|
|
||||||
++ lib.optionals config.movScripts.commandScripts.icanhazip.enable [ icanhazip ]
|
++ lib.optionals config.movScripts.commandScripts.icanhazip.enable [ icanhazip ]
|
||||||
++ lib.optionals config.movScripts.commandScripts.splash.enable [ splash ]
|
++ lib.optionals config.movScripts.commandScripts.splash.enable [ splash ]
|
||||||
++ lib.optionals config.movScripts.commandScripts.toolbelt.enable [ toolbelt ]
|
++ lib.optionals config.movScripts.commandScripts.toolbelt.enable [ toolbelt ]
|
||||||
|
|||||||
@@ -1,41 +1,52 @@
|
|||||||
{
|
{
|
||||||
self,
|
pkgs
|
||||||
pkgs,
|
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "garbage-collect" ''
|
pkgs.writeShellApplication {
|
||||||
#!/run/current-system/sw/bin/bash
|
name = "garbage-collect";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
bash
|
||||||
|
coreutils
|
||||||
|
gnugrep
|
||||||
|
bc
|
||||||
|
alsa-utils
|
||||||
|
findutils
|
||||||
|
nix
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
echo "This will delete all unused paths in the nix store and delete any files in the gtrash folder."
|
echo "This will delete all unused paths in the nix store and delete any files in the gtrash folder."
|
||||||
echo -e "\033[1;4;38;2;243;139;168mThis process is irreversible.\033[0m Are you sure?"
|
echo -e "\033[1;4;38;2;243;139;168mThis process is irreversible.\033[0m Are you sure?"
|
||||||
select yn in "Yes" "No"; do
|
select yn in "Yes" "No"; do
|
||||||
case $yn in
|
case $yn in
|
||||||
Yes ) echo "Sweeping system..."; scheck && runbg aplay "$HOME/assets/sound/sys/collectgarbage.wav"; break;;
|
Yes ) echo "Sweeping system..."; scheck && runbg aplay "$HOME/assets/sound/sys/collectgarbage.wav"; break;;
|
||||||
No ) echo "Canceling garbage collection."; return;;
|
No ) echo "Canceling garbage collection."; return;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
output=$(nix-collect-garbage | tee /dev/tty)
|
output=$(nix-collect-garbage | tee /dev/tty)
|
||||||
nix_freed=$(echo "$output" | grep -oP '\d+(\.\d+)? MiB freed' | cut -d' ' -f1)
|
nix_freed=$(echo "$output" | grep -oP '\d+(\.\d+)? MiB freed' | cut -d' ' -f1)
|
||||||
|
|
||||||
# Get the size of the trash folder before deleting
|
# Get the size of the trash folder before deleting
|
||||||
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
|
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
|
||||||
rm_freed=$(du -sm ~/.local/share/Trash/files | awk '{print $1}')
|
rm_freed=$(du -sm ~/.local/share/Trash/files | awk '{print $1}')
|
||||||
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files/* # Verbose output
|
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files/* # Verbose output
|
||||||
mkdir -p ~/.local/share/Trash/files
|
mkdir -p ~/.local/share/Trash/files
|
||||||
else
|
else
|
||||||
rm_freed="0"
|
rm_freed="0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
total_freed=$(echo "$nix_freed + $rm_freed" | bc)
|
total_freed=$(echo "$nix_freed + $rm_freed" | bc)
|
||||||
|
|
||||||
units=("MB" "GB" "TB" "PB")
|
units=("MB" "GB" "TB" "PB")
|
||||||
divisions=0
|
divisions=0
|
||||||
while [ "$(echo "$total_freed >= 1024.0" | bc -l)" -eq 1 ]; do
|
while [ "$(echo "$total_freed >= 1024.0" | bc -l)" -eq 1 ]; do
|
||||||
total_freed=$(echo "scale=2; $total_freed / 1024" | bc -l)
|
total_freed=$(echo "scale=2; $total_freed / 1024" | bc -l)
|
||||||
divisions=$((divisions + 1))
|
divisions=$((divisions + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "System cleaning complete, freed \033[1;4;38;2;166;227;161m$total_freed ''${units[$divisions]}\033[0m in total"
|
echo -e "System cleaning complete, freed \033[1;4;38;2;166;227;161m$total_freed ''${units[$divisions]}\033[0m in total"
|
||||||
|
|
||||||
scheck && runbg aplay "$HOME/assets/sound/sys/rm.wav"
|
scheck && runbg aplay "$HOME/assets/sound/sys/rm.wav"
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
self,
|
pkgs
|
||||||
pkgs,
|
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "nsp" ''
|
pkgs.writeShellApplication {
|
||||||
#!/run/current-system/sw/bin/bash
|
name = "nsp";
|
||||||
|
text = ''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
nix-shell -p "$@" --run zsh
|
nix-shell -p "$@" --run zsh
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
self,
|
self,
|
||||||
pkgs,
|
pkgs,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "rebuild" ''
|
pkgs.writeShellApplication {
|
||||||
#!/run/current-system/sw/bin/bash
|
name = "rebuild";
|
||||||
|
text = ''
|
||||||
scheck && runbg aplay ${self}/assets/sound/nixswitch-start.wav
|
scheck && runbg aplay ${self}/assets/sound/nixswitch-start.wav
|
||||||
set -e
|
set -e
|
||||||
nh os switch -H ${host} $HOME/.sysflake
|
nh os switch -H ${host} "$HOME"/.sysflake
|
||||||
sudo nixos-rebuild switch --flake "$HOME/.sysflake#${host}"
|
if sudo nixos-rebuild switch --flake "$HOME/.sysflake#${host}"; then
|
||||||
if [ $? -eq 0 ]; then
|
scheck && runbg aplay ${self}/assets/sound/update.wav
|
||||||
scheck && runbg aplay ${self}/assets/sound/update.wav
|
else
|
||||||
else
|
scheck && runbg aplay ${self}/assets/sound/error.wav
|
||||||
scheck && runbg aplay ${self}/assets/sound/error.wav
|
fi
|
||||||
fi
|
'';
|
||||||
''
|
}
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
{pkgs}:
|
{pkgs}:
|
||||||
pkgs.writeShellScriptBin "chpaper" ''
|
pkgs.writeShellApplication {
|
||||||
paper="$\{self}/assets/wallpapers/$(find "$FLAKEPATH"/assets/wallpapers -exec basename {} \; | rg "\.\w+$" | fzf --preview "chafa -s 30x40 $FLAKEPATH/assets/wallpapers/{}")"
|
name = "chpaper";
|
||||||
[ "$paper" = "$\{self}/assets/wallpapers/" ] && echo "Cancelling wallpaper change" && exit 1
|
runtimeInputs = with pkgs; [
|
||||||
echo "$paper" | xargs -I {} sed -i '/wallpaper =/s|"[^"]*"|"{}"|' "$FLAKEPATH"/modules/sys/environment/stylix.nix
|
chafa
|
||||||
echo "Successfully changed wallpaper. Rebuild now?" && \
|
fzf
|
||||||
select choice in "Yes" "No"; do
|
ripgrep
|
||||||
case $choice in
|
findutils
|
||||||
"Yes")
|
coreutils
|
||||||
rebuild;systemctl --user restart hyprpaper;exit 0;;
|
];
|
||||||
"No")
|
text = ''
|
||||||
echo "Exiting...";exit 0;;
|
paper="$\{self}/assets/wallpapers/$(find "$FLAKEPATH"/assets/wallpapers -exec basename {} \; | rg "\.\w+$" | fzf --preview "chafa -s 30x40 $FLAKEPATH/assets/wallpapers/{}")"
|
||||||
esac
|
[ "$paper" = "$\{self}/assets/wallpapers/" ] && echo "Cancelling wallpaper change" && exit 1
|
||||||
done
|
echo "$paper" | xargs -I {} sed -i '/wallpaper =/s|"[^"]*"|"{}"|' "$FLAKEPATH"/modules/sys/environment/stylix.nix
|
||||||
''
|
echo "Successfully changed wallpaper. Rebuild now?" && \
|
||||||
|
select choice in "Yes" "No"; do
|
||||||
|
case $choice in
|
||||||
|
"Yes")
|
||||||
|
rebuild;systemctl --user restart hyprpaper;exit 0;;
|
||||||
|
"No")
|
||||||
|
echo "Exiting...";exit 0;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,40 +1,46 @@
|
|||||||
{pkgs}:
|
{ pkgs }:
|
||||||
pkgs.writeShellScriptBin "chscheme" ''
|
pkgs.writeShellApplication {
|
||||||
selected_scheme=$(/usr/bin/env ls "$(nix-build '<nixpkgs>' -A base16-schemes)"/share/themes | \
|
name = "chscheme";
|
||||||
sed 's/\.yaml//g' | \
|
runtimeInputs = with pkgs; [
|
||||||
fzf --preview 'cat $(nix-build "<nixpkgs>" -A base16-schemes)/share/themes/{}.yaml | \
|
fzf
|
||||||
while IFS=": " read -r key value; do \
|
coreutils
|
||||||
if [[ $key =~ base0[0-9A-F] ]]; then \
|
];
|
||||||
clean_value=$(echo $value | tr -d "\""); \
|
text = ''
|
||||||
r=$((16#''${clean_value:0:2})); \
|
selected_scheme=$(/usr/bin/env ls "$(nix-build '<nixpkgs>' -A base16-schemes)"/share/themes | \
|
||||||
g=$((16#''${clean_value:2:2})); \
|
sed 's/\.yaml//g' | \
|
||||||
b=$((16#''${clean_value:4:2})); \
|
fzf --preview "cat \"$(nix-build '<nixpkgs>' -A base16-schemes)/share/themes/{}.yaml\" | \
|
||||||
printf "\033[48;2;%d;%d;%dm %-20s %s \033[0m\n" $r $g $b $key $clean_value; \
|
while IFS=\": \" read -r key value; do \
|
||||||
fi; \
|
if [[ \$key =~ base0[0-9A-F] ]]; then \
|
||||||
done')
|
clean_value=\$(echo \"\$value\" | tr -d '\"'); \
|
||||||
|
r=\$((16#\''${clean_value:0:2})); \
|
||||||
|
g=\$((16#\''${clean_value:2:2})); \
|
||||||
|
b=\$((16#\''${clean_value:4:2})); \
|
||||||
|
printf \"\\033[48;2;%d;%d;%dm %-20s %s \\033[0m\\n\" \$r \$g \$b \$key \$clean_value; \
|
||||||
|
fi; \
|
||||||
|
done")
|
||||||
|
|
||||||
if [[ -z "$selected_scheme" ]]; then
|
if [[ -z "$selected_scheme" ]]; then
|
||||||
echo "Aborting color scheme change."
|
echo "Aborting color scheme change."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$selected_scheme" | xargs -I {} sed -i '/^[[:space:]]*scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/modules/sys/environment/stylix.nix
|
if ! echo "$selected_scheme" | xargs -I {} sed -i '/^[[:space:]]*scheme\s*=\s*"/s/"[^"]*"/"{}"/' "$FLAKEPATH"/modules/sys/environment/stylix.nix; then
|
||||||
if [ $? -ne 0 ]; then
|
echo "Failed to change color scheme."
|
||||||
echo "Failed to change color scheme."
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Successfully changed system color scheme. Rebuild now?"
|
echo "Successfully changed system color scheme. Rebuild now?"
|
||||||
select choice in "Yes" "No"; do
|
select choice in "Yes" "No"; do
|
||||||
case $choice in
|
case $choice in
|
||||||
"Yes")
|
"Yes")
|
||||||
rebuild
|
rebuild
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"No")
|
"No")
|
||||||
echo "Exiting..."
|
echo "Exiting..."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,35 +1,42 @@
|
|||||||
{
|
{
|
||||||
self,
|
pkgs
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "keyring" ''
|
pkgs.writeShellApplication {
|
||||||
#!/run/current-system/sw/bin/bash
|
name = "keyring";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
pass
|
||||||
|
findutils
|
||||||
|
ripgrep
|
||||||
|
fzf
|
||||||
|
wl-clipboard
|
||||||
|
coreutils
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
# prevent multiple instances, conditional check happens in the hyprland bind
|
# prevent multiple instances, conditional check happens in the hyprland bind
|
||||||
touch /tmp/keyringfile
|
touch /tmp/keyringfile
|
||||||
trap "[ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile" EXIT SIGHUP SIGINT
|
trap "[ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile" EXIT SIGHUP SIGINT
|
||||||
|
|
||||||
# get passwords from password store, remove .password store/ prefix and .gpg suffix, exlude .gpg-id file, open results in fzf
|
# get passwords from password store, remove .password store/ prefix and .gpg suffix, exlude .gpg-id file, open results in fzf
|
||||||
pass_string=$(find $HOME/.password-store -type f | sed 's|.*/.password-store/||; s|\.gpg$||' | sed 's|^\([^/]*\)|\x1b[32m\1\x1b[0m|' | rg -v "\.git|.gpg-id" | sort -r | fzf --border --border-label="$(whoami)'s keyring" --ansi --layout=reverse)
|
pass_string=$(find "$HOME"/.password-store -type f | sed 's|.*/.password-store/||; s|\.gpg$||' | sed 's|^\([^/]*\)|\x1b[32m\1\x1b[0m|' | rg -v "\.git|.gpg-id" | sort -r | fzf --border --border-label="$(whoami)'s keyring" --ansi --layout=reverse)
|
||||||
|
|
||||||
[ $? = 0 ] || { [ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile; exit 1; }
|
# prevents cliphist from writing passwords to the clipboard history
|
||||||
|
pkill -STOP wl-paste
|
||||||
|
|
||||||
# prevents cliphist from writing passwords to the clipboard history
|
# copy password
|
||||||
pkill -STOP wl-paste
|
pass -c "$pass_string" > /dev/null
|
||||||
|
echo "Password copied. Clearing clipboard in 10 seconds."
|
||||||
|
|
||||||
# copy password
|
# start a timer for 10 seconds, clear clipboard, resume cliphist tracking
|
||||||
pass -c "$pass_string" > /dev/null
|
nohup bash <<-EOF > /dev/null &
|
||||||
echo "Password copied. Clearing clipboard in 10 seconds."
|
sleep 10
|
||||||
|
wl-copy -c
|
||||||
|
pkill -CONT wl-paste
|
||||||
|
EOF
|
||||||
|
|
||||||
# start a timer for 10 seconds, clear clipboard, resume cliphist tracking
|
/run/current-system/sw/bin/rm /tmp/keyringfile
|
||||||
nohup bash <<-EOF > /dev/null &
|
sleep 0.5
|
||||||
sleep 10
|
exit 0
|
||||||
wl-copy -c
|
'';
|
||||||
pkill -CONT wl-paste
|
}
|
||||||
EOF
|
|
||||||
|
|
||||||
/run/current-system/sw/bin/rm /tmp/keyringfile
|
|
||||||
sleep 0.5
|
|
||||||
exit 0
|
|
||||||
''
|
|
||||||
|
|||||||
@@ -1,58 +1,70 @@
|
|||||||
{ pkgs }:
|
{ pkgs }:
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "mkscreenshots" ''
|
pkgs.writeShellApplication {
|
||||||
if [ -n "$(hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4")')" ]; then
|
name = "mkscreenshots";
|
||||||
echo "There are windows in workspace 4. This script uses workspace 4, so move those windows and run it again."
|
runtimeInputs = with pkgs; [
|
||||||
exit 1
|
jq
|
||||||
fi
|
|
||||||
|
|
||||||
prev_workspace=$(hyprctl activeworkspace -j | jq '.id')
|
|
||||||
|
|
||||||
hyprctl dispatch focusmonitor 0
|
|
||||||
|
|
||||||
screenshotfetch() {
|
|
||||||
neofetch
|
neofetch
|
||||||
|
kitty
|
||||||
|
coreutils
|
||||||
|
nemo
|
||||||
|
grimblast
|
||||||
|
git
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
if [ -n "$(hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4")')" ]; then
|
||||||
|
echo "There are windows in workspace 4. This script uses workspace 4, so move those windows and run it again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
kitty @ scroll-window 20-
|
prev_workspace=$(hyprctl activeworkspace -j | jq '.id')
|
||||||
|
|
||||||
exec sleep infinity
|
hyprctl dispatch focusmonitor 0
|
||||||
}
|
|
||||||
|
|
||||||
closewindows() {
|
screenshotfetch() {
|
||||||
hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4") | .address' | while read -r addr; do
|
neofetch
|
||||||
hyprctl dispatch closewindow address:"$addr"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
temp_script=$(mktemp)
|
kitty @ scroll-window 20-
|
||||||
screenshotfetch_var=$(declare -f screenshotfetch)
|
|
||||||
echo "$screenshotfetch_var" > "$temp_script"
|
|
||||||
echo "screenshotfetch" >> "$temp_script"
|
|
||||||
chmod +x "$temp_script"
|
|
||||||
|
|
||||||
hyprctl dispatch workspace 4
|
exec sleep infinity
|
||||||
hyprctl dispatch exec "[float;size 40% 25%;move 1% 66%] kitty bash -c '$temp_script'"
|
}
|
||||||
hyprctl dispatch exec "[float;size 40% 50%;move 57% 8%] nemo"
|
|
||||||
|
|
||||||
sleep 1
|
closewindows() {
|
||||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-neofetch.png
|
hyprctl clients -j | jq -r '.[] | select(.workspace.name == "4") | .address' | while read -r addr; do
|
||||||
|
hyprctl dispatch closewindow address:"$addr"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
closewindows
|
temp_script=$(mktemp)
|
||||||
|
screenshotfetch_var=$(declare -f screenshotfetch)
|
||||||
|
echo "$screenshotfetch_var" > "$temp_script"
|
||||||
|
echo "screenshotfetch" >> "$temp_script"
|
||||||
|
chmod +x "$temp_script"
|
||||||
|
|
||||||
hyprctl dispatch exec 'kitty nvim'
|
hyprctl dispatch workspace 4
|
||||||
hyprctl dispatch exec 'kitty yazi'
|
hyprctl dispatch exec "[float;size 40% 25%;move 1% 66%] kitty bash -c '$temp_script'"
|
||||||
hyprctl dispatch exec 'kitty'
|
hyprctl dispatch exec "[float;size 40% 50%;move 57% 8%] nemo"
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
grimblast save output "$FLAKEPATH"/assets/screens/desktop-busy.png
|
grimblast save output "$FLAKEPATH"/assets/screens/desktop-neofetch.png
|
||||||
|
|
||||||
(
|
closewindows
|
||||||
cd "$FLAKEPATH"
|
|
||||||
latest_hash=$(git rev-parse HEAD)
|
|
||||||
sed -i "s|\(https://github.com/pagedMov/nixos-config/commit/\)[a-f0-9]\{40\}|\1$latest_hash|" "$FLAKEPATH"/README.md
|
|
||||||
)
|
|
||||||
|
|
||||||
closewindows
|
hyprctl dispatch exec 'kitty nvim'
|
||||||
|
hyprctl dispatch exec 'kitty yazi'
|
||||||
|
hyprctl dispatch exec 'kitty'
|
||||||
|
|
||||||
hyprctl dispatch workspace "$prev_workspace"
|
sleep 1
|
||||||
''
|
grimblast save output "$FLAKEPATH"/assets/screens/desktop-busy.png
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "$FLAKEPATH"
|
||||||
|
latest_hash=$(git rev-parse HEAD)
|
||||||
|
sed -i "s|\(https://github.com/pagedMov/nixos-config/commit/\)[a-f0-9]\{40\}|\1$latest_hash|" "$FLAKEPATH"/README.md
|
||||||
|
)
|
||||||
|
|
||||||
|
closewindows
|
||||||
|
|
||||||
|
hyprctl dispatch workspace "$prev_workspace"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,76 +1,85 @@
|
|||||||
{pkgs}:
|
{pkgs}:
|
||||||
pkgs.writeShellScriptBin "moveonscreen" ''
|
pkgs.writeShellApplication {
|
||||||
center_window=false
|
name = "moveonscreen";
|
||||||
if [[ $1 == "--center" ]]; then
|
runtimeInputs = with pkgs; [
|
||||||
center_window=true
|
hyprland
|
||||||
fi
|
jq
|
||||||
|
coreutils
|
||||||
|
gawk
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
center_window=false
|
||||||
|
if [[ ! $# -eq 0 ]] && [[ $1 == "--center" ]]; then
|
||||||
|
center_window=true
|
||||||
|
fi
|
||||||
|
|
||||||
cursor_pos=$(hyprctl cursorpos | sed 's/,//')
|
cursor_pos=$(hyprctl cursorpos | sed 's/,//')
|
||||||
cursor_x=$(echo "$cursor_pos" | awk '{print $1}')
|
cursor_x=$(echo "$cursor_pos" | awk '{print $1}')
|
||||||
cursor_y=$(echo "$cursor_pos" | awk '{print $2}')
|
cursor_y=$(echo "$cursor_pos" | awk '{print $2}')
|
||||||
|
|
||||||
|
|
||||||
window_info=$(hyprctl activewindow -j)
|
window_info=$(hyprctl activewindow -j)
|
||||||
window_width=$(echo "$window_info" | jq ".size[0]")
|
window_width=$(echo "$window_info" | jq ".size[0]")
|
||||||
window_height=$(echo "$window_info" | jq ".size[1]")
|
window_height=$(echo "$window_info" | jq ".size[1]")
|
||||||
|
|
||||||
|
|
||||||
if [ "$center_window" = true ]; then
|
if [ "$center_window" = true ]; then
|
||||||
cursor_x=$((cursor_x - window_width / 2))
|
cursor_x=$((cursor_x - window_width / 2))
|
||||||
cursor_y=$((cursor_y - window_height / 2))
|
cursor_y=$((cursor_y - window_height / 2))
|
||||||
|
|
||||||
if (( cursor_x < 10 )); then
|
if (( cursor_x < 10 )); then
|
||||||
cursor_x=10
|
cursor_x=10
|
||||||
fi
|
fi
|
||||||
if (( cursor_y < 54 )); then
|
if (( cursor_y < 54 )); then
|
||||||
cursor_y=54
|
cursor_y=54
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
monitors=$(hyprctl monitors -j)
|
monitors=$(hyprctl monitors -j)
|
||||||
|
|
||||||
monitor_x_min=0
|
monitor_x_min=0
|
||||||
monitor_x_max=0
|
monitor_x_max=0
|
||||||
monitor_y_min=0
|
monitor_y_min=0
|
||||||
monitor_y_max=0
|
monitor_y_max=0
|
||||||
focused_monitor=-1
|
focused_monitor=-1
|
||||||
|
|
||||||
for ((i = 0; i < $(echo "$monitors" | jq 'length'); i++)); do
|
for ((i = 0; i < $(echo "$monitors" | jq 'length'); i++)); do
|
||||||
mon_x=$(echo "$monitors" | jq ".[$i].x")
|
mon_x=$(echo "$monitors" | jq ".[$i].x")
|
||||||
mon_y=$(echo "$monitors" | jq ".[$i].y")
|
mon_y=$(echo "$monitors" | jq ".[$i].y")
|
||||||
mon_width=$(echo "$monitors" | jq ".[$i].width")
|
mon_width=$(echo "$monitors" | jq ".[$i].width")
|
||||||
mon_height=$(echo "$monitors" | jq ".[$i].height")
|
mon_height=$(echo "$monitors" | jq ".[$i].height")
|
||||||
is_focused=$(echo "$monitors" | jq ".[$i].focused")
|
is_focused=$(echo "$monitors" | jq ".[$i].focused")
|
||||||
|
|
||||||
if [ "$is_focused" = true ]; then
|
if [ "$is_focused" = true ]; then
|
||||||
monitor_x_min=$((mon_x + 10))
|
monitor_x_min=$((mon_x + 10))
|
||||||
monitor_x_max=$((mon_x + mon_width - 10))
|
monitor_x_max=$((mon_x + mon_width - 10))
|
||||||
monitor_y_min=$((mon_y + 10))
|
monitor_y_min=$((mon_y + 10))
|
||||||
monitor_y_max=$((mon_y + mon_height - 10))
|
monitor_y_max=$((mon_y + mon_height - 10))
|
||||||
focused_monitor=$i
|
focused_monitor=$i
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$focused_monitor" -eq -1 ]; then
|
if [ "$focused_monitor" -eq -1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( cursor_x < monitor_x_min )); then
|
if (( cursor_x < monitor_x_min )); then
|
||||||
adjusted_x=$monitor_x_min
|
adjusted_x=$monitor_x_min
|
||||||
elif (( cursor_x + window_width > monitor_x_max )); then
|
elif (( cursor_x + window_width > monitor_x_max )); then
|
||||||
adjusted_x=$((monitor_x_max - window_width))
|
adjusted_x=$((monitor_x_max - window_width))
|
||||||
else
|
else
|
||||||
adjusted_x=$cursor_x
|
adjusted_x=$cursor_x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( cursor_y < monitor_y_min )); then
|
if (( cursor_y < monitor_y_min )); then
|
||||||
adjusted_y=$monitor_y_min
|
adjusted_y=$monitor_y_min
|
||||||
elif (( cursor_y + window_height > monitor_y_max )); then
|
elif (( cursor_y + window_height > monitor_y_max )); then
|
||||||
adjusted_y=$((monitor_y_max - window_height))
|
adjusted_y=$((monitor_y_max - window_height))
|
||||||
else
|
else
|
||||||
adjusted_y=$cursor_y
|
adjusted_y=$cursor_y
|
||||||
fi
|
fi
|
||||||
|
|
||||||
hyprctl dispatch moveactive exact "$adjusted_x $adjusted_y" > /dev/null 2>&1
|
hyprctl dispatch moveactive exact "$adjusted_x $adjusted_y" > /dev/null 2>&1
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
self,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "scheck" ''
|
pkgs.writeShellApplication {
|
||||||
#!/run/current-system/sw/bin/bash
|
name = "scheck";
|
||||||
|
text = ''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
|
||||||
[ "$SOUNDS_ENABLED" -eq 1 ]
|
[ "$SOUNDS_ENABLED" -eq 1 ]
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
self,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
}:
|
}:
|
||||||
pkgs.writeShellScriptBin "switchmon" ''
|
pkgs.writeShellApplication {
|
||||||
#!/bin/zsh
|
name = "switchmon";
|
||||||
|
text = ''
|
||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
hyprctl dispatch focusmonitor $(echo "$(hyprctl -j monitors)" | jq -r '.[] | select(.focused == false) | .name')
|
hyprctl dispatch focusmonitor "$(hyprctl -j monitors | jq -r '.[] | select(.focused == false) | .name')"
|
||||||
''
|
'';
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user