fufexan / dotfiles

NixOS system config & Home-Manager user config
MIT License
730 stars 43 forks source link

Some questions about eww under Hyprland #7

Closed ZephyrHeather closed 1 year ago

ZephyrHeather commented 1 year ago

It's really an awesome desktop setup. But i have encountered some trouble to config it on my Arch Linux. Here are my problems.

  1. Couldn't run eww successfully on first time. I write "eww open bar" in my Hyprland config, which seems just bring a flicker of the bar why i start Hyprland. And i comment it to run manually with the command eww open bar. Still, eww bar won't appear until i run it twice or even third times. Here are my logs. (Tips: just run curl ix.io/xxxx to get the logs in the terminal.)
    • The first time to run: ix.io/4tTI, and the second: ix.io/4tTJ
    • The third time to run (when the bar finally come out): ix.io/4tTK
    • Run with RUST_BACKRACE=1 first time: ix.io/4tTM (I'm using Pulseaudio instead of Pipewire, but i'm still trying to replace the wpctl with pactl in the scripts/volume. But i think that's not the problem why eww didn't show, or is it?)
  2. Icons broken. i know it's because that i didn't install the proper font material-symbols-outline. But, i actually install ttf-material-design-iconic-font and ttf-material-design-icons from archlinux aur and try to change the family name of the icon, no success. i find out that the material-icon and material-symbols are two things. It seems that icon are iconic font like awesome font, but symbols are like svg or png? See here So, how can i install the proper fonts? (i try download the symbols.ttf from github and manually install, no success)
  3. cache problem(solved) There are some scripts using cache file like scripts/utils or scripts/music. But my XDG_CACHE_HOME are empty. scripts/utils sets the XDG_CACHE_HOME to /home/mihai/.local/cache, and the scripts/music doesn't set the value. After i set env to XDG_CACHE_HOME = $HOME/.local/cache, all programs using caches broken. It seems that $HOME/.cache is the default cache file on Arch, though not related to XDG_CACHE_HOME.

I'm sry that i am poor in coding. Just like what's said by the elkowar/eww:

Smash your head against the keyboard from frustration (coding is hard)

Any help would be appreciated. Thanks in advance!

fufexan commented 1 year ago
  1. I write "eww open bar" in my Hyprland config, which seems just bring a flicker of the bar why i start Hyprland. And i comment it to run manually with the command eww open bar. Still, eww bar won't appear until i run it twice or even third times.

Yeah it happens to me too since a few days ago, I'm really unsure if one of my script rewrites broke it or if it's an eww update that broke it. Probably the former though. It seems that if I have firefox open and then start eww, it works. No idea why.

  1. So, how can i install the proper fonts? (i try download the symbols.ttf from github and manually install, no success)

You have to download this and put it in ~/.local/share/fonts. After that, run fc-cache -f and then check whether it was picked up with fc-list "Material Symbols Outlined". If it worked, restart eww and icons should be fixed. If all else fails, you could manually replace icons with another font's icons. They won't match since there's no standard dictating what codepoint each icon uses. gucharmap is really handy for searching the icons.

Hope these help.

ZephyrHeather commented 1 year ago

Thank you for the instant help. I've installed font properly.

Yeah it happens to me too since a few days ago, I'm really unsure if one of my script rewrites broke it or if it's an eww update that broke it. Probably the former though. It seems that if I have firefox open and then start eww, it works. No idea why.

I tried several programs, some of which lead to successful start of eww. And some actually caused weird behavior.

  1. yay When I was using yay(a package manager of Archlinux), say, when it was download some packages, I can start eww. But as i interrupt yay downloading with Ctrl+C, eww bar disappeared after few seconds. And i also tried close the terminal which has run eww open bar, the eww bar didn't disappear.
  2. ranger The same happened when i run ranger(file manager), but more surprisingly, when i close the termianl which has finished running eww open bar, the eww bar also disappeared.
  3. vim If I run vim, eww open bar acted well, and the bar didn't disappear after i closed vim.

I chose these programs, because I'm suspecting the cache. The programs with outcome like firefox all write to $HOME/.cache. And before i figured out the cache file path problem, eww can just start normally.

