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

Cannot run SketchyBar if configuration is execeutable symbolic link #553

Open
vkravets opened this issue May 27, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@vkravets
Copy link

vkravets commented May 27, 2024

In case of nix all config files are symlink. The SketcyBar check if config file is executable (and it will be false in case of symlink, even if target is executable) and try to set the execute permission and it's fail since it's a nix )))

It seems issue is arising here

bool is_executable = buffer.st_mode & S_IXUSR;

and this code for executable symlink won't return true

I don't have knowladge of c++ to fix this, so please aware of the issue related to symlinked configuration

in my case I've fixed it, by manualy configure launchctl service using following changes at my configuration and don't using the nix-darwin service for the integration

    launchd.user.agents.sketchybar = {
      path = [ pkgs.sketchybar ] ++ [ pkgs.sketchybar-app-font ] ++ [ config.environment.systemPath ];
      serviceConfig.ProgramArguments = [ "${pkgs.sketchybar}/bin/sketchybar" ] ++ ["--config" "${self}/sketchybar/sketchybarrc"];
      serviceConfig.KeepAlive = true;
      serviceConfig.RunAtLoad = true;
    };

Where self it's my flake configuration inherits to system configuration and to home-manager configuration via specialArgs and extraSpecialArgs.

Note: nix-darwin solution works since create the service using real path to configuration, not symlink

@vkravets vkravets changed the title Cannot run SketcyBar if configuration is execeutable symbolic link Cannot run SketchyBar if configuration is execeutable symbolic link May 27, 2024
@FelixKratz FelixKratz added the bug Something isn't working label Jul 23, 2024
@neversad-dev
Copy link

neversad-dev commented Nov 12, 2024

@vkravets I encountered the same issue, and here’s how I resolved it:

I moved my entire Sketchybar configuration (including the sketchybarrc file and all associated shell scripts) under a central config directory. Then, I symlinked the whole directory with the following line in my Home Manager configuration:

home.file.".config/sketchybar".source = ./config;

You can check out my setup here for reference: nix-setup/home/darwin/sketchybar/default.nix

Hope this helps!

@mariovagomarzal
Copy link

mariovagomarzal commented Jan 15, 2025

I have encountered a similar problem trying to configure Sketchybar with Home-Manager. I've tried @neversad-dev approach of symlinking the directory:

{
  pkgs,
  config,
  ...
}: let
  # Sketchybar package to use.
  sketchybar = pkgs.sketchybar;
in {
  home.packages = [sketchybar];

  # Sketchybar configuration directory.
  home.file.".config/sketchybar" = {
    source = ./config;
    recursive = false;
  };

  # Add Sketchybar to the user's launchd agents.
  launchd.agents.sketchybar = {
    enable = true;
    config = {
      Label = "sketchybar";
      ProgramArguments = [
        "${sketchybar}/bin/sketchybar"
      ];
      RunAtLoad = true;
      KeepAlive = true;
    };
  };
}

Then, inside the config folder I have the following (executable) script:

#!/bin/bash

# Bar properties.
bar=(
  height=39
  shadow=on
  margin=30
  color=0xff9b9b9b
)

sketchybar --bar "${bar[@]}"

sketchybar --update
echo "Sketchybar configuration loaded."

However, when rebuild the Home-Manager configuration, Sketchybar shows the default bar:
Screenshot 2025-01-15 at 13 42 02

Any idea on what's going wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants