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

display-manager: allow executable background #49492

Closed
wants to merge 1 commit into from

Conversation

mkaito
Copy link
Contributor

@mkaito mkaito commented Oct 30, 2018

Motivation for this change

I use Nitrogen to set my wallpaper.

Things done

If ~/.background-image is executable, run it to set background image. In my case, a bash script that runs nitrogen --restore.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

If ~/.background-image is executable, run it to set background image.

Useful when using something like Nitrogen
@mkaito mkaito changed the title display-manager: allow executable display-manager: allow executable background Oct 30, 2018
@@ -73,7 +73,9 @@ in
manage = "desktop";
start = d.start
+ optionalString (needBGCond d) ''
if [ -e $HOME/.background-image ]; then
if [ -x $HOME/.background-image ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will execute JPGs copied from a FAT filesystems, which often have the executable bit set in VFS due to permissive mount options. You could check for a #! or ELF magic bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would much rather remove the entire section and let people set their own colours and wallpapers than try to work around every possible edge case here.

@infinisil
Copy link
Member

Tbh, the default display manager script definitely doesn't look like the right place to me to put wallpaper logic, use your window manager or something instead. And I'd also rather use a different file for this (e.g. .background-image-exe).

@mkaito
Copy link
Contributor Author

mkaito commented Nov 10, 2018

This was extremely confusing when I started using NixOS. I tried running nitrogen --restore in services.xserver.windowManager.i3.extraSessionCommands, but as the display-manager script has the wallpaper logic appended to it, it overrides whatever I tried to do.

This entire section seems very wrong to me, but this PR proposes one possible workaround. I'd much rather remove all wallpaper logic from here, honestly. But this won't break people's configs.

@mmahut
Copy link
Member

mmahut commented Aug 10, 2019

Are there any updates on this pull request, please?

@mkaito
Copy link
Contributor Author

mkaito commented Aug 10, 2019

Doesn't seem like there's an agreement of how this should actually be handled.

@infinisil
Copy link
Member

Looking at this again, I think the best course of action is to implement a way to turn off this automatic background setting. I'm currently looking into how to implement this

@infinisil
Copy link
Member

I just created #78346 which adds an option to prevent NixOS from messing with the background. Let me know if this works for you.

@infinisil
Copy link
Member

Closing this because since #78346 that usecase is now supported with e.g. services.xserver.windowManager.i3.extraSessionCommands

@infinisil infinisil closed this Jan 28, 2020
ivanbrennan added a commit to ivanbrennan/nixbox that referenced this pull request Feb 21, 2020
Getting the background color/image correctly configured has been a bit
tricky due to the interactions of the display manager, compton, and
NixOS.

NixOS is doing the following. If ~/.background-image exists, it uses feh
to set that as the background, otherwise, it uses xsetroot to set the
root X window's background to black:
  xsetroot -solid black

This happens _after_ displayManager.sessionCommands have been run,
clobbering any color that was previously set. A fix for this has been
merged upstream: NixOS/nixpkgs#78346

Also relevant is a newly introduced option:
  services.xserver.windowManager.i3.extraSessionCommands
NixOS/nixpkgs#49492 (comment)

In the meantime, my workaround has been to create an image with the
color I want and copy it to ~/.background-image.

While trying to figure out how to get conky to work in i3, I learned
that compton doesn't play nice with xsetroot. I haven't dug into too
much detail, but it behaves as if compton introduces another layer of
background that hides the layer xsetroot touches. Instead, using
hsetroot has the desired affect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants