Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| acbf499bb7 | |||
| 8bc6d5d1c5 | |||
| 4b7bdc487f |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -148,7 +148,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cliphoard"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dirs",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cliphoard"
|
||||
version = "1.1.0"
|
||||
version = "1.2.0"
|
||||
edition = "2021"
|
||||
description = "A tiny, keyboard-first clipboard history utility"
|
||||
license = "MIT"
|
||||
|
||||
@@ -8,7 +8,7 @@ with SQLCipher and unlocked with a passphrase that Cliphoard does not store.
|
||||
Install the package on Debian, Ubuntu, or Mint:
|
||||
|
||||
```bash
|
||||
sudo apt install ./cliphoard_1.1.0_amd64.deb
|
||||
sudo apt install ./cliphoard_1.2.0_amd64.deb
|
||||
```
|
||||
|
||||
The package installs the `cliphoard` command, desktop launcher, tray icon,
|
||||
@@ -29,7 +29,7 @@ sudo apt install cargo rustc dpkg-dev libgtk-4-dev libdbus-1-dev libx11-dev libx
|
||||
cargo test --locked --all-features
|
||||
cargo build --release --locked --features gui
|
||||
packaging/build-deb.sh
|
||||
sudo apt install ./target/cliphoard_1.1.0_amd64.deb
|
||||
sudo apt install ./target/cliphoard_1.2.0_amd64.deb
|
||||
```
|
||||
|
||||
An isolated Docker build produces the same package:
|
||||
|
||||
21
RELEASE_NOTES.md
Normal file
21
RELEASE_NOTES.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Cliphoard 1.2.0
|
||||
|
||||
## Highlights
|
||||
|
||||
- Added configurable popup opacity and always-on-top behavior.
|
||||
- Added settings for startup behavior, keyboard shortcut, history limits, and
|
||||
retention.
|
||||
- Added search reset-on-reopen and privacy-pattern clipboard filtering.
|
||||
- Settings changes are persisted in the user configuration file.
|
||||
|
||||
## Compatibility and migration
|
||||
|
||||
This release continues to use encrypted SQLCipher storage and the existing
|
||||
passphrase. No database migration is required. Plaintext databases remain
|
||||
unsupported and are not opened or migrated; preserve any needed data with the
|
||||
previous release before removing a plaintext database.
|
||||
|
||||
## Build requirements
|
||||
|
||||
Linux/X11, GTK4, and the runtime libraries listed by the Debian package are
|
||||
required. See `README.md` for installation and plaintext-database handling.
|
||||
98
RELEASING.md
98
RELEASING.md
@@ -1,7 +1,7 @@
|
||||
# Cliphoard release procedure
|
||||
|
||||
Run releases from the repository root. The current Git remote stores source
|
||||
and tags, but no binary-upload destination is configured.
|
||||
Run releases from the repository root. The process produces a source tag,
|
||||
release binary, Debian package, checksums, and a Gitea release.
|
||||
|
||||
## Prepare
|
||||
|
||||
@@ -11,10 +11,12 @@ git pull --ff-only
|
||||
git status --short
|
||||
```
|
||||
|
||||
Choose the next semantic version, for example `1.1.0`, and tag it `v1.1.0`.
|
||||
Choose the next semantic version, such as `1.2.0`, and matching tag `v1.2.0`.
|
||||
Update the version in `Cargo.toml`, the root `cliphoard` package in
|
||||
`Cargo.lock`, `packaging/debian/control`, `packaging/build-deb.sh`, and the
|
||||
versioned `.deb` names in `README.md`.
|
||||
versioned `.deb` names in `README.md`. Review changes since the previous tag
|
||||
and write notes covering features, fixes, breaking changes, migration needs,
|
||||
passphrase behavior, and platform requirements.
|
||||
|
||||
## Verify and build
|
||||
|
||||
@@ -23,20 +25,22 @@ cargo fmt --all -- --check
|
||||
cargo test --locked --all-features
|
||||
cargo clippy --locked --all-features -- -D warnings
|
||||
cargo build --release --locked --features gui
|
||||
CLIPHOARD_VERSION=1.1.0 packaging/build-deb.sh
|
||||
dpkg-deb --info target/cliphoard_1.1.0_amd64.deb
|
||||
dpkg-deb --contents target/cliphoard_1.1.0_amd64.deb
|
||||
sha256sum target/cliphoard_1.1.0_amd64.deb target/release/cliphoard
|
||||
CLIPHOARD_VERSION=1.2.0 packaging/build-deb.sh
|
||||
dpkg-deb --info target/cliphoard_1.2.0_amd64.deb
|
||||
dpkg-deb --contents target/cliphoard_1.2.0_amd64.deb
|
||||
sha256sum target/cliphoard_1.2.0_amd64.deb target/release/cliphoard > target/cliphoard_1.2.0_SHA256SUMS
|
||||
```
|
||||
|
||||
The Docker workflow from the README provides an isolated test, release-build,
|
||||
and package-build path:
|
||||
The isolated package path is:
|
||||
|
||||
```bash
|
||||
docker build -t cliphoard-builder .
|
||||
docker run --rm -v "$PWD/target:/out" cliphoard-builder
|
||||
```
|
||||
|
||||
Do not commit `target/`; retain the exact package, binary, and checksum files
|
||||
for upload.
|
||||
|
||||
## Commit and tag
|
||||
|
||||
Only commit after the gates pass:
|
||||
@@ -45,35 +49,75 @@ Only commit after the gates pass:
|
||||
git diff --check
|
||||
git status --short
|
||||
git add Cargo.toml Cargo.lock README.md packaging/debian/control packaging/build-deb.sh src .agents RELEASING.md
|
||||
git commit -m "Release Cliphoard 1.1.0"
|
||||
git tag -a v1.1.0 -m "Release Cliphoard 1.1.0"
|
||||
git commit -m "Release Cliphoard 1.2.0"
|
||||
git tag -a v1.2.0 -m "Release Cliphoard 1.2.0"
|
||||
```
|
||||
|
||||
Replace `1.1.0` and `v1.1.0` with the actual version.
|
||||
Replace `1.2.0` and `v1.2.0` with the actual version.
|
||||
|
||||
## Sync
|
||||
## Push Git
|
||||
|
||||
Confirm the remote has not moved since the preparation pull. Never force-push:
|
||||
|
||||
```bash
|
||||
git show --stat --oneline HEAD
|
||||
git show --no-patch --decorate HEAD
|
||||
git push origin main
|
||||
git push origin v1.1.0
|
||||
git push origin v1.2.0
|
||||
```
|
||||
|
||||
If another commit landed remotely after the initial pull, stop and resolve it
|
||||
before pushing. Never force-push release history.
|
||||
If the remote changed, stop and reconcile it before pushing.
|
||||
|
||||
## Publish the Gitea release and binary
|
||||
## Publish on Gitea
|
||||
|
||||
Pushing Git does not upload `target/*.deb`: `target/` is ignored and the
|
||||
binary is not committed. Create a Gitea release for the pushed tag, include a
|
||||
summary of commits and changes, explicitly call out breaking changes, and
|
||||
attach the `.deb`, release binary, and checksum file. The release must include
|
||||
the plaintext-database deletion note and commands from `README.md`.
|
||||
Pushing Git does not upload ignored `target/` files. Create a release for the
|
||||
pushed tag and attach:
|
||||
|
||||
- `target/cliphoard_1.2.0_amd64.deb`
|
||||
- `target/release/cliphoard`
|
||||
- `target/cliphoard_1.2.0_SHA256SUMS`
|
||||
|
||||
Using the Gitea web UI: open **Releases**, choose **New Release**, select
|
||||
`v1.2.0`, enter `Cliphoard 1.2.0`, paste the release notes, upload all three
|
||||
files, and publish. Include breaking changes and the plaintext-database
|
||||
deletion warning and commands from `README.md`.
|
||||
|
||||
For API automation, create a repository release-write token and set the
|
||||
installation-specific values without committing them:
|
||||
|
||||
```bash
|
||||
GITEA_URL="https://gitea.example.com"
|
||||
GITEA_OWNER="owner"
|
||||
GITEA_REPO="cliphoard"
|
||||
GITEA_TOKEN="..."
|
||||
VERSION="1.2.0"
|
||||
TAG="v${VERSION}"
|
||||
```
|
||||
|
||||
Create the release, then upload each artifact:
|
||||
|
||||
```bash
|
||||
release_json=$(curl --fail-with-body -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "$(jq -n --arg tag "$TAG" --arg name "Cliphoard $VERSION" --arg body "$(cat RELEASE_NOTES.md)" \
|
||||
'{tag_name:$tag,target_commitish:"main",name:$name,body:$body,draft:false,prerelease:false}')" \
|
||||
"${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases"
|
||||
release_id=$(jq -r '.id' <<<"$release_json")
|
||||
for artifact in "target/cliphoard_${VERSION}_amd64.deb" "target/release/cliphoard" "target/cliphoard_${VERSION}_SHA256SUMS"; do
|
||||
curl --fail-with-body -sS -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@${artifact}" \
|
||||
"${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases/${release_id}/assets?name=$(basename "$artifact")"
|
||||
done
|
||||
```
|
||||
|
||||
Never put a token in the repository, shell history, or release notes. If no
|
||||
authenticated Gitea web session or API token is available, stop after the Git
|
||||
push and resume at publication.
|
||||
|
||||
## Final smoke check
|
||||
|
||||
On a clean machine or disposable environment, install the exact `.deb`, start
|
||||
Cliphoard, create/unlock the encrypted database, and confirm the tray, popup,
|
||||
autostart, and passphrase flows. Keep the release commit, tag, artifact name,
|
||||
checksum, and test results together.
|
||||
On a clean machine, install the exact `.deb`, start Cliphoard, create/unlock
|
||||
the encrypted database, and check tray, popup, autostart, settings, and
|
||||
passphrase flows. Verify artifacts against `cliphoard_1.2.0_SHA256SUMS` and
|
||||
record the release URL, tag, checksums, and test results.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
version="${CLIPHOARD_VERSION:-1.1.0}"
|
||||
version="${CLIPHOARD_VERSION:-1.2.0}"
|
||||
package_root="${PWD}/target/cliphoard-deb"
|
||||
rm -rf "$package_root"
|
||||
mkdir -p "$package_root/DEBIAN" \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Package: cliphoard
|
||||
Version: 1.1.0
|
||||
Version: 1.2.0
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
|
||||
@@ -2,7 +2,7 @@ use anyhow::{Context, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fs, os::unix::fs::PermissionsExt, path::PathBuf};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct Config {
|
||||
pub history_limit: usize,
|
||||
@@ -11,7 +11,11 @@ pub struct Config {
|
||||
pub history_retention_days: u64,
|
||||
pub global_shortcut: String,
|
||||
pub autostart: bool,
|
||||
pub always_on_top: bool,
|
||||
pub show_window_after_unlock: bool,
|
||||
pub clear_search_on_reopen: bool,
|
||||
pub inactive_opacity: f64,
|
||||
pub ignored_patterns: Vec<String>,
|
||||
pub log_level: String,
|
||||
}
|
||||
|
||||
@@ -24,7 +28,11 @@ impl Default for Config {
|
||||
history_retention_days: 30,
|
||||
global_shortcut: "Ctrl+Alt+V".into(),
|
||||
autostart: true,
|
||||
always_on_top: true,
|
||||
show_window_after_unlock: true,
|
||||
clear_search_on_reopen: false,
|
||||
inactive_opacity: 0.60,
|
||||
ignored_patterns: Vec::new(),
|
||||
log_level: "info".into(),
|
||||
}
|
||||
}
|
||||
@@ -97,6 +105,9 @@ impl Config {
|
||||
if self.history_retention_days == 0 {
|
||||
anyhow::bail!("history_retention_days must be greater than zero")
|
||||
}
|
||||
if !self.inactive_opacity.is_finite() || !(0.0..=1.0).contains(&self.inactive_opacity) {
|
||||
anyhow::bail!("inactive_opacity must be between 0 and 1")
|
||||
}
|
||||
if !matches!(
|
||||
self.log_level.to_ascii_lowercase().as_str(),
|
||||
"trace" | "debug" | "info" | "warn" | "error"
|
||||
@@ -154,7 +165,9 @@ mod tests {
|
||||
assert_eq!(c.max_entry_bytes, 1_048_576);
|
||||
assert_eq!(c.history_retention_days, 30);
|
||||
assert_eq!(c.global_shortcut, "Ctrl+Alt+V");
|
||||
assert!(c.always_on_top);
|
||||
assert!(c.show_window_after_unlock);
|
||||
assert_eq!(c.inactive_opacity, 0.60);
|
||||
assert!(c.validate().is_ok());
|
||||
}
|
||||
|
||||
@@ -180,4 +193,15 @@ mod tests {
|
||||
assert!(config.validate().is_ok(), "{shortcut}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_invalid_inactive_opacity() {
|
||||
for inactive_opacity in [-0.01, 1.01, f64::NAN, f64::INFINITY] {
|
||||
let config = Config {
|
||||
inactive_opacity,
|
||||
..Config::default()
|
||||
};
|
||||
assert!(config.validate().is_err(), "{inactive_opacity}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
166
src/gui.rs
166
src/gui.rs
@@ -13,7 +13,7 @@ use anyhow::{Context, Result};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::{
|
||||
Application, ApplicationWindow, Box as GtkBox, Button, CheckButton, Entry, Label, ListBox,
|
||||
ListBoxRow, Orientation, ResponseType, ScrolledWindow, TextView,
|
||||
ListBoxRow, Orientation, ResponseType, Scale, ScrolledWindow, SpinButton, TextView,
|
||||
};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
@@ -358,6 +358,10 @@ fn build_window(
|
||||
.default_height(420)
|
||||
.child(&root)
|
||||
.build();
|
||||
let inactive_opacity = Rc::new(std::cell::Cell::new(config.inactive_opacity));
|
||||
let always_on_top = Rc::new(std::cell::Cell::new(config.always_on_top));
|
||||
let clear_search_on_reopen = Rc::new(std::cell::Cell::new(config.clear_search_on_reopen));
|
||||
let runtime_config = Rc::new(RefCell::new(config.clone()));
|
||||
let css = gtk4::CssProvider::new();
|
||||
css.load_from_data(
|
||||
"button.paused { background-color: #f3a6a6; color: #3d0000; font-weight: bold; } row.pinned { background-color: rgba(79, 107, 237, 0.10); border-radius: 6px; }",
|
||||
@@ -370,20 +374,40 @@ fn build_window(
|
||||
);
|
||||
}
|
||||
let window_for_opacity = window.clone();
|
||||
let inactive_opacity_for_realize = Rc::clone(&inactive_opacity);
|
||||
let always_on_top_for_realize = Rc::clone(&always_on_top);
|
||||
window.connect_realize(move |_| {
|
||||
crate::platform::linux::x11_window::configure(&window_for_opacity);
|
||||
crate::platform::linux::x11_window::configure(
|
||||
&window_for_opacity,
|
||||
inactive_opacity_for_realize.get(),
|
||||
always_on_top_for_realize.get(),
|
||||
);
|
||||
});
|
||||
let window_for_above = window.clone();
|
||||
let inactive_opacity_for_map = Rc::clone(&inactive_opacity);
|
||||
let always_on_top_for_map = Rc::clone(&always_on_top);
|
||||
window.connect_map(move |_| {
|
||||
crate::platform::linux::x11_window::configure(&window_for_above);
|
||||
crate::platform::linux::x11_window::configure(
|
||||
&window_for_above,
|
||||
inactive_opacity_for_map.get(),
|
||||
always_on_top_for_map.get(),
|
||||
);
|
||||
});
|
||||
let window_for_opacity = window.clone();
|
||||
let inactive_opacity_for_active = Rc::clone(&inactive_opacity);
|
||||
window.connect_is_active_notify(move |_| {
|
||||
crate::platform::linux::x11_window::set_active_opacity(&window_for_opacity);
|
||||
crate::platform::linux::x11_window::set_active_opacity(
|
||||
&window_for_opacity,
|
||||
inactive_opacity_for_active.get(),
|
||||
);
|
||||
});
|
||||
let window_for_opacity = window.clone();
|
||||
let inactive_opacity_for_timeout = Rc::clone(&inactive_opacity);
|
||||
glib::timeout_add_local(std::time::Duration::from_millis(100), move || {
|
||||
crate::platform::linux::x11_window::set_active_opacity(&window_for_opacity);
|
||||
crate::platform::linux::x11_window::set_active_opacity(
|
||||
&window_for_opacity,
|
||||
inactive_opacity_for_timeout.get(),
|
||||
);
|
||||
glib::ControlFlow::Continue
|
||||
});
|
||||
let recording = state.borrow().recording;
|
||||
@@ -701,13 +725,19 @@ fn build_window(
|
||||
});
|
||||
|
||||
let window_for_settings = window.clone();
|
||||
let config_for_settings = config.clone();
|
||||
let config_for_settings = Rc::clone(&runtime_config);
|
||||
let status_for_settings = status.clone();
|
||||
let inactive_opacity_for_settings = Rc::clone(&inactive_opacity);
|
||||
let always_on_top_for_settings = Rc::clone(&always_on_top);
|
||||
let clear_search_for_settings = Rc::clone(&clear_search_on_reopen);
|
||||
settings_button.connect_clicked(move |_| {
|
||||
show_settings(
|
||||
&window_for_settings,
|
||||
&config_for_settings,
|
||||
Rc::clone(&config_for_settings),
|
||||
&status_for_settings,
|
||||
Rc::clone(&inactive_opacity_for_settings),
|
||||
Rc::clone(&always_on_top_for_settings),
|
||||
Rc::clone(&clear_search_for_settings),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -765,7 +795,7 @@ fn build_window(
|
||||
|
||||
let state_for_watch = Rc::clone(&state);
|
||||
let list_for_watch = list.clone();
|
||||
let config_for_watch = config.clone();
|
||||
let config_for_watch = Rc::clone(&runtime_config);
|
||||
let row_actions_for_watch = row_actions.clone();
|
||||
let window_for_events = window.clone();
|
||||
let search_for_events = search_box.clone();
|
||||
@@ -781,6 +811,9 @@ fn build_window(
|
||||
if window_for_events.is_visible() {
|
||||
window_for_events.set_visible(false);
|
||||
} else {
|
||||
if clear_search_on_reopen.get() {
|
||||
search_for_events.set_text("");
|
||||
}
|
||||
request_focus(&mut state);
|
||||
window_for_events.present();
|
||||
search_for_events.grab_focus();
|
||||
@@ -790,6 +823,9 @@ fn build_window(
|
||||
if window_for_events.is_visible() {
|
||||
window_for_events.set_visible(false);
|
||||
} else {
|
||||
if clear_search_on_reopen.get() {
|
||||
search_for_events.set_text("");
|
||||
}
|
||||
request_focus(&mut state);
|
||||
window_for_events.present();
|
||||
search_for_events.grab_focus();
|
||||
@@ -807,7 +843,7 @@ fn build_window(
|
||||
&mut state,
|
||||
result,
|
||||
&list_for_watch,
|
||||
&config_for_watch,
|
||||
&config_for_watch.borrow(),
|
||||
&row_actions_for_watch,
|
||||
);
|
||||
}
|
||||
@@ -893,6 +929,14 @@ fn process_clipboard_result(
|
||||
&& !content.trim().is_empty()
|
||||
&& content.len() <= config.max_entry_bytes =>
|
||||
{
|
||||
if config
|
||||
.ignored_patterns
|
||||
.iter()
|
||||
.any(|pattern| content.contains(pattern))
|
||||
{
|
||||
tracing::debug!("ignored clipboard entry matching a privacy pattern");
|
||||
return;
|
||||
}
|
||||
match state.database.upsert_content(&content, now()) {
|
||||
Ok(entry) => {
|
||||
if let Err(error) = state.database.trim_unpinned(config.history_limit) {
|
||||
@@ -1096,7 +1140,15 @@ fn show_text_dialog(window: &ApplicationWindow, title: &str, content: &str) {
|
||||
dialog.present();
|
||||
}
|
||||
|
||||
fn show_settings(window: &ApplicationWindow, config: &Config, status: &Label) {
|
||||
fn show_settings(
|
||||
window: &ApplicationWindow,
|
||||
config: Rc<RefCell<Config>>,
|
||||
status: &Label,
|
||||
inactive_opacity: Rc<std::cell::Cell<f64>>,
|
||||
always_on_top: Rc<std::cell::Cell<bool>>,
|
||||
clear_search_on_reopen: Rc<std::cell::Cell<bool>>,
|
||||
) {
|
||||
let current_config = config.borrow().clone();
|
||||
let dialog = gtk4::Dialog::builder()
|
||||
.transient_for(window)
|
||||
.modal(true)
|
||||
@@ -1109,24 +1161,108 @@ fn show_settings(window: &ApplicationWindow, config: &Config, status: &Label) {
|
||||
content.set_margin_start(18);
|
||||
content.set_margin_end(18);
|
||||
let show_window = CheckButton::with_label("Show the Cliphoard window after unlock");
|
||||
show_window.set_active(config.show_window_after_unlock);
|
||||
show_window.set_active(current_config.show_window_after_unlock);
|
||||
content.append(&show_window);
|
||||
let keep_on_top = CheckButton::with_label("Always keep the popup in the foreground");
|
||||
keep_on_top.set_active(always_on_top.get());
|
||||
content.append(&keep_on_top);
|
||||
let clear_search = CheckButton::with_label("Clear the search field when reopening");
|
||||
clear_search.set_active(clear_search_on_reopen.get());
|
||||
content.append(&clear_search);
|
||||
let explanation = Label::new(Some(
|
||||
"When disabled, Cliphoard starts in the tray after you enter the passphrase. You can still open the window with the global shortcut.",
|
||||
"When disabled, Cliphoard starts in the tray after you enter the passphrase. You can still open the window with the global shortcut. Shortcut, autostart, and history-limit changes apply after restart.",
|
||||
));
|
||||
explanation.set_wrap(true);
|
||||
content.append(&explanation);
|
||||
let opacity_label = Label::new(Some("Opacity when unfocused"));
|
||||
content.append(&opacity_label);
|
||||
let opacity = Scale::with_range(Orientation::Horizontal, 0.0, 100.0, 1.0);
|
||||
opacity.set_value(inactive_opacity.get() * 100.0);
|
||||
opacity.set_digits(0);
|
||||
opacity.set_draw_value(true);
|
||||
opacity.set_hexpand(true);
|
||||
opacity.set_tooltip_text(Some("How transparent the popup is when it is not focused"));
|
||||
content.append(&opacity);
|
||||
let shortcut_label = Label::new(Some("Global shortcut (applies after restart)"));
|
||||
content.append(&shortcut_label);
|
||||
let shortcut = Entry::new();
|
||||
shortcut.set_text(¤t_config.global_shortcut);
|
||||
shortcut.set_tooltip_text(Some("For example: Ctrl+Alt+V"));
|
||||
content.append(&shortcut);
|
||||
let autostart = CheckButton::with_label("Start Cliphoard automatically when I log in");
|
||||
autostart.set_active(current_config.autostart);
|
||||
content.append(&autostart);
|
||||
let history_limit_label = Label::new(Some("Maximum unpinned history entries"));
|
||||
content.append(&history_limit_label);
|
||||
let history_limit = SpinButton::with_range(1.0, 10_000.0, 1.0);
|
||||
history_limit.set_value(current_config.history_limit as f64);
|
||||
content.append(&history_limit);
|
||||
let pinned_limit_label = Label::new(Some("Maximum pinned entries"));
|
||||
content.append(&pinned_limit_label);
|
||||
let pinned_limit = SpinButton::with_range(1.0, 10_000.0, 1.0);
|
||||
pinned_limit.set_value(current_config.pinned_limit as f64);
|
||||
content.append(&pinned_limit);
|
||||
let retention_label = Label::new(Some("Remove unpinned entries older than (days)"));
|
||||
content.append(&retention_label);
|
||||
let retention_days = SpinButton::with_range(1.0, 3_650.0, 1.0);
|
||||
retention_days.set_value(current_config.history_retention_days as f64);
|
||||
content.append(&retention_days);
|
||||
let ignored_label = Label::new(Some(
|
||||
"Ignore clipboard entries containing (comma-separated)",
|
||||
));
|
||||
content.append(&ignored_label);
|
||||
let ignored_patterns = Entry::new();
|
||||
ignored_patterns.set_text(¤t_config.ignored_patterns.join(", "));
|
||||
ignored_patterns.set_tooltip_text(Some("For example: password, secret-token"));
|
||||
content.append(&ignored_patterns);
|
||||
dialog.content_area().append(&content);
|
||||
dialog.add_button("Cancel", ResponseType::Cancel);
|
||||
dialog.add_button("Save", ResponseType::Accept);
|
||||
let config_for_response = config.clone();
|
||||
let config_for_response = Rc::clone(&config);
|
||||
let status_for_response = status.clone();
|
||||
let window_for_response = window.clone();
|
||||
dialog.connect_response(move |dialog, response| {
|
||||
if response == ResponseType::Accept {
|
||||
let mut updated_config = config_for_response.clone();
|
||||
let mut updated_config = config_for_response.borrow().clone();
|
||||
updated_config.show_window_after_unlock = show_window.is_active();
|
||||
updated_config.always_on_top = keep_on_top.is_active();
|
||||
updated_config.clear_search_on_reopen = clear_search.is_active();
|
||||
updated_config.inactive_opacity = opacity.value() / 100.0;
|
||||
updated_config.global_shortcut = shortcut.text().to_string();
|
||||
updated_config.autostart = autostart.is_active();
|
||||
updated_config.history_limit = history_limit.value_as_int() as usize;
|
||||
updated_config.pinned_limit = pinned_limit.value_as_int() as usize;
|
||||
updated_config.history_retention_days = retention_days.value_as_int() as u64;
|
||||
updated_config.ignored_patterns = ignored_patterns
|
||||
.text()
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.filter(|pattern| !pattern.is_empty())
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
if let Err(error) = updated_config.validate() {
|
||||
set_status(
|
||||
&status_for_response,
|
||||
&format!("Could not save settings: {error}"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
match updated_config.save() {
|
||||
Ok(()) => set_status(&status_for_response, "Settings saved"),
|
||||
Ok(()) => {
|
||||
*config_for_response.borrow_mut() = updated_config.clone();
|
||||
inactive_opacity.set(updated_config.inactive_opacity);
|
||||
always_on_top.set(updated_config.always_on_top);
|
||||
clear_search_on_reopen.set(updated_config.clear_search_on_reopen);
|
||||
crate::platform::linux::x11_window::set_active_opacity(
|
||||
&window_for_response,
|
||||
updated_config.inactive_opacity,
|
||||
);
|
||||
crate::platform::linux::x11_window::set_always_on_top(
|
||||
&window_for_response,
|
||||
updated_config.always_on_top,
|
||||
);
|
||||
set_status(&status_for_response, "Settings saved");
|
||||
}
|
||||
Err(error) => set_status(
|
||||
&status_for_response,
|
||||
&format!("Could not save settings: {error}"),
|
||||
|
||||
@@ -9,10 +9,13 @@ use x11rb::{
|
||||
};
|
||||
|
||||
const ACTIVE_OPACITY: f64 = 1.0;
|
||||
const INACTIVE_OPACITY: f64 = 0.60;
|
||||
|
||||
pub fn configure(window: &ApplicationWindow) {
|
||||
set_active_opacity(window);
|
||||
pub fn configure(window: &ApplicationWindow, inactive_opacity: f64, always_on_top: bool) {
|
||||
set_active_opacity(window, inactive_opacity);
|
||||
set_always_on_top(window, always_on_top);
|
||||
}
|
||||
|
||||
pub fn set_always_on_top(window: &ApplicationWindow, always_on_top: bool) {
|
||||
let Some(surface) = window.surface() else {
|
||||
return;
|
||||
};
|
||||
@@ -37,15 +40,6 @@ pub fn configure(window: &ApplicationWindow) {
|
||||
let Ok(above) = above_cookie.reply() else {
|
||||
return;
|
||||
};
|
||||
if let Err(error) = connection.change_property32(
|
||||
x11rb::protocol::xproto::PropMode::REPLACE,
|
||||
xid,
|
||||
state.atom,
|
||||
x11rb::protocol::xproto::AtomEnum::ATOM,
|
||||
&[above.atom],
|
||||
) {
|
||||
tracing::warn!(%error, "could not mark popup as always on top");
|
||||
}
|
||||
let root = connection.setup().roots[0].root;
|
||||
let event = ClientMessageEvent {
|
||||
response_type: CLIENT_MESSAGE_EVENT,
|
||||
@@ -53,7 +47,7 @@ pub fn configure(window: &ApplicationWindow) {
|
||||
sequence: 0,
|
||||
window: xid,
|
||||
type_: state.atom,
|
||||
data: ClientMessageData::from([1, above.atom, 0, 0, 0]),
|
||||
data: ClientMessageData::from([if always_on_top { 1 } else { 0 }, above.atom, 0, 0, 0]),
|
||||
};
|
||||
match connection.send_event(
|
||||
false,
|
||||
@@ -63,15 +57,17 @@ pub fn configure(window: &ApplicationWindow) {
|
||||
) {
|
||||
Ok(cookie) => {
|
||||
if let Err(error) = cookie.check() {
|
||||
tracing::debug!(%error, "window manager rejected always-on-top request");
|
||||
tracing::debug!(%error, always_on_top, "window manager rejected always-on-top request");
|
||||
}
|
||||
}
|
||||
Err(error) => tracing::debug!(%error, "could not send always-on-top request"),
|
||||
Err(error) => {
|
||||
tracing::debug!(%error, always_on_top, "could not send always-on-top request")
|
||||
}
|
||||
}
|
||||
let _ = connection.flush();
|
||||
}
|
||||
|
||||
pub fn set_active_opacity(window: &ApplicationWindow) {
|
||||
pub fn set_active_opacity(window: &ApplicationWindow, inactive_opacity: f64) {
|
||||
let Some(surface) = window.surface() else {
|
||||
return;
|
||||
};
|
||||
@@ -90,7 +86,7 @@ pub fn set_active_opacity(window: &ApplicationWindow) {
|
||||
let value = if window.is_active() {
|
||||
ACTIVE_OPACITY
|
||||
} else {
|
||||
INACTIVE_OPACITY
|
||||
inactive_opacity
|
||||
};
|
||||
let scaled = (value * u32::MAX as f64).round() as u32;
|
||||
if let Err(error) = connection.change_property32(
|
||||
|
||||
Reference in New Issue
Block a user