diff --git a/lib/shared/home-manager-packages.nix b/lib/shared/home-manager-packages.nix index 3206050b..f8ccc6d7 100644 --- a/lib/shared/home-manager-packages.nix +++ b/lib/shared/home-manager-packages.nix @@ -11,6 +11,9 @@ let inherit (pkgs) writeShellApplication; _timer = writeShellApplication (import ./scripts/_timer.nix); + export-video-list = writeShellApplication ( + import ./scripts/export-video-list.nix { inherit pkgs; } + ); notetaker = writeShellApplication (import ./scripts/notetaker.nix); run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; }); t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; }); @@ -68,5 +71,6 @@ with pkgs; ++ pkgs.lib.optionals desktop [ # Scripts. _timer + export-video-list timer ] diff --git a/lib/shared/modules/zsh/abbreviations.zsh b/lib/shared/modules/zsh/abbreviations.zsh index 87d4f826..79299e4e 100644 --- a/lib/shared/modules/zsh/abbreviations.zsh +++ b/lib/shared/modules/zsh/abbreviations.zsh @@ -5,6 +5,9 @@ abbr daily="run create-daily next" abbr switch="run nixos nixedo switch" abbr sz="source ~/.config/zsh/.zshrc" +abbr evl="export-video-list" +abbr vv="cat ~/Documents/videos.json" + abbr g="git" abbr ga="git add" abbr gap="git add -p" diff --git a/lib/shared/scripts/export-video-list.nix b/lib/shared/scripts/export-video-list.nix new file mode 100644 index 00000000..9b82f11e --- /dev/null +++ b/lib/shared/scripts/export-video-list.nix @@ -0,0 +1,33 @@ +{ pkgs, ... }: +{ + name = "export-video-list"; + + runtimeInputs = with pkgs; [ + jq + tree + udisks + ]; + + text = '' + device_name="/dev/sda2" + device_label="UNTITLED" + + source_path="/run/media/opdavies/$device_label" + + # If the source path doesn't exist, try mounting the device. + if [[ ! -d "$source_path" ]]; then + ${pkgs.udisks}/bin/udisksctl mount -b "$device_name" + fi + + # Exit early if the source path still doesn't exist. + if [[ ! -d "$source_path" ]]; then + echo "Error: $source_path not found." + exit 1 + fi + + output_file="$HOME/Documents/videos.json" + + ${pkgs.tree}/bin/tree -J "$source_path/Videos" | jq . > "$output_file" + ${pkgs.jq}/bin/jq . < "$output_file" + ''; +}