Thus, I write a C program to write a file in $HOME/.cache:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    FILE *fp;
    char ch;
    fp = fopen("1.txt", "r+");
    while ((ch = getchar()) != EOF)
        putc(ch, fp);
    if(fclose(fp))
        printf("Error in closing file \n");
    return 0;
}

And this c script acted just like what yay caused! And if I run this c script elsewhere but $HOME/.cache, eww bar won't show.

Hope this could help you debug it.

fufexan commented 1 year ago

Thank you for the extensive info!

I'm suspecting one of my recent changes to eww scripts that cause I'll try to debug it soon.

Otherwise, it might be some recent change to xdg dirs or eww, I'm not sure.

ZephyrHeather commented 1 year ago

I've two more problems with the window system-menu:

  1. The Airplane icon missing. Don't know if it's related with this code in scripts/airplane
    icon() {
    [ "$STATUS" = "no" ] && echo "" || echo ""
    }

    The character here is just what shows on the system-menu. And if i click on the Airplane place. It just turn off the airplane mode but never turn on. logs related:

ERROR eww::error_handling_ctx > Error while updating UI after state change
Caused by:
    invalid float literal
  1. The volume won't change.(solved) I find the error it's that

    Error: '@DEFAULT_AUDIO_SINK 20@' is not a valid number

    And I change the scripts/volume line 62 setvol "$2 $3" to setvol "$2" "$3". I'm happy that I could really make some small help. :)

sandangel commented 1 year ago

Hi, may I ask some questions too? I got this error:

home-manager switch --impure --flake ".#sand"
warning: Git tree '/nix-config' is dirty
error: getting status of '/nix/store/6h1yfnpx87917z45djqfh7jm0hjrcw0q-source/home/profiles/programs/eww': No such file or directory
(use '--show-trace' to show detailed location information)

I already added your flake as in the readme, but it doesn't work.

# home.nix

{ pkgs, default, fufexan, ... }:
{
  # enable hyprland
  wayland.windowManager.hyprland = {
    enable = true;
    xwayland = {
      enable = true;
      hidpi = true;
    };
    nvidiaPatches = false;
  };

  home.packages = with pkgs; [
    jaq
    xorg.xprop
  ];

  imports = [
    fufexan.homeManagerModules.eww-hyprland
    ./wofi
    ./hyprpaper
    ./dunst
  ];

  programs.eww-hyprland = {
    enable = true;
  };

  services.kanshi = {
    enable = true;
    systemdTarget = "graphical-session.target";
  };

  # fake a tray to let apps start
  # https://github.com/nix-community/home-manager/issues/2064
  systemd.user.targets.tray = {
    Unit = {
      Description = "Home Manager System Tray";
      Requires = [ "graphical-session-pre.target" ];
    };
  };
}

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

    devenv.url = "github:cachix/devenv";

    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    neovim.url = "github:nix-community/neovim-nightly-overlay";

    hyprland.url = "github:hyprwm/Hyprland";

    hyprpaper.url = "github:hyprwm/hyprpaper";

    fufexan.url = "github:fufexan/dotfiles";
  };
  outputs = inputs@{ flake-parts, nixpkgs, home-manager, hyprland, hyprpaper, neovim, fufexan, devenv, ... }:
    let
      username = "sand";
    in
    flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: {
      systems = [ "aarch64-linux" ];
      debug = true;

      imports = [
        inputs.flake-parts.flakeModules.easyOverlay
        inputs.devenv.flakeModule
      ];

      perSystem = { config, self', inputs', pkgs, system, lib, devenv, ... }: {
        devenv.shells.default = {
          languages.nix.enable = true;
        };
        packages = with pkgs; {
          neovim-nightly = neovim.packages.${system}.neovim;
          hyprpaper = hyprpaper.packages.${system}.hyprpaper;
          vcluster = callPackage ./pkgs/vcluster { };
          kubeswitch = callPackage ./pkgs/kubeswitch { };
          yamlfmt = callPackage ./pkgs/yamlfmt { };
          comic-code = callPackage ./pkgs/comic-code { };
          flypie = callPackage ./pkgs/flypie { };
        };
        overlayAttrs = {
          inherit (config.packages) neovim-nightly vcluster kubeswitch yamlfmt comic-code flypie;
        };
      };

      flake.homeConfigurations.${username} = withSystem "aarch64-linux" ({ final, ... }:
        home-manager.lib.homeManagerConfiguration {
          pkgs = final;
          extraSpecialArgs =
            let
              inherit (inputs.nixpkgs) lib;
              colorlib = import ./lib/colors.nix lib;
              default = import ./lib/theme { inherit colorlib lib; };
            in
            { inherit username fufexan default; };
          modules = [
            hyprland.homeManagerModules.default
            ./users/${username}/home.nix
          ];
        });
    });
}
fufexan commented 1 year ago

@sandangel sorry for the late response, I hope it works after https://github.com/fufexan/dotfiles/issues/8.

sandangel commented 1 year ago

it's working now. thank you very much.

fufexan commented 1 year ago

@ZephyrHeather turns out the STATUS variable wasn't being set before the toggle action. Should be fixed in https://github.com/fufexan/dotfiles/commit/1f4e77d5c8f2b20c12dc36ce770b42ed069b6666.

ZephyrHeather commented 1 year ago

turns out the STATUS variable wasn't being set before the toggle action. Should be fixed in 1f4e77d.

Thank you for fixing the toggle problem! Still i have some new problems to show.

  1. The battery time left (solved) I notice that the battery time left on the window system-menu is either 00:00h left or 08:00h left. And i changed the scripts/battery line 39 -- line 46 as:
    if [ "$RATE" -gt 0 ]; then
    if [ "$STATE" = "Discharging" ]; then
      EX=$(($NOW / $RATE))
    else
      EX=$((($FULL - $NOW) / $RATE))
    fi
    date -u -d@"$(awk -v ex="$EX" 'BEGIN{print ex * 3600}')" +%H:%M
    fi

    I think the $EX here should be digits rather than strings. But then, this script just show hours without minutes. So I put multiply the factor 3600 before as:

    if [ "$RATE" -gt 0 ]; then
    if [ "$STATE" = "Discharging" ]; then
      EX=$(($NOW * 3600 / $RATE))
    else
      EX=$((($FULL - $NOW) * 3600 / $RATE))
    fi
    date -u -d@"$EX" +%H:%M
    fi

    Hope this won't overflow the range of the integer.

  2. the logout button of window system-menu After i trigger the wlogout, i just can't close the window of system-menu. It seems that no matter where i click on the eww, it just call out wlogout again. Don't know if it's an issue of eww. Also, can I close the window of eww without click on the origin place I call it out? Say, can I click elsewhere on the desktop to close the extra window of eww? Maybe it will be convenient.
  3. Still missing the airplane icon Thank you for fixing the toggle problem. Sorry that i still miss the icon of airplane, it doesn't call the icon like others, right? The echo command just print two characters, but what are they?

Hope you cloud fix the eww open problem soon, which is surely the most tricky and bothering problem. Thanks again.

fufexan commented 1 year ago

I think the $EX here should be digits rather than strings. But then, this script just show hours without minutes. So I put multiply the factor 3600 before as:

That looks old. I've changed the script to use upower for battery querying instead. It should be more consistent now, though sometimes slow to update.

  1. the logout button of window system-menu

Weird, this does not happen to me. I'm not sure how to debug it. Do the logs say anything useful?

Also, can I close the window of eww without click on the origin place I call it out? Say, can I click elsewhere on the desktop to close the extra window of eww? Maybe it will be convenient.

I'm not sure, maybe if you make the widget occupy the entire screen (and remove the blurls rule, since it'll just blur everything). I may look into that sometime, but it's not a priority right now.

  1. Still missing the airplane icon

Weird. It should be provided by the font. However, try to change those icons to these, as I might have overlooked them. The reason I don't use a json here is that it's the only output of the script, so it can be handled as a simple string.

ZephyrHeather commented 1 year ago

I think that all the problems are solved prettily. eww could run perfectly with hyprland on start now. Thanks again @fufexan ! I'd like to close this issue now.