Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite it in Rust #317

Merged
merged 104 commits into from
Oct 23, 2024
Merged

Rewrite it in Rust #317

merged 104 commits into from
Oct 23, 2024

Conversation

teohhanhui
Copy link
Contributor

@teohhanhui teohhanhui commented Jun 26, 2024

Description

Rewrite hyfetch (Python) in Rust.

TODO:

  • --config option to interactively create new config
  • --june option for the Pride month animation
  • --backend other than neofetch
    • fastfetch, fastfetch-old
    • qwqfetch (seems tricky... the integration was via importing the qwqfetch Python library and calling a function) replaced with a new backend - macchina
  • --c-overlay option for experimental color overlay mode (probably remove as it's no longer useful) removed

Relevant Links

#296

Screenshots

TBD

Additional context

TBD

teohhanhui and others added 29 commits June 27, 2024 01:13
Parse CLI options, including presets
Get distro name from neofetch
Generate distros.rs on build
Add some more scaffolding
[rust] implement list_distros match_condition method in rust
Implement neofetch_util functions
Co-authored-by: Chiew Yan Wei <[email protected]>
Co-authored-by: Tan Chee Keong <[email protected]>
Apply lightness to preset color profile
Implement recolored ascii output
@teohhanhui
Copy link
Contributor Author

Finally we have recolored ascii output:

Screenshot from 2024-07-07 04-38-50

The work is not done, but we're getting somewhere lol

Use "alternate screen" for Pride month animation
@teohhanhui
Copy link
Contributor Author

No more screen flickering: rust-malaysia#43

@nexplorer-3e
Copy link
Contributor

Hello it's possible to save backend choice in config? Looks like directly run without specify backend with -b it would always use neowofetch.

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Aug 4, 2024

@nexplorer-3e Backend choice is saved in config. You can even run with e.g. hyfetch --config -b fastfetch the first time to not need neowofetch at all.

(Not the best experience on Termux, for example. If you don't pass -b fastfetch the first time it'll fail without a clear error message. Maybe we can have better logic to fallback to another backend if the default fails?)

@CarterLi
Copy link
Contributor

CarterLi commented Aug 4, 2024

Hyfetch will let user select the preferred backend, won't it?

I think the backend should default to fastfetch on Windows, at least.

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Aug 4, 2024

@CarterLi I'll add some heuristics for selecting the default backend.

UPDATE: Done. We now default to fastfetch except on non-Android *nix. The user should be able to tell they need to install fastfetch from the error message...

UPDATE 2: Changed to just default to fastfetch if it's installed (on any platforms).

@1337isnot1337
Copy link

1337isnot1337 commented Aug 9, 2024

Hello,
What's the project status on this? If there's anything left I can help with let me know. Just seems to be like there hasn't been any activity in a bit.

@teohhanhui
Copy link
Contributor Author

@1337isnot1337 I think we just need to wait for @hykilpikonna to review and merge. Our work is done here, except for further improvements which could definitely be done as separate pull requests...

* Use fastfetch on Android (Termux)
teohhanhui and others added 3 commits August 19, 2024 00:58
@eleanordoesntcode
Copy link

kinda annoying if this becomes the only option, as older OSes sometimes won't have support for that rust version (i.e. my PowerMac G5 with macOS 10.5)

@teohhanhui
Copy link
Contributor Author

@eleanordoesntcode While I'm sympathetic to that struggle, ultimately that's an unsupported platform that has been unmaintained for a long time now...

The closest thing I could find with a quick Google search is this: https://www.wezm.net/v2/posts/2023/rust-on-ppc-classic-mac-os/ (the working approach that they found was to compile from Rust to WebAssembly, and then from WebAssembly to C, lol... and their target was Mac OS 9 🙈)

@teohhanhui
Copy link
Contributor Author

/ping @hykilpikonna Have you had the chance to take a look at this rewrite yet?

@devnoname120
Copy link
Contributor

IMO it's not a great idea because in its current state the tool runs anywhere with just a bash environment. Rewriting it in Rust makes it non-portable and a hassle to get working in some exotic environments.

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Oct 22, 2024

@devnoname120 No, the current version needs Python (and optionally Bash).

@catumin
Copy link
Collaborator

catumin commented Oct 22, 2024

IMO it's not a great idea because in its current state the tool runs anywhere with just a bash environment. Rewriting it in Rust makes it non-portable and a hassle to get working in some exotic environments.

Do note that this rewrite is for specifically HyFetch, neofetch is staying as just the bash script. Currently, HyFetch requires a working python 3.7 or newer to be available which is going to limit which hardware it works on as well, though I think is still more widely available than Rust. But neofetch is staying completely portable.

@hykilpikonna hykilpikonna merged commit b5b49ec into hykilpikonna:master Oct 23, 2024
@hykilpikonna
Copy link
Owner

Just published the last python release 1.99.0 and merged this PR. All future releases from this point will be in rust now. Thanks for all the great work!

@eleanordoesntcode
Copy link

@devnoname120 No, the current version needs Python (and optionally Bash).

@teohhanhui I was mentioning my G5 before, and this G5 can run the latest version of Python. However Rust does not compile for this machine. There is more support for Python on older machines so your argument is invalid
It's useless now since the change has been pushed anyway but yeah.

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Oct 29, 2024

@eleanordoesntcode Sorry for the confusion. I was not trying to make an argument, just making a factual correction.

But anyway, like I've said before, I'm sympathetic to trying to support as much old hardware as feasible. Perhaps we can consider doing the Rust (-> WASM) -> C build, then it should be truly portable.

Another project to maybe keep an eye on: https://www.reddit.com/r/rust/comments/1bhajzp/rust_to_c_compiler/ (and the latest status update I could find: https://www.reddit.com/r/rust/comments/1e5vrrs/media_the_rust_to_net_compiler_backend_can_now/)

Also to note:

Python 3.9 requires macOS 10.6 or newer.

So a bump in Python version requirement could easily have the same effect for your platform :(

@eleanordoesntcode
Copy link

@teohhanhui This G5 runs macOS 10.5. Again, by compiling Python from source it works just fine.

I'll keep an eye on those Rust to C projects.

@nexplorer-3e
Copy link
Contributor

@teohhanhui Hello, are there any working installation methods? crate on https://crates.io/crates/hyfetch is just a stub, and when I trying to install by cargo install --path crates/hyfetch/, it throws failed to get distro ascii error:

Error: failed to get distro ascii

Caused by:
    0: failed to get distro name
    1: failed to get distro name from neofetch
    2: neofetch command not found

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Nov 24, 2024

@nexplorer-3e Sorry, I didn't try with cargo install. But I'll try to take a look today and send a PR if there's something that needs to be fixed.

neofetch command not found

You'd need neofetch or fastfetch in PATH

EDIT: There's nothing to be done here... cargo install is not capable of dealing with auxiliary files.

EDIT 2: Easy installation instructions after git checkout from master:

cargo install --locked --path crates/hyfetch
mkdir -p ~/.local/bin
cp neofetch ~/.local/bin/neowofetch

(Assuming ~/.local/bin is prepended to PATH. It's the default in Fedora at least.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.