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

per monitor background image #16

Closed
Hippo0o opened this issue Jun 10, 2022 · 8 comments
Closed

per monitor background image #16

Hippo0o opened this issue Jun 10, 2022 · 8 comments

Comments

@Hippo0o
Copy link

Hippo0o commented Jun 10, 2022

Is there a way to define a background image per monitor?
Like so in css: window#DP-1 {} or window.HDMI-A-1 {}

Or a way for a single background to span across monitors. So you could do smth like this:

grim /tmp/lock.png
corrupter -mag 1 -boffset 3 -meanabber 1 /tmp/lock.png /tmp/lock.png
gtklock -s style.css
@jovanlanik
Copy link
Owner

It wouldn't be too hard to implement per monitor bg, I'll get to it.
A span of a single image would require implementing custom drawing of backgrounds. Maybe taking a screenshot of every monitor separately would work?

@Hippo0o
Copy link
Author

Hippo0o commented Jun 10, 2022

Per monitor background would have more practical use i'd imagine, although more configuration.

I don't mind taking screenshots per monitor :)

@jovanlanik
Copy link
Owner

jovanlanik commented Jun 10, 2022

I added monitor names to windows so you can set backgrounds per monitor now using css. The only issue is that GTK doesn't offer an API to access output names such as DP-1 and HDMI-A-1 (it's deprecated) so I'm using monitor model names instead. You can list out connected monitors by running $ gtklock --list-monitors

@ErikReider
Copy link
Contributor

ErikReider commented Jun 11, 2022

The needed GDK method isn't publicly visible (gdk_monitor_get_connector).

The method for getting the connection name is deprecated (gdk_screen_get_monitor_plug_name) in favor of gdk_monitor_get_model which doesn't even return the connection name, it returns the model. I'd use the deprecated option. It's not like GTK3 is getting updated with breaking features/updates right?

Maybe we should open an issue or even a MR about this?

Edit: Opened an issue

@jovanlanik
Copy link
Owner

Yeah, you're right. I added use of the deprecated function and a pragma to hide the compiler warning.
I do hope the issue gets resolved on GTK's end.

Per monitor background are now possible using a CSS selector such as window#HDMI-A-1.

@Hippo0o
Copy link
Author

Hippo0o commented Jun 14, 2022

Here is an example of how i use it now.
@jovanlanik tyvm for the implementation ❤️

lock.sh

#! /bin/bash
outputs=(HDMI-A-2 DP-1 eDP-1)

for o in ${outputs[@]}; do
    grim -o $o /tmp/$o.png
    corrupter -mag 1 -boffset 3 -meanabber 5 /tmp/$o.png /tmp/$o.png &
done

wait < <(jobs -p)

gtklock -d -s ~/.config/gtklock/style.css

style.css

window {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: black;
}
window#HDMI-A-2 {
    background-image: url("/tmp/HDMI-A-2.png");
}
window#DP-1 {
    background-image: url("/tmp/DP-1.png");
}
window#eDP-1 {
    background-image: url("/tmp/eDP-1.png");
}

@jovanlanik
Copy link
Owner

@Hippo0o Do you mind if I use your example in the wiki?

@Hippo0o
Copy link
Author

Hippo0o commented Jun 14, 2022

@jovanlanik please do ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants