mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Add wallpapers to output command
This commit is contained in:
parent
79b277fe9b
commit
5728307520
5 changed files with 59 additions and 19 deletions
22
sway.5.txt
22
sway.5.txt
|
@ -115,14 +115,28 @@ Commands
|
||||||
When _output_: place mouse at center of newly focused window when changing
|
When _output_: place mouse at center of newly focused window when changing
|
||||||
output. When _none_: don't move mouse.
|
output. When _none_: don't move mouse.
|
||||||
|
|
||||||
**output** <name> <resolution|res WIDTHxHEIGHT> <position|pos X,Y>::
|
**output** <name> <resolution|res> <WIDTHxHEIGHT>::
|
||||||
Configures the specified output. It will use the given resolution and be
|
Configures the specified output to use the given resolution.
|
||||||
arranged at the given position in the layout tree. You may omit either of
|
|
||||||
these parameters if you only want to set one of them.
|
**output** <name> <position|pos> <X,Y>::
|
||||||
|
Configures the specified output to be arranged at the given position.
|
||||||
|
|
||||||
|
**output** <name> <background|bg> <file> <mode>::
|
||||||
|
Sets the wallpaper for the given output to the specified file, using the given
|
||||||
|
scaling mode (one of "stretch", "fill", "center", "tile").
|
||||||
|
|
||||||
**output** <name> disable::
|
**output** <name> disable::
|
||||||
Disables the specified output.
|
Disables the specified output.
|
||||||
|
|
||||||
|
**NOTES FOR THE OUTPUT COMMAND**::
|
||||||
|
You may combine output commands into one, like so:
|
||||||
|
+
|
||||||
|
output HDMI-A-1 res 1920x1080 pos 1920,0 bg ~/wallpaper.png stretch
|
||||||
|
+
|
||||||
|
You can get a list of output names like so:
|
||||||
|
+
|
||||||
|
swaymsg -t get_outputs
|
||||||
|
|
||||||
**reload**::
|
**reload**::
|
||||||
Reloads the sway config file without restarting sway.
|
Reloads the sway config file without restarting sway.
|
||||||
|
|
||||||
|
|
|
@ -314,6 +314,28 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||||
}
|
}
|
||||||
output->x = x;
|
output->x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oc->background) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < root_container.children->length; ++i) {
|
||||||
|
if (root_container.children->items[i] == output) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
|
||||||
|
char *cmd = malloc(
|
||||||
|
strlen("swaybg ") +
|
||||||
|
(i >= 10 ? 2 : 1) +
|
||||||
|
strlen(oc->background) + 3 +
|
||||||
|
strlen(oc->background_option) + 3 +
|
||||||
|
1);
|
||||||
|
sprintf(cmd, "swaybg %d '%s' '%s'", i, oc->background, oc->background_option);
|
||||||
|
if (fork() == 0) {
|
||||||
|
execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
|
||||||
|
}
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *do_var_replacement(char *str) {
|
char *do_var_replacement(char *str) {
|
||||||
|
|
|
@ -43,6 +43,11 @@ static bool handle_output_created(wlc_handle output) {
|
||||||
swayc_t *ws = op->children->items[0];
|
swayc_t *ws = op->children->items[0];
|
||||||
workspace_switch(ws);
|
workspace_switch(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixes issues with backgrounds and wlc
|
||||||
|
wlc_handle prev = wlc_get_focused_output();
|
||||||
|
wlc_output_focus(output);
|
||||||
|
wlc_output_focus(prev);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,28 +28,29 @@ int main(int argc, char **argv) {
|
||||||
surfaces = create_list();
|
surfaces = create_list();
|
||||||
registry = registry_poll();
|
registry = registry_poll();
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 4) {
|
||||||
sway_abort("Usage: swaybg path/to/file.png");
|
sway_abort("Do not run this program manually. See man 5 sway and look for output options.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!registry->desktop_shell) {
|
if (!registry->desktop_shell) {
|
||||||
sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
|
sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int desired_output = atoi(argv[1]);
|
||||||
|
sway_log(L_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < registry->outputs->length; ++i) {
|
struct output_state *output = registry->outputs->items[desired_output];
|
||||||
struct output_state *output = registry->outputs->items[i];
|
struct window *window = window_setup(registry, 100, 100, false);
|
||||||
struct window *window = window_setup(registry, 100, 100, false);
|
if (!window) {
|
||||||
if (!window) {
|
sway_abort("Failed to create surfaces.");
|
||||||
sway_abort("Failed to create surfaces.");
|
|
||||||
}
|
|
||||||
window->width = output->width;
|
|
||||||
window->height = output->height;
|
|
||||||
desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
|
|
||||||
list_add(surfaces, window);
|
|
||||||
}
|
}
|
||||||
|
window->width = output->width;
|
||||||
|
window->height = output->height;
|
||||||
|
desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
|
||||||
|
list_add(surfaces, window);
|
||||||
|
|
||||||
cairo_surface_t *image = cairo_image_surface_create_from_png(argv[1]);
|
char *scaling_mode = argv[3];
|
||||||
|
cairo_surface_t *image = cairo_image_surface_create_from_png(argv[2]);
|
||||||
double width = cairo_image_surface_get_width(image);
|
double width = cairo_image_surface_get_width(image);
|
||||||
double height = cairo_image_surface_get_height(image);
|
double height = cairo_image_surface_get_height(image);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
||||||
uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) {
|
uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) {
|
||||||
sway_log(L_INFO, "Set cursor");
|
|
||||||
struct window *window = data;
|
struct window *window = data;
|
||||||
struct wl_cursor_image *image = window->cursor.cursor->images[0];
|
struct wl_cursor_image *image = window->cursor.cursor->images[0];
|
||||||
wl_pointer_set_cursor(pointer, serial, window->cursor.surface, image->hotspot_x, image->hotspot_y);
|
wl_pointer_set_cursor(pointer, serial, window->cursor.surface, image->hotspot_x, image->hotspot_y);
|
||||||
|
@ -72,7 +71,6 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t
|
||||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||||
}
|
}
|
||||||
if (registry->pointer) {
|
if (registry->pointer) {
|
||||||
sway_log(L_INFO, "Register pointer");
|
|
||||||
wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
|
wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue