fastfetch icon indicating copy to clipboard operation
fastfetch copied to clipboard

[RFC] Request for testing of JSON config

Open CarterLi opened this issue 3 years ago • 17 comments

There are no documentations yet ( JSON schema is planned ). Keys can mostly map to the traditional command flags. Here is an example ( when config.jsonc is found, config.conf will be ignored )

My config file

// ~/.config/fastfetch/config.json
{
  "logo": { // https://github.com/fastfetch-cli/fastfetch/blob/71beb626c30c5755613d743d9349f7a95effbe6c/src/fastfetch.c#L900
    "type": "iterm",
    "source": "/home/carter/linux.png", // https://en.wikipedia.org/wiki/Linux#/media/File:Tux.svg
    "width": 30,
    "height": 14,
    "padding": {
      "top": 2,
      "left": 1,
      "right": 2
    }
  },
  "general": { // https://github.com/fastfetch-cli/fastfetch/blob/71beb626c30c5755613d743d9349f7a95effbe6c/src/fastfetch.c#L872
    "allowSlowOperations": true,
    "stat": true
  },
  "display": { // https://github.com/fastfetch-cli/fastfetch/blob/71beb626c30c5755613d743d9349f7a95effbe6c/src/fastfetch.c#L906
    "color": {
      "keys": "yellow"
    },
    "percentType": 9,
    "hideCursor": false
  },
  "modules": [
    "title",
    "separator",
    "os",
    "host",
    "kernel",
    "uptime",
    "processes",
    "packages",
    "shell",
    {
      "type": "display",
      "detectName": true
    },
    "brightness",
    "de",
    "wm",
    "wmtheme",
    "theme",
    "icons",
    "cursor",
    "terminal",
    "terminalfont",
    {
      "type": "cpu",
      "temp": true
    },
    {
      "type": "gpu",
      "forceVulkan": true
    },
    "memory",
    "swap",
    "disk",
    "media",
    "battery",
    {
      "type": "localip",
      "showIpv6": true
    },
    "cpuusage",
    "wifi",
    "locale",
    "vulkan",
    "opengl",
    "bluetooth",
    "sound",
    "datetime",
    "break",
    "colors"
  ]
}

The result

image

CarterLi avatar Jun 11 '23 13:06 CarterLi

Thanks. I'll definitely give this a go when I get home.

Edit: What you have works fine on my end. Will certain things still work again in the future? I have noticed none of the old themes I made work anymore. They fail for several reasons. Mostly anything I ever used starting with --set-keyless no longer works. I get the gist of what you're doing here. Would really like a guide on how to do other keys like host key, cpu key, etc.

tdtooke avatar Jun 12 '23 16:06 tdtooke

Mostly anything I ever used starting with --set-keyless no longer works.

Breaking change is the main reason we bump the major version of fastfetch. --set-key and --set-keyless were implemented as a hack, and will be replaced by the new Custom module.

Would really like a guide on how to do other keys like host key, cpu key, etc.

Definitely yes. I just need more time. However, --host-key and --cpu-key should work like what they did.

CarterLi avatar Jun 14 '23 09:06 CarterLi

I'm wanting to go full json so my question is for those keys would I want that to be within "display"? Adding just under "color" something like "host-key" : "myhostkey"?

Edit: I'm still at work so I won't be able to experiment 'til maybe tomorrow, just so you know. Ok, home now and making progress jsonifying my theme. I see where you set the color for all keys under display, was wondering if I can set custom colors for individual keys. I do love the logo you use but I kinda want to go back to my 2 colored ascii logo. I played around in the logo settings but couldn't figure out what the equivalent of --logo-color-1 and --logo-color-2 is. Also now some of my keys have an unwanted added colon. That's really not a big deal but it makes the appearance inconsistent. I"ll include my json and a screenshot.

// ~/.config/fastfetch/config.json
{
  "logo": { // https://github.com/fastfetch-cli/fastfetch/blob/71beb626c30c5755613d743d9349f7a95effbe6c/src/fastfetch.c#L900
    "type": "iterm",
    "source": "/home/travis/mysources/Tux.png", // https://en.wikipedia.org/wiki/Linux#/media/File:Tux.svg
    "width": 30,
    "height": 14,
    "padding": {
      "top": 2,
      "left": 1,
      "right": 2
    }
  },
  "general": { // https://github.com/fastfetch-cli/fastfetch/blob/71beb626c30c5755613d743d9349f7a95effbe6c/src/fastfetch.c#L872
    "allowSlowOperations": true
  },
  "display": { // https://github.com/fastfetch-cli/fastfetch/blob/71beb626c30c5755613d743d9349f7a95effbe6c/src/fastfetch.c#L906
    "color": {
      "keys": "yellow"
    },
    "percentType": 9,
    "hideCursor": false,
    "separator": "  "
  },
  "modules": [
    "title",
    "separator",
    {
    "type": "host",
    "key": " PC"
    },
    {
    "type": "board",
    "key": "  ├"
    },
    {
    "type": "CPU",
    "key": "  ├"
    },
    {
    "type": "gpu",
    "forceVulkan": true,
    "key": "  ├﬙"
    },
    {
    "type": "display",
    "key": "  ├"
    },
    {
    "type": "memory",
    "key": "  ╰"
    },
    "break",
    {
    "type": "os",
    "key": " OS"
    },
    {
    "type": "kernel",
    "key": "  ├"
    },
    {
    "type": "shell",
    "key": "  ├"
    },
    {
    "type": "terminal",
    "key": "  ├"
    },
    {
    "type": "TerminalFont",
    "key": "  ├"
    },
    {
    "type": "Locale",
    "key": "  ├"
    },
    {
    "type": "Packages",
    "key": "  ╰"
    },
    "break",
    {
    "type": "DE",
    "key": " DE"
    },
    {
    "type": "WM",
    "key": "  ├"
    },
    {
    "type": "WMTheme",
    "key": "  ├"
    },
    {
    "type": "Theme",
    "key": "  ├"
    },
    {
    "type": "Icons",
    "key": "  ├"
    },
    {
    "type": "Font",
    "key": "  ├"
    },
    {
    "type": "Cursor",
    "key": "  ╰󰇀"
    },
    "break",
    "colors"
  ]
}

https://i.postimg.cc/N0Cxt5Rx/fetch.png

tdtooke avatar Jun 16 '23 18:06 tdtooke

I see where you set the color for all keys under display, was wondering if I can set custom colors for individual keys.

You can do it with

{
    "type": "host",
    "key": "\\e[34mhost" // note double `\`s are required
}

for now, but we may support it some day. Let me focus porting existing features.

but couldn't figure out what the equivalent of --logo-color-1 and --logo-color-2 is.

{
    "logo": {
        "color": {
            "1": "white",
            "2": "cyan",
            // and whatever
        }
    }
}

You may add

"$schema": "https://raw.githubusercontent.com/fastfetch-cli/fastfetch/dev/src/data/json_schema.jsonc"

at the beginning of the JSON config file and use vscode to get some suggestions when typing

image

Also now some of my keys have an unwanted added colon.

Fixed in 184a6de1e9845e9310fd1ee3101cd668b06457d6

CarterLi avatar Jun 17 '23 13:06 CarterLi

Mostly anything I ever used starting with --set-keyless no longer works.

{
    "type": "custom",
    "format": "whatever you want"
}

CarterLi avatar Jun 17 '23 13:06 CarterLi

Thanks you!!! I actually did try that way to color a key just without the extra '\" I tried a variation of what you did for logo colors. I really should have known but for some reason my brain was telling me there wouldn't be something named simply "1". I'm beginning to suspect the colon I see after the key is hard coded in so I won't ask for that.

Edit: You fixed the colon thing, thanks!!! Now we have achieved perfection on my theme!

tdtooke avatar Jun 17 '23 14:06 tdtooke

Just in case it would help anybody else wanting to go in the direction I tend to go theming wise I'll post my json. Thanks to CarterLi for fixing my other post. I guess the old bbcode tags I'm used to using don't always work.

{
  "$schema": "https://raw.githubusercontent.com/fastfetch-cli/fastfetch/dev/src/data/json_schema.jsonc",
  "logo": {
    "padding": {
      "top": 3,
      "left": 1
    },
    "color": {
      "1": "36",
      "2": "32"
    }
  },
  "general": {
    "allowSlowOperations": true
  },
  "display": {
    "color": {
      "title": "33"
    },
    "percentType": 9,
    "hideCursor": false,
    "separator": "   "
  },
  "modules": [
    "title",
    "separator",
    {
    "type": "host",
    "key": "\\e[36m PC"
    },
    {
    "type": "board",
    "key": "\\e[36m  ├"
    },
    {
    "type": "CPU",
    "key": "\\e[36m  ├"
    },
    {
    "type": "gpu",
    "key": "\\e[36m  ├﬙"
    },
    {
    "type": "display",
    "key": "\\e[36m  ├"
    },
    {
    "type": "memory",
    "key": "\\e[36m  ╰"
    },
    "break",
    {
    "type": "os",
    "key": "\\e[32m OS"
    },
    {
    "type": "kernel",
    "key": "\\e[32m  ├"
    },
    {
    "type": "shell",
    "key": "\\e[32m  ├"
    },
    {
    "type": "terminal",
    "key": "\\e[32m  ├"
    },
    {
    "type": "TerminalFont",
    "key": "\\e[32m  ├"
    },
    {
    "type": "Locale",
    "key": "\\e[32m  ├"
    },
    {
    "type": "Packages",
    "key": "\\e[32m  ╰"
    },
    "break",
    {
    "type": "DE",
    "key": "\\e[33m DE"
    },
    {
    "type": "WM",
    "key": "\\e[33m  ├"
    },
    {
    "type": "WMTheme",
    "key": "\\e[33m  ├"
    },
    {
    "type": "Theme",
    "key": "\\e[33m  ├"
    },
    {
    "type": "Icons",
    "key": "\\e[33m  ├"
    },
    {
    "type": "Font",
    "key": "\\e[33m  ├"
    },
    {
    "type": "Cursor",
    "key": "\\e[33m  ╰󰇀"
    },
    "break",
    {
    "type": "custom",
    "format": "   \\e[38m \\e[37m \\e[36m \\e[35m \\e[34m \\e[33m \\e[32m \\e[31m"
    }
  ]
}

And if you want to know what that will produce on konsole with the Mega-Konsole theme then:

https://i.postimg.cc/VkhB8zxb/fetch.png

tdtooke avatar Jun 17 '23 17:06 tdtooke

Added keyColor and --<module>-key-color

Usage:

{
    "type": "Cursor",
    "keyColor": "cyan"
}

CarterLi avatar Jun 18 '23 05:06 CarterLi

I would suggest you move your config into presets. A lot of people will like that one. I just might convert a lot of the old examples into the new format and make a pull request. Also will there be a way to have a config file where you can choose your json theme?

tdtooke avatar Jun 20 '23 01:06 tdtooke

What is a json theme?

CarterLi avatar Jun 20 '23 02:06 CarterLi

The contents of config.jsonc are what I would call a theme. As is if I want to change appearance I need to rename a config I created as config.jsonc. I was thinking of themes being stored in the presets directory and in a config file you might have something like "theme" : "mytheme"

tdtooke avatar Jun 20 '23 02:06 tdtooke

You mean something like --load-config?

It's easy to support it for commandline / flag based config file. For a config file newly loaded, it just override everything set before.

However JSON config is structure based, there are trees, arrays, etc. It's not easy to do so.

It's considerable though. A lot of JSON based configuration files support { "extends": "some other files" }

CarterLi avatar Jun 20 '23 02:06 CarterLi

I mean trees are mergeable, but arrays (eg modules) are not.

CarterLi avatar Jun 20 '23 03:06 CarterLi

I see. I hadn't really considered the difficulty of that idea. Maybe a default config.jsonc that is installed. Yours would be a good choice. Then the preset directory converted to themename.jsonc files and an install script in there that you could run with ./install.sh --themename which would then copy that theme to where config.jsonc is and rename it to that. I believe neofetch does something like that with it's themes.

Edit: Sorry to be such a bother but I've ran into another issue. On another config I have a png as type kitty but when I run fastfetch it starts on the same line the command was run from. Before I posted about this and was told I needed the height parameter because it arose from the app not properly knowing the height of my image. I do have that but with jsonc the problem is back. It was fixed before. I'll post my config.jsonc and a screenshot.

{
  "$schema": "https://raw.githubusercontent.com/fastfetch-cli/fastfetch/dev/src/data/json_schema.jsonc",
  "logo": {
    "type": "kitty",
    "source": "/home/travis/mysources/fastarch.png",
    "height": 17,
    "padding": {
      "top": 3,
      "left": 1,
      "right": 3
    }
  },
  "general": {
    "allowSlowOperations": true
  },
  "display": {
    "color": {
      "keys": "yellow"
    },
    "percentType": 9,
    "hideCursor": false,
    "separator": "  "
  },
  "modules": [
    {
      "type": "custom",
      "format": "┌────────────────── \\e[1mHardware Information\\e[0m ─────────────────┐"
    },
    {
      "type": "Host",
      "key": "  "
    },
    {
      "type": "CPU",
      "key": "  "
    },
    {
      "type": "GPU",
      "key": "  ﬙"
    },
    {
      "type": "Display",
      "key": "  "
    },
    {
      "type": "Memory",
      "key": "  "
    },
    {
      "type": "Disk",
      "key": "  "
    },
    {
      "type": "custom",
      "format": "├────────────────── \\e[1mDesktop Environment\\e[0m ──────────────────┤"
    },
    {
      "type": "DE",
      "key": "  "
    },
    {
      "type": "WM",
      "key": "  "
    },
    {
      "type": "WMTheme",
      "key": "  "
    },
    {
      "type": "Theme",
      "key": "  "
    },
    {
      "type": "Icons",
      "key": "  "
    },
    {
      "type": "Font",
      "key": "  "
    },
    {
      "type": "Cursor",
      "key": "  󰇀"
    },
    {
      "type": "custom",
      "format": "├────────────────── \\e[1mSystem Information\\e[0m ───────────────────┤"
    },
    {
      "type": "OS",
      "key": "  "
    },
    {
      "type": "Kernel",
      "key": "  "
    },
    {
      "type": "Shell",
      "key": "  "
    },
    {
      "type": "Terminal",
      "key": "  "
    },
    {
      "type": "TerminalFont",
      "key": "  "
    },
    {
      "type": "Locale",
      "key": "  "
    },
    {
      "type": "Packages",
      "key": "  "
    },
    {
      "type": "custom",
      "format": "└─────────────────────────────────────────────────────────┘",
    },
    "Break",
    {
      "type": "custom",
      "format": "  \\e[38m \\e[37m \\e[36m \\e[35m \\e[34m \\e[33m \\e[32 \\e[31m"
    }
  ]
}

https://i.postimg.cc/zB0z6g92/fetch.png

More Edit: Strange, I substituted the image you used in your example and this doesn't happen. For mine (my version of your tux icon)I just downloaded the link you had for that image and exported it as a pgn in gimp. I've looked at my icon (my arch icon which is 320x320) and yours and the only difference I see is the one I used for your icon is considerably larger. The application of the alpha layers are identical so the size you see visibly really is the true size. I'll experiment further but I suspect this only happens with smaller images.

Nevermind, it still does it. Looks like only kitty does this, if you use iterm the problem dissapears and things work as they should.

tdtooke avatar Jun 20 '23 05:06 tdtooke

Wgen i run fastfetch --load-config theme.jsonc i get error. Sorry but i'm new to this

image

gabrielomana avatar Jul 12 '23 13:07 gabrielomana

Wgen i run fastfetch --load-config theme.jsonc i get error. Sorry but i'm new to this

image

Did you use the latest dev build? fastfetch --version?

CarterLi avatar Jul 12 '23 14:07 CarterLi

Closing in favor of https://github.com/fastfetch-cli/fastfetch/wiki/Configuration

CarterLi avatar Jul 21 '23 02:07 CarterLi