Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ $ wpaperctl toggle-pause
## Wallpaper Configuration

The configuration file for *wpaperd* is located in `XDG_CONFIG_HOME/wpaperd/config.toml`
(which defaults to `~/.config/wpaperd/config.toml`). Each section
represents a different display and can contain the following keys:
(which defaults to `~/.config/wpaperd/config.toml`).

There are some top-level options for configuring general wpaperd behavior, and sections for configuring the wallpapers. The top-level options are:

- `layer_namespace`, the prefix for the `wlr_layer_shell` layer surface's namespace. _Optional_, defaults to `wpaperd`
- `socket_name`, the name used for the IPC socket. Can be specified in `wpaperctl` with the `-s` flag. _Optional_, defaults to `wpaperd`

Each section represents a different display and can contain the following keys:

- `path`, path to the image to use as wallpaper or to a directory to pick the wallpaper from
- `duration`, how much time the image should be displayed until it is changed with a new one.
Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {

let mut json_resp = false;

let mut conn = UnixStream::connect(socket_path().unwrap()).unwrap();
let mut conn = UnixStream::connect(socket_path(args.socket_name.as_deref()).unwrap()).unwrap();
let msg = match args.subcmd {
SubCmd::GetWallpaper { monitor } => IpcMessage::CurrentWallpaper {
monitor: unquote(monitor),
Expand Down
2 changes: 2 additions & 0 deletions cli/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use clap::Parser;
pub struct Opts {
#[clap(subcommand)]
pub subcmd: SubCmd,
#[clap(short, long)]
pub socket_name: Option<String>,
}

#[derive(clap::Subcommand)]
Expand Down
2 changes: 2 additions & 0 deletions daemon/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ impl SerializedWallpaperInfo {
pub struct Config {
#[serde(flatten)]
data: HashMap<String, SerializedWallpaperInfo>,
pub layer_namespace: Option<String>,
pub socket_name: Option<String>,
#[serde(skip)]
default: SerializedWallpaperInfo,
#[serde(skip)]
Expand Down
8 changes: 6 additions & 2 deletions daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ fn run(opts: Opts, xdg_dirs: BaseDirectories) -> Result<()> {
.wrap_err("Failed to insert the image loader listener into the event loop")?;
let image_loader = Rc::new(RefCell::new(ImageLoader::new(image_loader_ping)));

let socket_name = config.socket_name.clone();

let mut wpaperd = Wpaperd::new(
&qh,
&globals,
Expand All @@ -171,8 +173,10 @@ fn run(opts: Opts, xdg_dirs: BaseDirectories) -> Result<()> {
.wrap_err("Failed to initiliaze wpaperd status")?;

// Start listening on the IPC socket
let socket = listen_on_ipc_socket(&socket_path().wrap_err("Failed to locate wpaperd socket")?)
.wrap_err("Failed to listen to IPC socket")?;
let socket = listen_on_ipc_socket(
&socket_path(socket_name.as_deref()).wrap_err("Failed to locate wpaperd socket")?,
)
.wrap_err("Failed to listen to IPC socket")?;

// Add source to calloop loop.
event_loop
Expand Down
9 changes: 8 additions & 1 deletion daemon/src/wpaperd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,14 @@ impl OutputHandler for Wpaperd {
qh,
surface.clone(),
Layer::Background,
Some(format!("wpaperd-{name}")),
Some(format!(
"{}-{name}",
self.config
.layer_namespace
.as_ref()
.and_then(|s| Some(s.as_str()))
.unwrap_or("wpaperd")
)),
Some(&output),
);
layer.set_anchor(Anchor::TOP | Anchor::LEFT | Anchor::RIGHT | Anchor::BOTTOM);
Expand Down
9 changes: 6 additions & 3 deletions ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ pub enum IpcError {
DrawErrors(Vec<(String, String)>),
}

pub fn socket_path() -> Result<PathBuf, BaseDirectoriesError> {
let xdg_dirs = BaseDirectories::with_prefix("wpaperd")?;
Ok(xdg_dirs.get_runtime_directory()?.join("wpaperd.sock"))
pub fn socket_path(name: Option<&str>) -> Result<PathBuf, BaseDirectoriesError> {
let name = name.unwrap_or("wpaperd");
let xdg_dirs = BaseDirectories::with_prefix(name)?;
Ok(xdg_dirs
.get_runtime_directory()?
.join(format!("{name}.sock")))
}
13 changes: 11 additions & 2 deletions man/wpaperd-output.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ $ hyprctl monitors
```

The configuration file for *wpaperd* is located in `XDG_CONFIG_HOME/wpaperd/config.toml`
(which defaults to `~/.config/wpaperd/config.toml`). Each section
represents a different display and can contain the following keys:
(which defaults to `~/.config/wpaperd/config.toml`).

There are some top-level options for configuring general wpaperd behavior, and sections for
configuring the wallpapers. The top-level options are:

- `layer_namespace`, the prefix for the `wlr_layer_shell` layer surface's namespace.
_Optional_, defaults to `wpaperd`
- `socket_name`, the name used for the IPC socket. Can be specified in `wpaperctl` with the
`-s` flag. _Optional_, defaults to `wpaperd`

Each section represents a different display and can contain the following keys:

- `path`, path to the image to use as wallpaper or to a directory to pick the wallpaper from
- `duration`, how much time the image should be displayed until it is changed with a new one.
Expand Down