Skip to content

Commit 1d8df14

Browse files
vaxerskifufexan
andauthored
core: migrate to hyprtoolkit (#288)
--------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
1 parent 1733e00 commit 1d8df14

36 files changed

Lines changed: 1151 additions & 1787 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ result
2222
protocols/*.hpp
2323
protocols/*.cpp
2424

25+
hw-protocols/*.hpp
26+
hw-protocols/*.cpp
27+
2528
.cache/
2629

2730
hyprctl/hyprctl

CMakeLists.txt

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ project(
88
DESCRIPTION "A blazing fast wayland wallpaper utility"
99
VERSION ${VERSION})
1010

11+
add_compile_definitions(HYPRPAPER_VERSION="${VERSION}")
12+
1113
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
1214

1315
message(STATUS "Configuring hyprpaper!")
@@ -39,7 +41,7 @@ execute_process(
3941
OUTPUT_VARIABLE GIT_DIRTY
4042
OUTPUT_STRIP_TRAILING_WHITESPACE)
4143

42-
include_directories(.)
44+
include_directories(. hw-protocols protocols)
4345
set(CMAKE_CXX_STANDARD 23)
4446
add_compile_options(-DWLR_USE_UNSTABLE)
4547
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
@@ -53,19 +55,20 @@ pkg_check_modules(
5355
deps
5456
REQUIRED
5557
IMPORTED_TARGET
56-
wayland-client
57-
wayland-protocols>=1.35
58-
cairo
59-
pango
60-
pangocairo
6158
hyprlang>=0.6.0
6259
hyprutils>=0.2.4
63-
hyprgraphics)
60+
wayland-client
61+
hyprtoolkit>=0.4.1
62+
hyprwire
63+
pixman-1
64+
libdrm)
6465

6566
file(GLOB_RECURSE SRCFILES "src/*.cpp")
6667

6768
add_executable(hyprpaper ${SRCFILES})
6869

70+
# Wayland
71+
6972
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
7073
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
7174
pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir)
@@ -107,6 +110,25 @@ protocolnew("stable/xdg-shell" "xdg-shell" false)
107110
protocolnew("staging/cursor-shape" "cursor-shape-v1" false)
108111
protocolnew("stable/tablet" "tablet-v2" false)
109112

113+
# Hyprwire
114+
115+
function(hyprprotocolServer protoPath protoName)
116+
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
117+
add_custom_command(
118+
OUTPUT ${CMAKE_SOURCE_DIR}/hw-protocols/${protoName}-server.cpp
119+
${CMAKE_SOURCE_DIR}/hw-protocols/${protoName}-server.hpp
120+
COMMAND hyprwire-scanner ${path}/${protoName}.xml
121+
${CMAKE_SOURCE_DIR}/hw-protocols/
122+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
123+
target_sources(hyprpaper PRIVATE hw-protocols/${protoName}-server.cpp
124+
hw-protocols/${protoName}-server.hpp
125+
)
126+
endfunction()
127+
128+
hyprprotocolServer(hw-protocols hyprpaper_core)
129+
130+
#
131+
110132
string(REPLACE "\"" " " GIT_COMMIT_MESSAGE_ESCAPED "${GIT_COMMIT_MESSAGE}")
111133
target_compile_definitions(hyprpaper
112134
PRIVATE "-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")

README.md

Lines changed: 6 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# hyprpaper
22

3-
Hyprpaper is a blazing fast wallpaper utility for Hyprland with the ability to dynamically change wallpapers through sockets. It will work on all wlroots-based compositors, though.
3+
Hyprpaper is a simple and fast wallpaper utility for Hyprland with the ability to dynamically change wallpapers through sockets.
44

55
# Features
66
- Per-output wallpapers
7-
- fill, tile or contain modes
7+
- fill, tile, cover or contain modes
88
- fractional scaling support
9-
- IPC for blazing fast wallpaper switches
10-
- preloading targets into memory
9+
- IPC for fast wallpaper switches
1110

1211
# Installation
1312

@@ -20,35 +19,10 @@ Hyprpaper is a blazing fast wallpaper utility for Hyprland with the ability to d
2019
### Dependencies
2120
The development files of these packages need to be installed on the system for `hyprpaper` to build correctly.
2221
(Development packages are usually suffixed with `-dev` or `-devel` in most distros' repos).
23-
- wayland
24-
- wayland-protocols
25-
- pango
26-
- cairo
27-
- file
28-
- libglvnd
29-
- libglvnd-core
30-
- libjpeg-turbo
31-
- libwebp
32-
- libjxl
22+
- hyprtoolkit
3323
- hyprlang
3424
- hyprutils
35-
- hyprwayland-scanner
36-
- hyprgraphics
37-
38-
To install all of these in Fedora, run this command:
39-
```
40-
sudo dnf install wayland-devel wayland-protocols-devel hyprlang-devel pango-devel cairo-devel file-devel libglvnd-devel libglvnd-core-devel libjpeg-turbo-devel libwebp-devel libjxl-devel gcc-c++ hyprutils-devel hyprwayland-scanner
41-
```
42-
43-
On Arch:
44-
```
45-
sudo pacman -S ninja gcc wayland-protocols libjpeg-turbo libwebp libjxl pango cairo pkgconf cmake libglvnd wayland hyprutils hyprwayland-scanner hyprlang
46-
```
47-
48-
On OpenSUSE:
49-
```
50-
sudo zypper install ninja gcc-c++ wayland-protocols-devel Mesa-libGLESv3-devel file-devel hyprutils-devel hyprwayland-scanner
51-
```
25+
- hyprwire
5226

5327
### Building
5428

@@ -63,129 +37,4 @@ Install with:
6337

6438
```sh
6539
cmake --install ./build
66-
```
67-
68-
# Usage
69-
70-
Hyprpaper is controlled by the config, like this:
71-
72-
*~/.config/hypr/hyprpaper.conf*
73-
```
74-
preload = /path/to/image.png
75-
#if more than one preload is desired then continue to preload other backgrounds
76-
preload = /path/to/next_image.png
77-
# .. more preloads
78-
79-
#set the default wallpaper(s) seen on initial workspace(s) --depending on the number of monitors used
80-
wallpaper = monitor1,/path/to/image.png
81-
#if more than one monitor in use, can load a 2nd image
82-
wallpaper = monitor2,/path/to/next_image.png
83-
# .. more monitors
84-
85-
#enable splash text rendering over the wallpaper
86-
splash = true
87-
88-
#fully disable ipc
89-
# ipc = off
90-
91-
92-
```
93-
94-
Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg, jpeg xl, webp). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty to set all monitors without an active wallpaper. You can also use `desc:` followed by the monitor's description without the (PORT) at the end)
95-
96-
You may add `contain:` or `tile:` before the file path in `wallpaper=` to set the mode to either contain or tile, respectively, instead of cover:
97-
98-
```
99-
wallpaper = monitor,contain:/path/to/image.jpg
100-
```
101-
102-
A Wallpaper ***cannot*** be applied without preloading. The config is ***not*** reloaded dynamically.
103-
104-
## Important note to the inner workings
105-
Preload does exactly what it says. It loads the entire wallpaper into memory. This can result in around 8 - 20MB of mem usage. It is not recommended to preload every wallpaper you have, as it will be a) taking a couple seconds at the beginning to load and b) take 100s of MBs of disk and RAM usage.
106-
107-
Preload is meant only for situations in which you want a wallpaper to switch INSTANTLY when you issue a wallpaper keyword (e.g. wallpaper per workspace)
108-
109-
In any and all cases when you don't mind waiting 300ms for the wallpaper to change, consider making a script that:
110-
- preloads the new wallpaper
111-
- sets the new wallpaper
112-
- unloads the old wallpaper (to free memory)
113-
114-
# IPC
115-
You can use `hyprctl hyprpaper` (if on Hyprland) to issue a keyword, for example
116-
117-
Example:
118-
119-
If your wallpapers are stored in *~/Pictures*, then make sure you have already preloaded the desired wallpapers in hyprpaper.conf.
120-
121-
*~/.config/hypr/hyprpaper.conf*
122-
```
123-
preload = ~/Pictures/myepicpng.png
124-
preload = ~/Pictures/myepicpngToo.png
125-
preload = ~/Pictures/myepicpngAlso.png
126-
#... continue as desired, but be mindful of the impact on memory.
127-
```
128-
129-
In the actual configuration for Hyprland, *hyprland.conf*, variables can be set for ease of reading and to be used as shortcuts in the bind command. The following example uses $w shorthand wallpaper variables:
130-
131-
*~/.config/hypr/hyprland.conf*
132-
```
133-
$w1 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpng.png"
134-
$w2 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpngToo.png"
135-
$w3 = hyprctl hyprpaper wallpaper "DP-1,~/Pictures/myepicpngAlso.png"
136-
#yes use quotes around desired monitor and wallpaper
137-
#... continued with desired amount
138-
```
139-
With the variables created we can now "exec" the actions.
140-
141-
Remember in Hyprland we can bind more than one action to a key so in the case where we'd like to change the wallpaper when we switch workspace we have to ensure that the actions are bound to the same key such as...
142-
143-
*~/.config/hypr/hyprland.conf*
144-
```
145-
bind=SUPER,1,workspace,1 #Superkey + 1 switches to workspace 1
146-
bind=SUPER,1,exec,$w1 #SuperKey + 1 switches to wallpaper $w1 on DP-1 as defined in the variable
147-
148-
bind=SUPER,2,workspace,2 #Superkey + 2 switches to workspace 2
149-
bind=SUPER,2,exec,$w2 #SuperKey + 2 switches to wallpaper $w2 on DP-1 as defined in the variable
150-
151-
bind=SUPER,3,workspace,3 #Superkey + 3 switches to workspace 3
152-
bind=SUPER,3,exec,$w3 #SuperKey + 3 switches to wallpaper $w3 on DP-1 as defined in the variable
153-
154-
#... and so on
155-
```
156-
Because the default behavior in Hyprland is to also switch the workspace whenever movetoworkspace is used to move a window to another workspace you may want to include the following:
157-
158-
```
159-
bind=SUPERSHIFT,1,movetoworkspace,1 #Superkey + Shift + 1 moves windows and switches to workspace 1
160-
bind=SUPERSHIFT,1,exec,$w1 #SuperKey + Shift + 1 switches to wallpaper $w1 on DP-1 as defined in the variable
161-
```
162-
163-
## Getting information from hyprpaper
164-
You can also use `hyprctl hyprpaper` to get information about the state of hyprpaper using the following commands:
165-
```
166-
listloaded - lists the wallpapers that are currently preloaded (useful for dynamically preloading and unloading)
167-
listactive - prints the active wallpapers hyprpaper is displaying, along with its accociated monitor
168-
```
169-
170-
# Battery life
171-
Since the IPC has to tick every now and then, and poll in the background, battery life might be a tiny bit worse with IPC on. If you want to fully disable it, use
172-
```
173-
ipc = off
174-
```
175-
in the config.
176-
177-
# Misc
178-
You can set `splash = true` to enable the splash rendering over the wallpaper.
179-
180-
The value for `splash_offset` sets, in percentage, the splash rendering offset relative to the bottom of the display.
181-
182-
## Unloading
183-
If you use a lot of wallpapers, consider unloading those that you no longer need. This will mean you need to load them again if you wish to use them for a second time, but will free the memory used by the preloaded bitmap. (Usually 8 - 20MB, depending on the resolution)
184-
185-
You can issue a `hyprctl hyprpaper unload [PATH]` to do that.
186-
187-
You can also issue a `hyprctl hyprpaper unload all` to unload all inactive wallpapers.
188-
189-
<br/>
190-
191-
For other compositors, the socket works like socket1 of Hyprland, and is located in `/tmp/hypr/.hyprpaper.sock` (this path only when Hyprland is not running!)
40+
```

0 commit comments

Comments
 (0)