diff --git a/scripts/abs-nu-exec.nu b/scripts/abs-nu-exec.nu index 45ec2e9..42781e5 100755 --- a/scripts/abs-nu-exec.nu +++ b/scripts/abs-nu-exec.nu @@ -3,6 +3,6 @@ # Copyright (c) 2025 MatrixFurry # Useful for executing nushell scripts in GNOME keyboard shortcuts without adding Homebrew PATH to your shell environment -def main [...command] { +export def main [...command] { exec /home/linuxbrew/.linuxbrew/bin/nu -l -c ($command | str join ' ') } diff --git a/scripts/adb-auto-connect.nu b/scripts/adb-auto-connect.nu index 2d23878..0a4ad01 100755 --- a/scripts/adb-auto-connect.nu +++ b/scripts/adb-auto-connect.nu @@ -2,9 +2,7 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -let mac = open ("~/.config/adb-auto-connect.nuon" | path expand) -def main [] { # Automatically find and connect to an Android device with Wireless Debugging over the local network. # # You'll need to create a file at `~/.config/adb-auto-connect.nuon` with the MAC Addresses you want to search for. For example: @@ -14,6 +12,8 @@ def main [] { # "aa:aa:aa:aa:aa:aa" # ] # ``` +export def main [] { + let mac = open ("~/.config/adb-auto-connect.nuon" | path expand) let connected = (adb devices -l | lines | skip | drop | length) > 0 if $connected { diff --git a/scripts/atproto-app-passwords.nu b/scripts/atproto-app-passwords.nu index 34e406d..b32c13e 100755 --- a/scripts/atproto-app-passwords.nu +++ b/scripts/atproto-app-passwords.nu @@ -2,10 +2,10 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2026 MatrixFurry -def main [ # Create an app password for your ATProto account. # # TODO: Add subcommands to list and delete +export def main [ --pds-host: string = "https://tngl.sh" handle: string name: string diff --git a/scripts/auto-benchmark.nu b/scripts/auto-benchmark.nu index 6332828..2e82e9e 100755 --- a/scripts/auto-benchmark.nu +++ b/scripts/auto-benchmark.nu @@ -2,11 +2,12 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std [log assert] +use std/log +use std/assert -def main [ # Set up and run a Blender benchmark on the specified device, then automatically # compare your results to the results on [Blender Open Data](https://opendata.blender.org/). +export def main [ --debug: string # NUON ] { log info "Getting latest version" diff --git a/scripts/clean-bin.nu b/scripts/clean-bin.nu index aa30c6e..4f31d73 100755 --- a/scripts/clean-bin.nu +++ b/scripts/clean-bin.nu @@ -2,8 +2,8 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2026 MatrixFurry -def main [] { # Remove broken symlinks from `~/.local/bin` +export def main [] { ls -l ~/.local/bin | where type == symlink | each {|link| diff --git a/scripts/detect-gpu-issues.nu b/scripts/detect-gpu-issues.nu index 010c21c..a02114e 100755 --- a/scripts/detect-gpu-issues.nu +++ b/scripts/detect-gpu-issues.nu @@ -2,15 +2,15 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std log +use std/log -def main [] { # Detect issues with the GPU. # # This was created for my own use on a Framework Laptop 16 with an external dock. # Sometimes, the external GPU will have issues caused by my hacky m.2 to oculink adapter. # # I can't guarantee this will work for you, but it does reliably detect when there is an issue on my system. +export def main [] { let vkinfo = vulkaninfo --summary o+e>| $in if ($vkinfo diff --git a/scripts/extract-m4a.nu b/scripts/extract-m4a.nu index d21c950..4d31220 100755 --- a/scripts/extract-m4a.nu +++ b/scripts/extract-m4a.nu @@ -2,10 +2,10 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std log +use std/log # Extract audio from a m4a file to the codec's native container -def main [ +export def main [ path: path --rm # Remove the original file after conversion ] { diff --git a/scripts/homepod-mini-workaround.nu b/scripts/homepod-mini-workaround.nu index 877ea24..a7b17dd 100755 --- a/scripts/homepod-mini-workaround.nu +++ b/scripts/homepod-mini-workaround.nu @@ -2,8 +2,8 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -def main [sink: string] { # see https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3279 +export def main [sink: string] { loop { pactl set-sink-volume $sink -1% sleep 20sec diff --git a/scripts/lh-pairall.nu b/scripts/lh-pairall.nu index d8d5030..563ed49 100755 --- a/scripts/lh-pairall.nu +++ b/scripts/lh-pairall.nu @@ -2,7 +2,10 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -# TODO: Auto detect executable if not in path -# OPTIMIZE: Send commands on stdin, do not init lh console twice -lighthouse_console dongleresetall -lighthouse_console pairall +# Reset all Watchman (lighthouse_console) dongles and put them into pairing mode. +export def main [] { + # TODO: Auto detect executable if not in path + # OPTIMIZE: Send commands on stdin, do not init lh console twice + lighthouse_console dongleresetall + lighthouse_console pairall +} diff --git a/scripts/ln-bin.nu b/scripts/ln-bin.nu index e29ba27..b1ed5a7 100755 --- a/scripts/ln-bin.nu +++ b/scripts/ln-bin.nu @@ -3,7 +3,7 @@ # Copyright (c) 2025 MatrixFurry # Quickly symlink executable files to `~/.local/bin/` -def main [bin: path, name?: string] { +export def main [bin: path, name?: string] { let name = $name | default ($bin | path parse | get stem) ln -s ($bin | path expand) $"($env.HOME)/.local/bin/($name)" } diff --git a/scripts/lyricfetch.nu b/scripts/lyricfetch.nu index 9c7d322..5b8d6e8 100755 --- a/scripts/lyricfetch.nu +++ b/scripts/lyricfetch.nu @@ -2,15 +2,17 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std [log null-device] +use std/log +use std/util + -def main [ # > [!NOTE] # > I reccomend using a [lrclib](https://lrclib.net/) client such as [lrcget](https://github.com/tranxuanthang/lrcget) or [Chronograph](https://flathub.org/apps/io.github.dzheremi2.lrcmake-gtk) instead! # # Fetches lyrics from Genius using a [Dumb](https://github.com/rramiachraf/dumb) instance, and adds them to your music library's metadata. # # Currently only supports FLAC files. +export def main [ --library (-l): path = ("~/Music" | path expand) --dumb-instance (-d): string = "https://dumb.hyperreal.coffee" --db-path: path = ("~/.local/share/lyricfetch.nuon" | path expand) @@ -82,7 +84,7 @@ def main [ log debug "Getting file tags" let meta = metaflac $file --show-all-tags | parse "{key}={value}" - | reduce --fold {} {|it, acc| $acc | upsert ($it.key | str downcase) $it.value} + | reduce --fold {} {|it, acc| $acc | upsert ($it.key | str lowercase) $it.value} if ($meta.artist? == null) or ($meta.title? == null) { print $"(ansi yellow)`($file)`(ansi red) doesn't contain artist and title tags, cannot search for lyrics(ansi reset)" @@ -135,9 +137,9 @@ def "fetch-lyrics dumb" [ return null } - if ($search_result.title | str downcase) != ($title | str downcase) or ($search_result.artist | str downcase) != ($artist | str downcase) { + if ($search_result.title | str lowercase) != ($title | str lowercase) or ($search_result.artist | str lowercase) != ($artist | str lowercase) { print -n $"Best result: (ansi green)($search_result.title)(ansi reset) by (ansi green)($search_result.artist)(ansi reset). Is this correct? [Y/n]: " - match (input -n 1 | str downcase) { + match (input -n 1 | str lowercase) { "n" => (return null) } } diff --git a/scripts/podman-remote-tcp.nu b/scripts/podman-remote-tcp.nu index 4d7edbb..28ee1cf 100755 --- a/scripts/podman-remote-tcp.nu +++ b/scripts/podman-remote-tcp.nu @@ -2,10 +2,10 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -def main [ # Create up a Podman remote TCP connection to a machine over SSH. This is insecure, be careful. @deprecated --report every "Use pods-remote instead" @category depricated +export def main [ remote?: string ...rest --root (-r) # Connect to rootful socket diff --git a/scripts/pods-remote.nu b/scripts/pods-remote.nu index 327af70..47fcbef 100755 --- a/scripts/pods-remote.nu +++ b/scripts/pods-remote.nu @@ -4,7 +4,7 @@ # Create a podman socket connection over SSH # This will not work with Tailscale SSH, see https://github.com/tailscale/tailscale/issues/5295 -def main [ +export def main [ remote: string --uid (-u): int # Remote user ID --name (-n): string # Socket name diff --git a/scripts/rawrsync.nu b/scripts/rawrsync.nu index f829ddf..8921718 100755 --- a/scripts/rawrsync.nu +++ b/scripts/rawrsync.nu @@ -6,7 +6,6 @@ use std/log const config_path: path = ".rawrsync.toml" -def main [ # Easily sync or deploy projects over rsync. Intended to somewhat replicate CLion's Deployment feature for use with other IDEs. # # Configure with `.rawrsync.toml` in your project root. For example: @@ -21,6 +20,7 @@ def main [ # address = "vr-desktop.tailnet-name.ts.net" # path = "/home/username/vr/project" # ``` +export def main [ select?: string # Select a configuration by name --continuous (-c) # Sync on file change --verbose (-v) # Verbose rsync logging (use NU_LOG_LEVEL=debug to set rawrsync logging level) diff --git a/scripts/relink.nu b/scripts/relink.nu index 1c78d5f..d06d89b 100755 --- a/scripts/relink.nu +++ b/scripts/relink.nu @@ -2,16 +2,16 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std log +use std/log # Update symlink targets from an old target directory to a new one -def main [ @example "If you moved `~/Development/tools` to `~/Applications/Development Tools`, update all symlinks in `~/.local/bin` that point to the old location" { relink ~/.local/bin ~/Development/tools `~/Applications/Development Tools` } @example "Update symlinks in `~/.local/bin` from target `~/Development/tools` to `~/Applications/Development Tools`" { relink ~/.local/bin ~/Development/tools `~/Applications/Development Tools` } +export def main [ directory: path old_target_dir: path new_target_dir: path diff --git a/scripts/reset-envision-prefix.nu b/scripts/reset-envision-prefix.nu index 915f72d..ed36059 100755 --- a/scripts/reset-envision-prefix.nu +++ b/scripts/reset-envision-prefix.nu @@ -2,36 +2,38 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std log +use std/log -envision -l -| parse '{id}: "{name}"' -| skip 1 -| where {|it| - ( - "~/.local/share/envision/" - | path join $it.id - | path exists - ) or ( - "~/.local/share/envision/prefixes" - | path join $it.id - | path exists - ) -} -| if ($in | is-empty) { - error make { - msg: "No profiles installed" - } -} else { - $in -} -| input list -md name -| each {|e| - log info $"Resetting prefix: ($e.name)" - rm -rf ( - "~/.local/share/envision/" | path join $e.id | path expand - ) ( - "~/.local/share/envision/prefixes" | path join $e.id | path expand - ) # Resets an Envision prefix and the downloaded repos. Useful to work around [#65](https://gitlab.com/gabmus/envision/-/issues/65) +export def main [] { + envision -l + | parse '{id}: "{name}"' + | skip 1 + | where {|it| + ( + "~/.local/share/envision/" + | path join $it.id + | path exists + ) or ( + "~/.local/share/envision/prefixes" + | path join $it.id + | path exists + ) + } + | if ($in | is-empty) { + error make { + msg: "No profiles installed" + } + } else { + $in + } + | input list -md name + | each {|e| + log info $"Resetting prefix: ($e.name)" + rm -rf ( + "~/.local/share/envision/" | path join $e.id | path expand + ) ( + "~/.local/share/envision/prefixes" | path join $e.id | path expand + ) + } } diff --git a/scripts/start-service-if-needed.nu b/scripts/start-service-if-needed.nu index 189db9e..cf0e8bf 100755 --- a/scripts/start-service-if-needed.nu +++ b/scripts/start-service-if-needed.nu @@ -2,10 +2,10 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -def main [service: string] { # Starts a systemd service if it is not already started, otherwise do nothing. # Useful if you only want to ask for the password when the service actually needs # to be started. +export def main [service: string] { if (systemctl is-active --quiet $service | complete).exit_code == 3 { systemctl start $service } diff --git a/scripts/steam-disable-update.nu b/scripts/steam-disable-update.nu index aec9610..8c9bf32 100755 --- a/scripts/steam-disable-update.nu +++ b/scripts/steam-disable-update.nu @@ -2,9 +2,8 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -use std log +use std/log -def main [ # Completely disable steam updates for a game or app. # # Caveats to this approach: @@ -14,6 +13,7 @@ def main [ @example "Disable updates for SteamVR" {steam-disable-update 250820} @example "Disable updates for Beat Saber" {steam-disable-update 620980} @example "Allow SteamVR Updates" {steam-disable-update --revert 250820} +export def main [ appid: int --revert (-r) # Allow updates again ] { diff --git a/scripts/toggle-extension.nu b/scripts/toggle-extension.nu index d5ad784..8ff558e 100755 --- a/scripts/toggle-extension.nu +++ b/scripts/toggle-extension.nu @@ -2,8 +2,8 @@ # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2025 MatrixFurry -def main [extension: string] { # Provides an easy way to toggle a GNOME extension. Useful for setting up keyboard shortcuts. +export def main [extension: string] { gnome-extensions info $extension | lines | parse " State: {state}" diff --git a/scripts/update-gitignore.nu b/scripts/update-gitignore.nu index b2af9c6..0407846 100755 --- a/scripts/update-gitignore.nu +++ b/scripts/update-gitignore.nu @@ -5,8 +5,8 @@ const self = path self | path expand const templates_dir = $self | path join ../../resources/gitignore/ -def main [ # Quickly and easily create or update `gitignore` files from predefined templates. +export def main [ --replace (-r) # Overwrite the exiting gitignore rather than appending to it --global (-g) # Create a global ignore file at `~/.config/git/ignore` ] { diff --git a/scripts/yt-rss.nu b/scripts/yt-rss.nu index 0045910..2ff458f 100755 --- a/scripts/yt-rss.nu +++ b/scripts/yt-rss.nu @@ -4,8 +4,8 @@ use std assert -def main [ # Get an RSS feed for the specified YouTube channel. +export def main [ channel_url: string --copy (-c) ] {