XR for Universal Blue and Fedora Atomic Desktops
vr fedora-atomic linux
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve install script

Shiloh Fen 24e15c50 f01a4cd6

+97 -74
+30 -7
install.nu
··· 4 4 5 5 use std log 6 6 7 - let lib_dir = $NU_LIB_DIRS | first | path join atomic-xr 8 - mkdir ($lib_dir | path dirname) 9 - rm -rf $lib_dir 10 - cp -r src/atomic-xr $lib_dir 11 - mkdir ~/.local/bin 12 - cp -f src/axr.nu ~/.local/bin/axr 7 + def main [ 8 + prefix: string = "~/.local" 9 + --install-library (-l) 10 + ] { 11 + let prefix = $prefix | path expand 12 + 13 + log debug $"Install prefix: ($prefix)" 14 + 15 + let lib_dir = $prefix | path join "share" "atomic-xr" "lib" 16 + 17 + let axr = open src/axr.nu.in --raw 18 + | str replace "/@AXR_LIB@/" $"use ($lib_dir)/atomic-xr" 19 + 20 + let bin = $prefix | path join "bin" "axr" 21 + 22 + mkdir $lib_dir 23 + rm -rf ($lib_dir | path join "atomic-xr") # Remove old library if it exists 24 + cp -r src/atomic-xr $lib_dir 25 + 26 + if $install_library { 27 + rm -f ($NU_LIB_DIRS | first | path join "atomic-xr") 28 + ln -s ($lib_dir | path join "atomic-xr") ($NU_LIB_DIRS | first) 29 + } 13 30 14 - log info "AtomicXR CLI has been installed, use `axr -l` for a list of commands." 31 + mkdir ($bin | path dirname) 32 + rm -f $bin 33 + $axr | save $bin 34 + chmod +x $bin 35 + 36 + log info "AtomicXR CLI has been installed, use `axr -l` for a list of commands." 37 + }
-67
src/axr.nu
··· 1 - #!/usr/bin/env nu 2 - # SPDX-License-Identifier: AGPL-3.0-only 3 - # Copyright (c) 2025 Shiloh Fen <shiloh@shilohfen.com> 4 - 5 - use std log 6 - use atomic-xr 7 - 8 - def main [ 9 - # TODO: --choose (-c) # Interactively choose a function 10 - --list (-l) # List avaliable functions 11 - --interactive (-i) # Enter interactive shell with the module loaded 12 - ...function 13 - ] { 14 - let function = $function | str join ' ' 15 - if $interactive { 16 - exec nu -e "use atomic-xr; print $'(ansi yellow)AtomicXR module loaded.(ansi reset)'" 17 - } else if $list or ($function | is-empty) { 18 - print-functions 19 - } else { 20 - # Make sure the function is valid to avoid unhelpful error messages (doesn't check flags) 21 - if ($function | str replace -r " -.*" '') in (get-functions | append (get-aliases)) { 22 - nu -c $"use atomic-xr ; atomic-xr ($function)" 23 - } else { 24 - log error $"Invalid function: `($function)`" 25 - print-functions 26 - } 27 - } 28 - } 29 - 30 - def get-functions [] { 31 - scope modules 32 - | where name == atomic-xr 33 - | get 0.commands.name 34 - } 35 - 36 - def get-aliases [] { 37 - scope modules 38 - | where name == atomic-xr 39 - | get 0.aliases.name 40 - } 41 - 42 - def print-functions [] { 43 - get-functions 44 - | each {|function| 45 - let help = help atomic-xr $function | lines 46 - 47 - let short_description = $help 48 - | first 49 - | if $in == $"(ansi green)Usage(ansi reset):" { 50 - null 51 - } else { 52 - $in 53 - } 54 - 55 - # let usage = $help 56 - # | get ( 57 - # ($help | enumerate | where item == $"(ansi green)Usage(ansi reset):").0.index + 1 58 - # ) 59 - # | str trim 60 - 61 - { 62 - command: $"(ansi cyan)($function)(ansi reset)" 63 - description: $"(ansi lp)($short_description)(ansi reset)" 64 - } 65 - } 66 - | table --index false --theme rounded 67 - }
+67
src/axr.nu.in
··· 1 + #!/usr/bin/env nu 2 + # SPDX-License-Identifier: AGPL-3.0-only 3 + # Copyright (c) 2025 Shiloh Fen <shiloh@shilohfen.com> 4 + 5 + use std log 6 + /@AXR_LIB@/ 7 + 8 + def main [ 9 + # TODO: --choose (-c) # Interactively choose a function 10 + --list (-l) # List avaliable functions 11 + --interactive (-i) # Enter interactive shell with the module loaded 12 + ...function 13 + ] { 14 + let function = $function | str join ' ' 15 + if $interactive { 16 + exec nu -e "use atomic-xr; print $'(ansi yellow)AtomicXR module loaded.(ansi reset)'" 17 + } else if $list or ($function | is-empty) { 18 + print-functions 19 + } else { 20 + # Make sure the function is valid to avoid unhelpful error messages (doesn't check flags) 21 + if ($function | str replace -r " -.*" '') in (get-functions | append (get-aliases)) { 22 + nu -c $"use atomic-xr ; atomic-xr ($function)" 23 + } else { 24 + log error $"Invalid function: `($function)`" 25 + print-functions 26 + } 27 + } 28 + } 29 + 30 + def get-functions [] { 31 + scope modules 32 + | where name == atomic-xr 33 + | get 0.commands.name 34 + } 35 + 36 + def get-aliases [] { 37 + scope modules 38 + | where name == atomic-xr 39 + | get 0.aliases.name 40 + } 41 + 42 + def print-functions [] { 43 + get-functions 44 + | each {|function| 45 + let help = help atomic-xr $function | lines 46 + 47 + let short_description = $help 48 + | first 49 + | if $in == $"(ansi green)Usage(ansi reset):" { 50 + null 51 + } else { 52 + $in 53 + } 54 + 55 + # let usage = $help 56 + # | get ( 57 + # ($help | enumerate | where item == $"(ansi green)Usage(ansi reset):").0.index + 1 58 + # ) 59 + # | str trim 60 + 61 + { 62 + command: $"(ansi cyan)($function)(ansi reset)" 63 + description: $"(ansi lp)($short_description)(ansi reset)" 64 + } 65 + } 66 + | table --index false --theme rounded 67 + }