first test
This commit is contained in:
11
.scripts/bin/calcurse-toggle.sh
Executable file
11
.scripts/bin/calcurse-toggle.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
if pgrep -f "foot --title floatcal" >/dev/null; then
|
||||
# If a process with "foot --title floatcal" is found, kill it
|
||||
pkill -f "foot --title floatcal"
|
||||
else
|
||||
# Otherwise, launch it via hyprctl
|
||||
if ! hyprctl dispatch exec 'foot --title floatcal calcurse'; then
|
||||
echo "Failed to launch calcurse in foot terminal"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
2
.scripts/bin/calsync.sh
Executable file
2
.scripts/bin/calsync.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
hyprctl dispatch exec calcurse-caldav
|
||||
52
.scripts/bin/extract.sh
Executable file
52
.scripts/bin/extract.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SAVEIFS=$IFS
|
||||
IFS="$(printf '\n\t')"
|
||||
|
||||
function extract {
|
||||
if [ $# -eq 0 ]; then
|
||||
# display usage if no parameters given
|
||||
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz|.zlib|.cso>"
|
||||
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
||||
fi
|
||||
for n in "$@"; do
|
||||
if [ ! -f "$n" ]; then
|
||||
echo "'$n' - file doesn't exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
case "''${n%,}" in
|
||||
*.cbt | *.tar.bz2 | *.tar.gz | *.tar.xz | *.tbz2 | *.tgz | *.txz | *.tar)
|
||||
tar zxvf "$n"
|
||||
;;
|
||||
*.lzma) unlzma ./"$n" ;;
|
||||
*.bz2) bunzip2 ./"$n" ;;
|
||||
*.cbr | *.rar) unrar x -ad ./"$n" ;;
|
||||
*.gz) gunzip ./"$n" ;;
|
||||
*.cbz | *.epub | *.zip) unzip ./"$n" ;;
|
||||
*.z) uncompress ./"$n" ;;
|
||||
*.7z | *.apk | *.arj | *.cab | *.cb7 | *.chm | *.deb | *.iso | *.lzh | *.msi | *.pkg | *.rpm | *.udf | *.wim | *.xar | *.vhd)
|
||||
7z x ./"$n"
|
||||
;;
|
||||
*.xz) unxz ./"$n" ;;
|
||||
*.exe) cabextract ./"$n" ;;
|
||||
*.cpio) cpio -id <./"$n" ;;
|
||||
*.cba | *.ace) unace x ./"$n" ;;
|
||||
*.zpaq) zpaq x ./"$n" ;;
|
||||
*.arc) arc e ./"$n" ;;
|
||||
*.cso) ciso 0 ./"$n" ./"$n.iso" &&
|
||||
extract "$n.iso" && \rm -f "$n" ;;
|
||||
*.zlib) zlib-flate -uncompress <./"$n" >./"$n.tmp" &&
|
||||
mv ./"$n.tmp" ./"''${n%.*zlib}" && rm -f "$n" ;;
|
||||
*.dmg)
|
||||
hdiutil mount ./"$n" -mountpoint "./$n.mounted"
|
||||
;;
|
||||
*)
|
||||
echo "extract: '$n' - unknown archive method"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
IFS=$SAVEIFS
|
||||
8
.scripts/bin/mako-toggle.sh
Executable file
8
.scripts/bin/mako-toggle.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Toggle Mako mode between "do-not-disturb" and "default"
|
||||
if makoctl mode | grep -q "default"; then
|
||||
makoctl set-mode do-not-disturb
|
||||
else
|
||||
makoctl set-mode default
|
||||
fi
|
||||
10
.scripts/bin/mako.sh
Executable file
10
.scripts/bin/mako.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
COUNT=$(makoctl list | grep -c "id")
|
||||
ENABLED=
|
||||
DISABLED=
|
||||
if [ "$COUNT" != 0 ]; then DISABLED=""; fi
|
||||
if [ "$(
|
||||
makoctl mode | grep -q "default"
|
||||
echo $?
|
||||
)" -eq 0 ]; then echo $ENABLED; else echo $DISABLED; fi
|
||||
9
.scripts/bin/pavucontrol-toggle.sh
Executable file
9
.scripts/bin/pavucontrol-toggle.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
if pgrep -f "pavucontrol" >/dev/null; then
|
||||
pkill -f "pavucontrol"
|
||||
else
|
||||
if ! hyprctl dispatch exec pavucontrol; then
|
||||
echo "Failed to launch Pavucontrol"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
6
.scripts/bin/rangerscript.sh
Executable file
6
.scripts/bin/rangerscript.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
if pgrep -f floatranger; then
|
||||
pkill -f floatranger
|
||||
else
|
||||
hyprctl dispatch exec 'foot --title floatranger ranger'
|
||||
fi
|
||||
26
.scripts/bin/tuirun-toggle.sh
Executable file
26
.scripts/bin/tuirun-toggle.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Path to the tuirun executable
|
||||
TUIRUN_PATH="/etc/profiles/per-user/$USER/bin/tuirun"
|
||||
LOGFILE="$HOME/tuirun_debug.log"
|
||||
|
||||
echo "Launching tuirun..." >>"$LOGFILE"
|
||||
date >>"$LOGFILE"
|
||||
|
||||
if pgrep -f "alacritty --title tuirun" >/dev/null; then
|
||||
echo "Terminating existing tuirun process" >>"$LOGFILE"
|
||||
pkill -f "alacritty --title tuirun"
|
||||
else
|
||||
echo "Starting new tuirun process" >>"$LOGFILE"
|
||||
if ! hyprctl dispatch exec "alacritty --title tuirun -e sh -c '$TUIRUN_PATH'"; then
|
||||
echo "Failed to launch tuirun in foot terminal" >>"$LOGFILE"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1 # Give it a second to start
|
||||
echo "Checking if tuirun process is still running..." >>"$LOGFILE"
|
||||
if pgrep -f "$TUIRUN_PATH" >/dev/null; then
|
||||
echo "tuirun is running" >>"$LOGFILE"
|
||||
else
|
||||
echo "tuirun exited prematurely" >>"$LOGFILE"
|
||||
fi
|
||||
fi
|
||||
114
.scripts/bin/volume-control.sh
Executable file
114
.scripts/bin/volume-control.sh
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
iDIR="$HOME/.config/mako/icons"
|
||||
|
||||
# Get Volume
|
||||
get_volume() {
|
||||
pamixer --get-volume
|
||||
}
|
||||
|
||||
# Get icons
|
||||
get_icon() {
|
||||
current=$(get_volume)
|
||||
case $current in
|
||||
0)
|
||||
echo "$iDIR/vol_off.svg"
|
||||
;;
|
||||
[1-9] | [1-2][0-9] | 30)
|
||||
echo "$iDIR/vol_mute.svg"
|
||||
;;
|
||||
[3-5][0-9] | 60)
|
||||
echo "$iDIR/vol_down.svg"
|
||||
;;
|
||||
*)
|
||||
echo "$iDIR/vol_up.svg"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Notify
|
||||
notify_user() {
|
||||
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume : $(get_volume) %"
|
||||
}
|
||||
|
||||
# Increase Volume
|
||||
inc_volume() {
|
||||
pamixer -i 5 && notify_user
|
||||
}
|
||||
|
||||
# Decrease Volume
|
||||
dec_volume() {
|
||||
pamixer -d 5 && notify_user
|
||||
}
|
||||
|
||||
# Toggle Mute
|
||||
toggle_mute() {
|
||||
if pamixer --get-mute | grep -q "false"; then
|
||||
pamixer -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/vol_off.svg" "Volume Switched OFF"
|
||||
else
|
||||
pamixer -u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume Switched ON"
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggle Mic
|
||||
toggle_mic() {
|
||||
if pamixer --default-source --get-mute | grep -q "false"; then
|
||||
pamixer --default-source -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/mic_off.svg" "Microphone Switched OFF"
|
||||
else
|
||||
pamixer --default-source -u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/mic.svg" "Microphone Switched ON"
|
||||
fi
|
||||
}
|
||||
|
||||
# Get mic icons
|
||||
get_mic_icon() {
|
||||
echo "$iDIR/mic.svg"
|
||||
}
|
||||
|
||||
# Notify
|
||||
notify_mic_user() {
|
||||
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_mic_icon)" "Mic-Level : $(pamixer --default-source --get-volume) %"
|
||||
}
|
||||
|
||||
# Increase MIC Volume
|
||||
inc_mic_volume() {
|
||||
pamixer --default-source -i 5 && notify_mic_user
|
||||
}
|
||||
|
||||
# Decrease MIC Volume
|
||||
dec_mic_volume() {
|
||||
pamixer --default-source -d 5 && notify_mic_user
|
||||
}
|
||||
|
||||
# Execute accordingly
|
||||
case $1 in
|
||||
--get)
|
||||
get_volume
|
||||
;;
|
||||
--inc)
|
||||
inc_volume
|
||||
;;
|
||||
--dec)
|
||||
dec_volume
|
||||
;;
|
||||
--toggle)
|
||||
toggle_mute
|
||||
;;
|
||||
--toggle-mic)
|
||||
toggle_mic
|
||||
;;
|
||||
--get-icon)
|
||||
get_icon
|
||||
;;
|
||||
--get-mic-icon)
|
||||
get_mic_icon
|
||||
;;
|
||||
--mic-inc)
|
||||
inc_mic_volume
|
||||
;;
|
||||
--mic-dec)
|
||||
dec_mic_volume
|
||||
;;
|
||||
*)
|
||||
get_volume
|
||||
;;
|
||||
esac
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script to clean up old initrd and kernel files in /boot/EFI/nixos
|
||||
# Make sure it's added to flake.nix, then run:
|
||||
# "nix build .#packages.x86_64-linux.cleanup-boot".
|
||||
|
||||
# Exit on any error, undefined variable, or pipeline failure
|
||||
set -euo pipefail
|
||||
@@ -96,19 +98,19 @@ for file in "${efi_files[@]}"; do
|
||||
basename=$(basename "$file")
|
||||
|
||||
# Pattern: <hash>-linux-<version>-bzImage.efi (kernel)
|
||||
if [[ "$basename" =~ ^(.*)-linux-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-bzImage\.efi$ ]]; then
|
||||
if [[ "$basename" =~ ^(.*)-linux-([0-9]+\.[0-9]+(\.[0-9]+)?)\-bzImage\.efi$ ]]; then
|
||||
kernel_files+=("$file")
|
||||
|
||||
# Pattern: <hash>-initrd-linux-<version>-initrd.efi (initrd)
|
||||
elif [[ "$basename" =~ ^(.*)-initrd-linux-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-initrd\.efi$ ]]; then
|
||||
elif [[ "$basename" =~ ^(.*)-initrd-linux-([0-9]+\.[0-9]+(\.[0-9]+)?)\-initrd\.efi$ ]]; then
|
||||
initrd_files+=("$file")
|
||||
|
||||
# Pattern: kernel-<version>-<hash>.efi (kernel)
|
||||
elif [[ "$basename" =~ ^kernel-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-([a-zA-Z0-9]+)\.efi$ ]]; then
|
||||
elif [[ "$basename" =~ ^kernel-([0-9]+\.[0-9]+(\.[0-9]+)?)\-([a-zA-Z0-9\-]+)\.efi$ ]]; then
|
||||
kernel_files+=("$file")
|
||||
|
||||
# Pattern: initrd-<version>-<hash>.efi (initrd)
|
||||
elif [[ "$basename" =~ ^initrd-([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.\+]+)?)-([a-zA-Z0-9]+)\.efi$ ]]; then
|
||||
elif [[ "$basename" =~ ^initrd-([0-9]+\.[0-9]+(\.[0-9]+)?)\-([a-zA-Z0-9\-]+)\.efi$ ]]; then
|
||||
initrd_files+=("$file")
|
||||
|
||||
else
|
||||
@@ -126,10 +128,10 @@ process_files() {
|
||||
log "Processing $file_type files..."
|
||||
|
||||
if [ "${#files[@]}" -gt "$keep_count" ]; then
|
||||
# Sort files by modification time and keep the latest N files
|
||||
# Sort files by modification time (newest first)
|
||||
sorted_files=$(for f in "${files[@]}"; do echo "$(stat -c '%Y' "$f"):$f"; done | sort -rn -k1,1)
|
||||
|
||||
# Collect files to delete
|
||||
# Collect files to delete (older than the top N)
|
||||
mapfile -t files_to_delete < <(echo "$sorted_files" | tail -n +"$((keep_count + 1))" | cut -d: -f2)
|
||||
|
||||
for file in "${files_to_delete[@]}"; do
|
||||
@@ -145,7 +147,7 @@ process_files() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Process initrd and kernel files
|
||||
# Process kernel and initrd files
|
||||
process_files kernel_files "$KEEP_KERNEL" "kernel"
|
||||
process_files initrd_files "$KEEP_INITRD" "initrd"
|
||||
|
||||
|
||||
58
.scripts/default.nix
Normal file
58
.scripts/default.nix
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) getExe;
|
||||
inherit (builtins) readFile;
|
||||
in {
|
||||
home = {
|
||||
# Ensure the scripts are linked in the session PATH
|
||||
sessionPath = ["${config.home.homeDirectory}/.local/bin"];
|
||||
|
||||
# Link the pavucontrol script to the local PATH
|
||||
file = {
|
||||
".local/bin/pavucontrol-toggle.sh" = {
|
||||
source = getExe (pkgs.writeShellApplication {
|
||||
name = "pavucontrol-toggle";
|
||||
runtimeInputs = with pkgs; [hyprland]; # Add any required runtime dependencies here
|
||||
text = readFile ./bin/pavucontrol-toggle.sh; # Path to your pavucontrol.sh script
|
||||
});
|
||||
};
|
||||
|
||||
".local/bin/tuirun-toggle.sh" = {
|
||||
source = getExe (pkgs.writeShellApplication {
|
||||
name = "tuirun-toggle";
|
||||
runtimeInputs = with pkgs; [hyprland]; # Add any required runtime dependencies here
|
||||
text = readFile ./bin/tuirun-toggle.sh; # Path to your tuirun-toggle.sh script
|
||||
});
|
||||
};
|
||||
|
||||
".local/bin/calcurse-toggle.sh" = {
|
||||
source = getExe (pkgs.writeShellApplication {
|
||||
name = "calcurse-toggle";
|
||||
runtimeInputs = with pkgs; [hyprland]; # Add any required runtime dependencies here
|
||||
text = readFile ./bin/calcurse-toggle.sh; # Path to your calcurse-toggle.sh script
|
||||
});
|
||||
};
|
||||
|
||||
".local/bin/volume-control.sh" = {
|
||||
source = getExe (pkgs.writeShellApplication {
|
||||
name = "volume-control";
|
||||
runtimeInputs = with pkgs; [pamixer libnotify]; # Add any required runtime dependencies here
|
||||
text = readFile ./bin/volume-control.sh; # Path to your volume-control.sh script
|
||||
});
|
||||
};
|
||||
|
||||
".local/bin/extract.sh" = {
|
||||
# Stolen from NotAShelf
|
||||
source = getExe (pkgs.writeShellApplication {
|
||||
name = "extract";
|
||||
runtimeInputs = with pkgs; [zip unzip gnutar p7zip];
|
||||
text = readFile ./bin/extract.sh;
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user