Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1671af82ee | ||
|
|
1b4f9c5c04 | ||
|
|
5c9efcf316 | ||
|
|
b064e86f2f | ||
|
|
014fd9c12e | ||
|
|
2d0cdae396 | ||
|
|
ca843bf255 |
3 changed files with 36 additions and 22 deletions
|
|
@ -6,19 +6,29 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DL_DIR: /srv/breadway-dl
|
DL_DIR: /srv/breadway-dl
|
||||||
ECOSYSTEM_DIR: /home/breadway/Projects/bread-ecosystem
|
ECOSYSTEM_DIR: /tmp/bread-ecosystem-ci
|
||||||
|
PATH: /home/breadway/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: [self-hosted, hestia]
|
runs-on: hestia
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: /tmp/breadpaper-build
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: checkout
|
||||||
|
working-directory: /tmp
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/breadpaper-build
|
||||||
|
git clone --branch "${GITHUB_REF_NAME}" --depth 1 \
|
||||||
|
"https://git.breadway.dev/${GITHUB_REPOSITORY}.git" /tmp/breadpaper-build
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: cargo build --release --locked
|
run: /home/breadway/.cargo/bin/cargo build --release --locked
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: cargo test --release --locked
|
run: /home/breadway/.cargo/bin/cargo test --release --locked
|
||||||
|
|
||||||
- name: prepare artifacts
|
- name: prepare artifacts
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -33,13 +43,11 @@ jobs:
|
||||||
ln -sfn "${VERSION}" "${DL_DIR}/breadpaper/latest"
|
ln -sfn "${VERSION}" "${DL_DIR}/breadpaper/latest"
|
||||||
|
|
||||||
- name: ensure bread-ecosystem
|
- name: ensure bread-ecosystem
|
||||||
|
working-directory: /tmp
|
||||||
run: |
|
run: |
|
||||||
if [[ -d "${ECOSYSTEM_DIR}/.git" ]]; then
|
rm -rf "${ECOSYSTEM_DIR}"
|
||||||
git -C "${ECOSYSTEM_DIR}" pull --ff-only
|
git clone https://github.com/Breadway/bread-ecosystem.git "${ECOSYSTEM_DIR}"
|
||||||
else
|
|
||||||
mkdir -p "$(dirname "${ECOSYSTEM_DIR}")"
|
|
||||||
git clone https://github.com/Breadway/bread-ecosystem.git "${ECOSYSTEM_DIR}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: regenerate index.json
|
- name: regenerate index.json
|
||||||
|
working-directory: /tmp
|
||||||
run: bash "${ECOSYSTEM_DIR}/scripts/gen-index.sh"
|
run: bash "${ECOSYSTEM_DIR}/scripts/gen-index.sh"
|
||||||
|
|
|
||||||
24
src/main.rs
24
src/main.rs
|
|
@ -4,19 +4,23 @@ use std::process;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "breadpaper", about = "Wallpaper manager for the bread desktop")]
|
#[command(
|
||||||
|
name = "breadpaper",
|
||||||
|
version,
|
||||||
|
about = "Wallpaper manager for the bread desktop"
|
||||||
|
)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
/// Image file to set as wallpaper (shorthand for `set`)
|
||||||
|
path: Option<PathBuf>,
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Command,
|
command: Option<Command>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Command {
|
enum Command {
|
||||||
/// Set wallpaper, generate pywal palette, and reload bread themes
|
/// Set wallpaper, generate pywal palette, and reload bread themes
|
||||||
Set {
|
Set { path: PathBuf },
|
||||||
/// Path to the image file
|
|
||||||
path: PathBuf,
|
|
||||||
},
|
|
||||||
/// Print the current wallpaper path
|
/// Print the current wallpaper path
|
||||||
Get,
|
Get,
|
||||||
}
|
}
|
||||||
|
|
@ -24,9 +28,11 @@ enum Command {
|
||||||
fn main() {
|
fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
|
|
||||||
let result = match cli.command {
|
let result = match (cli.command, cli.path) {
|
||||||
Command::Set { path } => breadpaper::set(&path),
|
(Some(Command::Set { path }), _) | (None, Some(path)) => breadpaper::set(&path),
|
||||||
Command::Get => breadpaper::get().map(|p| println!("{}", p.display())),
|
(Some(Command::Get), _) | (None, None) => {
|
||||||
|
breadpaper::get().map(|p| println!("{}", p.display()))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = result {
|
if let Err(e) = result {
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ use anyhow::{Context, Result, bail};
|
||||||
|
|
||||||
pub fn apply(path: &Path) -> Result<()> {
|
pub fn apply(path: &Path) -> Result<()> {
|
||||||
let status = Command::new("awww")
|
let status = Command::new("awww")
|
||||||
.arg("set")
|
.arg("img")
|
||||||
.arg(path)
|
.arg(path)
|
||||||
.status()
|
.status()
|
||||||
.context("failed to run awww — is awww-daemon running?")?;
|
.context("failed to run awww — is awww-daemon running?")?;
|
||||||
|
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
bail!("awww set exited with {}", status);
|
bail!("awww img exited with {}", status);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue