aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ne/neorg
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-04 11:48:44 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-04 11:48:44 +0200
commit135d09bfb305d54cac1ba1fb9861d5b9309a7b3a (patch)
tree459109a40320530993ae560f55a730a72df31416 /pkgs/by-name/ne/neorg
parentrefactor(modules/legacy/firefox): Move to by-name (diff)
downloadnixos-config-135d09bfb305d54cac1ba1fb9861d5b9309a7b3a.zip
feat(pkgs/neorg): Rewrite in rust
This improves upon neorg by integrating it better into the system context.
Diffstat (limited to 'pkgs/by-name/ne/neorg')
-rw-r--r--pkgs/by-name/ne/neorg/functions/add.sh23
-rw-r--r--pkgs/by-name/ne/neorg/functions/context.sh43
-rw-r--r--pkgs/by-name/ne/neorg/functions/dmenu.sh14
-rw-r--r--pkgs/by-name/ne/neorg/functions/f_start.sh7
-rw-r--r--pkgs/by-name/ne/neorg/functions/f_stop.sh7
-rw-r--r--pkgs/by-name/ne/neorg/functions/inputs.sh62
-rw-r--r--pkgs/by-name/ne/neorg/functions/list.sh8
-rw-r--r--pkgs/by-name/ne/neorg/functions/project.sh41
-rw-r--r--pkgs/by-name/ne/neorg/functions/review.sh12
-rw-r--r--pkgs/by-name/ne/neorg/functions/utils.sh40
-rw-r--r--pkgs/by-name/ne/neorg/functions/workspace.sh9
-rwxr-xr-xpkgs/by-name/ne/neorg/main.sh189
-rwxr-xr-xpkgs/by-name/ne/neorg/neorg_id_function.sh16
-rw-r--r--pkgs/by-name/ne/neorg/package.nix75
14 files changed, 0 insertions, 546 deletions
diff --git a/pkgs/by-name/ne/neorg/functions/add.sh b/pkgs/by-name/ne/neorg/functions/add.sh
deleted file mode 100644
index 5a830a10..00000000
--- a/pkgs/by-name/ne/neorg/functions/add.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env dash
-
-add0open_taskwarrior_project_file() {
- task_project_file="%TASK_PROJECT_FILE"
-
- cd "$(dirname $task_project_file)" || die "BUG: task_project_file ('$task_project_file') can't be accessed"
-
- git_dir="$(search_flake_base_dir)"
- [ "$git_dir" ] || die "(BUG): No git directory?"
- cd "$git_dir" || die "Unreachable, this MUST exists"
-
- nvim "$task_project_file"
- git add "$task_project_file"
-
- base_task_project_file_path="$(awk "{ gsub(\"$git_dir/\", \"\", \$0); print }" "$(ptmp "$task_project_file")")"
- git add $task_project_file
-
- # Check that only the project file has been added (and that our file is actually
- # modified)
- if git status --porcelain=v2 | awk -v path="$base_task_project_file_path" 'BEGIN { hit = 0 } { if ($2 ~ /A./ || $2 ~ /M./) { if ($NF ~ path) { hit = 1 } else { hit = 0; exit 1 } } } END { if (hit == 1) { exit 0 } else { exit 1 } }'; then
- git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update"
- fi
-}
diff --git a/pkgs/by-name/ne/neorg/functions/context.sh b/pkgs/by-name/ne/neorg/functions/context.sh
deleted file mode 100644
index 7095847d..00000000
--- a/pkgs/by-name/ne/neorg/functions/context.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env dash
-
-context0open_current_task_context() {
- current_context="$(utils0get_current_context)"
-
- if [ "$current_context" ]; then
- context_path="$(utils0get_current_context_path "$current_context")"
-
- extended_neorg_project_dir="$(utils0get_neorg_project_dir)"
- cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"
-
- nvim "$extended_neorg_project_dir/$context_path"
-
- git add .
- git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign
- else
- warn "No context active"
- fi
-}
-
-context0open_current_task_context_at_task_id() {
- task_id="$1"
- current_context="$(utils0get_current_context)"
-
- if [ "$current_context" ]; then
- context_path="$(utils0get_current_context_path "$current_context")"
- extended_neorg_project_dir="$(utils0get_neorg_project_dir)"
- task_uuid="$(task "$task_id" uuids)"
-
- cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"
-
- if ! grep -q "% $task_uuid" "$extended_neorg_project_dir/$context_path"; then
- echo "* TITLE (% $task_uuid)" >>"$extended_neorg_project_dir/$context_path"
- fi
-
- nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid"
-
- git add .
- git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign
- else
- warn "No context active"
- fi
-}
diff --git a/pkgs/by-name/ne/neorg/functions/dmenu.sh b/pkgs/by-name/ne/neorg/functions/dmenu.sh
deleted file mode 100644
index 5a138982..00000000
--- a/pkgs/by-name/ne/neorg/functions/dmenu.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env dash
-
-dmenu0open_context_in_browser() {
- project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)"
-
- if [ "$project" ]; then
- [ -d "%NEORG_REVIEW_PATH" ] || mkdir --parents "%NEORG_REVIEW_PATH"
- [ -f "%NEORG_REVIEW_PATH/$project.lock" ] || touch "%NEORG_REVIEW_PATH/$project.lock"
- project0open_project_in_browser "$project"
- else
- notify-send "(neorg/dmenu) No project selected"
- exit 1
- fi
-}
diff --git a/pkgs/by-name/ne/neorg/functions/f_start.sh b/pkgs/by-name/ne/neorg/functions/f_start.sh
deleted file mode 100644
index 2423dd44..00000000
--- a/pkgs/by-name/ne/neorg/functions/f_start.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env dash
-
-fstart0start_new_task() {
- task_id="$1"
- fstop0stop_current_task
- task start "$task_id"
-}
diff --git a/pkgs/by-name/ne/neorg/functions/f_stop.sh b/pkgs/by-name/ne/neorg/functions/f_stop.sh
deleted file mode 100644
index e4ff0b94..00000000
--- a/pkgs/by-name/ne/neorg/functions/f_stop.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env dash
-
-fstop0stop_current_task() {
- # we ensured that only one task may be active
- active="$(task +ACTIVE _ids)"
- [ "$active" ] && task stop "$active"
-}
diff --git a/pkgs/by-name/ne/neorg/functions/inputs.sh b/pkgs/by-name/ne/neorg/functions/inputs.sh
deleted file mode 100644
index d47b129a..00000000
--- a/pkgs/by-name/ne/neorg/functions/inputs.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/env dash
-
-_git_commit() {
- message="$1"
-
- cd "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" || die "BUG. This should exist."
- [ -d .git ] || git init
- git add .
- git commit --message "$message" --no-gpg-sign
-}
-
-inputs0add() {
- url_file="$1"
-
- mkdir --parents "$(dirname "%NEORG_INPUTS_STORAGE_FILE")"
-
- {
- # Add another newline
- echo ""
- # echo "# $url_file "
-
- clean "$url_file"
- } >>"%NEORG_INPUTS_STORAGE_FILE" &&
- msg2 "Successfully added file '$url_file' with $(clean "$url_file" | wc -l) entries to the url list"
-
- _git_commit "Add entries from '$url_file' ($(clean "$url_file" | wc -l))"
-}
-
-inputs0review() {
- base_profile="$1"
-
- [ -f "%NEORG_INPUTS_STORAGE_FILE" ] || die "'%NEORG_INPUTS_STORAGE_FILE' is not a file. Have you added something with 'inputs_add' yet?"
-
- done_urls="$(mktmp)"
-
- # We assume that the project is not yet open.
- firefox -P "$base_profile" &
- # Give it some time to start up.
- sleep 2
-
- if [ "$(wc -l <"%NEORG_INPUTS_STORAGE_FILE")" -gt 100 ]; then
- echo "Your would want to review more than 100 inputs. Limiting it to the first 100 entries."
- fi
-
- head --lines=100 "%NEORG_INPUTS_STORAGE_FILE" | while read -r url; do
- echo "-> '$url'"
- firefox -P "$base_profile" "$url"
-
- echo "$url" >>"$done_urls"
- done
-
- # Wait for the Firefox process from above to finish.
- wait
-
- tmp="$(mktmp)"
- # source: https://stackoverflow.com/a/24324455
- awk 'NR==FNR {a[$0]=1; next} !a[$0]' "$done_urls" "%NEORG_INPUTS_STORAGE_FILE" >"$tmp"
-
- mv "$tmp" "%NEORG_INPUTS_STORAGE_FILE"
-
- _git_commit "Dump entries into firefox profile '$base_profile'"
-}
diff --git a/pkgs/by-name/ne/neorg/functions/list.sh b/pkgs/by-name/ne/neorg/functions/list.sh
deleted file mode 100644
index 10659457..00000000
--- a/pkgs/by-name/ne/neorg/functions/list.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env dash
-
-list0list_all_contexts_newline() {
- print "%ALL_PROJECTS_NEWLINE"
-}
-list0list_all_contexts_comma() {
- print "%ALL_PROJECTS_COMMA"
-}
diff --git a/pkgs/by-name/ne/neorg/functions/project.sh b/pkgs/by-name/ne/neorg/functions/project.sh
deleted file mode 100644
index 64591850..00000000
--- a/pkgs/by-name/ne/neorg/functions/project.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env dash
-
-project0open_current_context_in_browser() {
- current_context="$(utils0get_current_context)"
- [ "$current_context" ] || die "No current context to use"
- project0open_context_in_browser "$(utils0context2project "$current_context")"
-}
-
-project0open_project_in_browser() {
- project="$1"
- [ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser"
-
- old_context="$(utils0get_current_context)"
- # We have ensured that only one task may be active
- old_started_task="$(task +ACTIVE _ids)"
-
- tracking="$(mktmp)"
- task "project:$project" _ids | xargs --no-run-if-empty task _zshids >"$tracking"
- task context "$(utils0project2context "$project")"
-
- while read -r description; do
- desc="$(echo "$description" | awk -F: '{print $2}')"
- if [ "$desc" = "tracking" ]; then
- task_id="$(echo "$description" | awk -F: '{print $1}')"
- notify-send "(Neorg)" "Starting task $project -> $desc"
- task start "$task_id"
- break
- fi
- done <"$tracking"
-
- firefox -P "$project"
-
- task stop "$task_id"
- [ "$old_started_task" ] && task start "$old_started_task"
-
- if [ "$old_context" ]; then
- task context "$old_context"
- else
- task context none
- fi
-}
diff --git a/pkgs/by-name/ne/neorg/functions/review.sh b/pkgs/by-name/ne/neorg/functions/review.sh
deleted file mode 100644
index a0a9ab8d..00000000
--- a/pkgs/by-name/ne/neorg/functions/review.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env dash
-
-review0start() {
- for project in $(list0list_all_contexts_newline); do
- if [ -f "%NEORG_REVIEW_PATH/$project.lock" ]; then
- msg "Reviewing '$project'"
- notify-send "Neorg" "Reviewing '$project'"
- firefox -P "$project"
- rm "%NEORG_REVIEW_PATH/$project.lock"
- fi
- done
-}
diff --git a/pkgs/by-name/ne/neorg/functions/utils.sh b/pkgs/by-name/ne/neorg/functions/utils.sh
deleted file mode 100644
index c3843e8e..00000000
--- a/pkgs/by-name/ne/neorg/functions/utils.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env dash
-
-# Runs it's first argument and then the second, regardless if the first failed or
-# succeeded
-utils0chain() {
- eval "$1"
- eval "$2"
-}
-
-utils0get_current_context() {
- current_context="$(task _get rc.context)"
- printf "%s\n" "$current_context"
-}
-
-utils0get_current_context_path() {
- current_context="$1"
- context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)"
- if ! [ "$context_path" ]; then
- context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')"
- [ "$context_path" ] || die "All contexts should have a 'neorg_path' set!"
- fi
- printf "%s\n" "$context_path"
-}
-
-utils0get_neorg_project_dir() {
- # Perform shell expansion of Tilde
- neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")"
- printf "%s\n" "$neorg_project_dir"
-}
-
-utils0project2context() {
- project="$1"
- context="$(sed 's|\.|_|g' "$(ptmp "$project")")"
- printf "%s\n" "$context"
-}
-utils0context2project() {
- context="$1"
- project="$(sed 's|_|\.|g' "$(ptmp "$context")")"
- printf "%s\n" "$project"
-}
diff --git a/pkgs/by-name/ne/neorg/functions/workspace.sh b/pkgs/by-name/ne/neorg/functions/workspace.sh
deleted file mode 100644
index d5eb2fca..00000000
--- a/pkgs/by-name/ne/neorg/functions/workspace.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env dash
-
-workspace0open_neorg_workspace() {
- workspace="$1"
- nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace $workspace\n")"
-}
-workspace0open_neorg_workspace_prompt() {
- nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace ")"
-}
diff --git a/pkgs/by-name/ne/neorg/main.sh b/pkgs/by-name/ne/neorg/main.sh
deleted file mode 100755
index b4f0f0e6..00000000
--- a/pkgs/by-name/ne/neorg/main.sh
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/usr/bin/env dash
-
-# shellcheck source=/dev/null
-SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH
-
-# load dependencies
-. ./functions/add.sh
-. ./functions/context.sh
-. ./functions/dmenu.sh
-. ./functions/f_start.sh
-. ./functions/f_stop.sh
-. ./functions/inputs.sh
-. ./functions/list.sh
-. ./functions/project.sh
-. ./functions/review.sh
-. ./functions/utils.sh
-. ./functions/workspace.sh
-
-# these are used in version()
-# shellcheck disable=2034
-AUTHORS="Soispha"
-# shellcheck disable=2034
-YEARS="2023"
-
-NAME="neorg"
-
-help() {
- cat <<EOF
-This is the core interface to the system-integrated task management
-
-USAGE:
- $NAME [OPTIONS] [COMMAND]
-
-OPTIONS:
- --help | -h
- Display this help and exit.
-
- --version | -v
- Display version and copyright information and exit.
-COMMANDS:
- task [ID]
- Open the neorg context associated with the current context and
- the uuid of the task with id ID. Without ID, it'll open the
- current context's norg file.
- If no context is set, drops you to the selection prompt
-
- dmenu
- Select a project in dmenu mode. This will give you all projects
- and exectute the selected one as in 'neorg projects <selected>'
-
- workspace [WS]
- The neorg workspace (WS) to open at startup, an empty value drops
- you at a prompt to enter the workspace yourself.
-
- project [P]
- Opens the webbrowser with either the context (P) or
- the current active context as argument if no context is supplied
-
- list
- Lists all available contexts
-
- add
- Allows you to quickly add projects
-
- fstart ID
- Starts the task (ID) but only after it stooped
- the previous active task, if it existed.
-
- fstop
- Stops the current active task
-
- review
- Review all firefox tabs
-
- inputs_add F
- Add all urls from the file F as inputs to be catogorized
-
- inputs_review P
- Like 'review', but for the inputs that have previously been added.
- It takes a project in which to open the urls.
-ARGUMENTS:
- ID | *([0-9]) := [[%ID_GENERATION_FUNCTION]]
- The function displays all possible IDs of the eligable tasks.
-
- WS := %ALL_WORKSPACES
- All possible workspaces.
-
- P := %ALL_PROJECTS_PIPE
- The possible project.
-
- F := [[fd . --max-depth 3]]
- A URL-Input file to use as source.
-
-EOF
-}
-
-for arg in "$@"; do
- case "$arg" in
- "--help" | "-h")
- help
- exit 0
- ;;
- "--version" | "-v")
- version
- exit 0
- ;;
- esac
-done
-
-while [ "$#" -ne 0 ]; do
- case "$1" in
- "t"*) # task
- shift 1
- task_id="$1"
- [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0"
- context0open_current_task_context_at_task_id "$task_id"
- exit 0
- ;;
- "w"*) # workspace
- shift 1
- workspace_to_open="$1"
- # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
- [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0"
- workspace0open_neorg_workspace "$workspace_to_open"
- exit 0
- ;;
- "p"*) # project
- shift 1
- project_to_open="$1"
- # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
- [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0"
- if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then
- die "Your project ('$project_to_open') is not in the list of available projects:
-%ALL_PROJECTS_COMMA"
- fi
- project0open_project_in_browser "$project_to_open"
- exit 0
- ;;
- "l"*) # list
- list0list_all_contexts_newline
- exit 0
- ;;
- "a"*) # add-project
- add0open_taskwarrior_project_file
- exit 0
- ;;
- "d"*) # dmenu
- dmenu0open_context_in_browser
- exit 0
- ;;
- "fsta"*) # fstart
- shift 1
- task_id="$1"
- [ "$task_id" ] || die "No task id provided to fstart"
- fstart0start_new_task "$task_id"
- exit 0
- ;;
- "fsto"*) # fstop
- fstop0stop_current_task
- exit 0
- ;;
- "r"*) # review
- shift 1
- review0start
- exit 0
- ;;
- "inputs_a"*) # inputs_add
- shift 1
- url_file="$1"
- [ -f "$url_file" ] || die "Url file ('$url_file') is not a valid file."
- inputs0add "$url_file"
- exit 0
- ;;
- "inputs_r"*) # inputs_review
- shift 1
- base_project="$1"
- [ -z "$base_project" ] && die "'inputs_review' requires a project."
- inputs0review "$base_project"
- exit 0
- ;;
- *)
- die "Command '$1' does not exist! Please look at:\n $NAME --help"
- exit 0
- ;;
- esac
-done
-
-context0open_current_task_context
-# vim: ft=sh
diff --git a/pkgs/by-name/ne/neorg/neorg_id_function.sh b/pkgs/by-name/ne/neorg/neorg_id_function.sh
deleted file mode 100755
index 865ecacf..00000000
--- a/pkgs/by-name/ne/neorg/neorg_id_function.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#! /usr/bin/env dash
-
-# shellcheck source=/dev/null
-SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH
-
-context="$(task _get rc.context)"
-if [ "$context" ]; then
- filter="project:$context"
-else
- filter="0-10000"
-fi
-tasks="$(task "$filter" _ids)"
-
-if [ "$tasks" ]; then
- echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}'
-fi
diff --git a/pkgs/by-name/ne/neorg/package.nix b/pkgs/by-name/ne/neorg/package.nix
deleted file mode 100644
index ad39290a..00000000
--- a/pkgs/by-name/ne/neorg/package.nix
+++ /dev/null
@@ -1,75 +0,0 @@
-{
- lib,
- sysLib,
- # dependencies
- cocogitto,
- rofi,
- libnotify,
- taskwarrior,
- gawk,
- findutils,
- # config
- defaultNeorgProjectDir ? "/no-default-dir", # homeConfig.programs.nixvim.plugins.neorg.settings.load."core.dirman".config.workspaces.projects
- allProjectsNewline ? "", # homeConfig.soispha.taskwarrior.projects.projects_newline
- allProjectsComma ? "", # homeConfig.soispha.taskwarrior.projects.projects_comma
- allProjectsPipe ? "", # homeConfig.soispha.taskwarrior.projects.projects_pipe
- allWorkspaces ? {}, # homeConfig.programs.nixvim.plugins.neorg.settings.load."core.dirman".config.workspaces
- xdgConfigHome ? builtins.getEnv "XDG_CONFIG_HOME",
- xdgDataHome ? builtins.getEnv "XDG_DATA_HOME",
-}:
-(sysLib.writeShellScriptMultiPart {
- name = "neorg";
- src = ./.;
- generateCompletions = true;
- keepPath = true;
-
- baseName = "main.sh";
- cmdPrefix = "functions";
- cmdNames = [
- "add.sh"
- "context.sh"
- "dmenu.sh"
- "f_start.sh"
- "f_stop.sh"
- "inputs.sh"
- "list.sh"
- "project.sh"
- "review.sh"
- "utils.sh"
- "workspace.sh"
- ];
-
- dependencies = [
- cocogitto
- rofi
- libnotify
- ];
- replacementStrings = {
- DEFAULT_NEORG_PROJECT_DIR = defaultNeorgProjectDir;
- HOME_TASKRC = "${xdgConfigHome}/task/home-manager-taskrc";
- NEORG_REVIEW_PATH = "${xdgDataHome}/neorg/review";
-
- NEORG_INPUTS_STORAGE_FILE = "${xdgDataHome}/neorg/inputs/url_list.txt";
-
- ALL_PROJECTS_NEWLINE = allProjectsNewline;
- ALL_PROJECTS_COMMA = allProjectsComma;
- ALL_PROJECTS_PIPE = allProjectsPipe;
- ALL_WORKSPACES = "${lib.strings.concatStringsSep "|" (builtins.attrNames allWorkspaces)}";
-
- ID_GENERATION_FUNCTION = "${sysLib.writeShellScript {
- name = "neorg_id_function";
- src = ./neorg_id_function.sh;
- dependencies = [
- taskwarrior
- gawk
- findutils # source of xargs
- ];
- }}/bin/neorg_id_function";
-
- # TODO: Replace the hard-coded path here with some reference <2023-10-20>
- TASK_PROJECT_FILE = "/home/soispha/repos/nix/nixos-config/hm/soispha/conf/taskwarrior/projects/default.nix";
- };
-})
-// {
- meta.mainProgram = "neorg";
-}