Giter Club home page Giter Club logo

Comments (65)

dylanaraps avatar dylanaraps commented on May 12, 2024

I really don't want to split fetch into any more files unless we have to. Even though the script
has multiple files it still works on its own. If we move the functions away from the script then
nobody will be able to just drop it into their path, they'll have to install it entirely.

The script uses fold comments so it's super easy to navigate inside of an editor that supports
them. You can also just ctrl+f for getfuncname to find the function. For example getbattery.

I've come up with an alternate solution, it's done and it's in a branch called stdout but I want
your opinion before I do anything with it.

I've created a new helper function called stdout which prints the function output to stdout without
any escape codes, newlines etc. This is what the printinfo function will look like:

printinfo () {
    # Print the info in the "Title: output" format.
    stdout "OS: distro"
    stdout "Kernel: kernel"

    # Print the memory without a title.
    stdout "memory"

    #...
}

You then launch the script like this:

fetch --image off

Here's a screenshot of what it looks like when used in a lemonbar script:
bar
NOTE: Click the image for a larger version
NOTE: I've added the ' | ' myself with a few printfs

You can then create a seperate config file and launch fetch with --config barconfig.

I've pushed this to a new branch called stdout so that you can test it out. If you need a simple
lemonbar script to test this out, this will work:

#!/bin/bash
while :; do
    echo "$(fetch --image off)"
    sleep 1s
done |

lemonbar

I know this probably isn't ideal but it's the best workaround I could come up with
without splitting fetch into more files.

What do you think?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

It looks nice. I will test it this afternoon (5 hours since now).

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Awesome!

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I've pushed a better (imo) solution to a new branch called stdout2. This version adds a new flag called --stdout which prints the existing printinfo function in a lemonbar compatible format. This new version is much smaller (excluding flags and comments) and allows you to use the same config without any modification.

This version also adds 3 new launch flags and config options:

  • stdout_title: Toggle the display of title@hostname in the output.
  • stdout_seperator: Takes a string which it adds to the end of each bit of info as a seperator.
    • eg. --stdout_seperator " | "
  • stdout_subtitles: Toggle the display of each info's subtitle in the output.

You can then launch fetch like this to also remove unwanted info from printing in the bar:

fetch --stdout --disable gpu gtktheme windowmanager shell kernel

Please test it out!

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Let's say I have a bar script and I want to display the CPU in the left and the GPU in the right. I need two different config files to do that. Correct me if I'm wrong.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

I think the stdout functions should be there.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

The problem with the stdout function is that it requires users to have two configs if they want to use fetch and stdout.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I have an idea though.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Why not an enable flag?

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

A new flag which only runs the functions that the flag is given, so:

fetch --stdout --function cpu gpu etc

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

That's what I was typing :)

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Why not simplify?

fetch --stdout cpu gpu etc

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Having a general flag allows it to work with fetch as well.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

I don't understand.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024
fetch --enable cpu gpu memory

This will only display cpu, gpu and memory in the regular fetch output.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Ah ok.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

The only issue with --enable is setting the subtitle, in the info functions the user has to specify a title but with this flag it'll complicate things.

I think I'll just add --stdout cpu gpu memory etc and make it print the info without a subtitle.

What do you think?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Leave it as --stdout etc for now.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I can add --stdout etc but you won't be able to have subtitles infront of the info.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

That was the whole purpose... just the info.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Alright, I've pushed an update to the stdout2 and --stdout cpu etc now work.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

It works beautifully, can you put it in master?

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I just need to write some docs about it and update the readme.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

BTW showing battery info doesn't work.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Also setting --stdout_seperator doesn't work when --stdout has args, so I'm going to fix this too before I push to master.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Battery is the only function that makes use of prin, I'll have a look.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

It's because prin prints a newline, I'll fix this.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I just pushed a fix for the battery info, try it out!

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

It prints all the other info and then the battery. Not good.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Oh, what do you mean?

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I've figured it out.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I just pushed another fix, try it out.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Running fetch --stdout battery yields

off60\033[0m8: 799%    OS: Arch Linux x86_64    Kernel: 4.3.5-1-ck    Uptime: up 1 hour, 53 minutes    Packages: 839    Shell: /bin/mksh    Window Manager: Bspwm    GTK Theme: Arc-Darker [GTK2/3]    Icons: UltraFlatIcons [GTK2/3]    CPU: Intel Core i5-3210M @ 3.1GHz    GPU: Nvidia NVS 5400M    Memory: 726MB / 7737MB    Birthday: Fri 27 Nov 2015 12:39 AM    Battery*: 99%    

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

What's the first battery in your system called?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

0

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

How many batteries do you have in your system?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

1

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I just pushed another fix, try it out.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024
off6�[0m8: 799%    

799?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Btw don't forget to test in normal mode, there are bugs in here.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Progress!

There are some escape codes which need to be removed.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

What does normal mode look like?

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I can't test the battery stuff myself.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

pic

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Pic is not found.

Also I just pushed another commit to stdout2, try it out.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Not found? Refresh.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Image is still not found for me

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Now it works perfectly, but in normal it no longer shows Battery0: 99%. It shows Battery: 99%, without the 0.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

The reason the battery output wasn't working properly in stdout mode is because $battery wasn't being set and we were directly printing the info instead. The fix is to use the subtitle from printinfo if there's only a single battery detected.

So in short, the battery info will now print the subtitle without a number if there's only a single battery detected.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Ah ok. We should keep the issue open until you replace --stdout with --enable.

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Thanks!

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I want to add --enable but the user won't be able to set the subtitle unless the flags look like this:

fetch --enable "CPU: cpu" "Memory: memory"

How does that look?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

As a temp fix, it looks good.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I don't think we can get any cleaner than that tbh,

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Then push it.

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

I don't think I can add --enable without some work, I'm going to just leave it at --stdout cpu etc for now. I'll push to master once I've done some cleanup and written some docs about it.

It's 2 am here so I'm going to bed and I'll finish this up tomorrow.

Thanks for the help!

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Thank you too and good night!

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Merged, thanks again!

Note: --stdout_seperator now works with --stdout cpu gpu etc

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

See #50

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Thanks

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

You're lucky because in my native language the word for "separator" is
exactly "separator" and I thought something was not right. You're welcome!
On Feb 7, 2016 1:07 AM, "Dylan Araps" [email protected] wrote:

Thanks


Reply to this email directly or view it on GitHub
#48 (comment).

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

What's your native language?

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

Romanian. A very hard language.
On Feb 7, 2016 1:15 AM, "Dylan Araps" [email protected] wrote:

What's your native language?


Reply to this email directly or view it on GitHub
#48 (comment).

from neofetch.

dylanaraps avatar dylanaraps commented on May 12, 2024

Mine's English but I also speak Greek. :)

from neofetch.

tudurom avatar tudurom commented on May 12, 2024

That was.... unexpected. Let's end this discussion because it floods the
watchers' mailboxes.
On Feb 7, 2016 1:18 AM, "Dylan Araps" [email protected] wrote:

Mine's English but I also speak Greek. :)


Reply to this email directly or view it on GitHub
#48 (comment).

from neofetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.