Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "surface"
version = "0.4.10"
version = "0.4.11"
authors = ["Maximilian Luz <luzmaximilian@gmail.com>"]
description = "Control various aspects of Microsoft Surface devices on Linux from the Command-Line"

Expand Down
5 changes: 4 additions & 1 deletion pkg/fedora/surface-control.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: surface-control
Version: 0.4.10
Version: 0.4.11
Release: 1%{?dist}
Summary: Control various aspects of Microsoft Surface devices from the shell

Expand Down Expand Up @@ -39,6 +39,9 @@ install -D -m644 "target/surface.fish" "%{buildroot}/usr/share/fish/vendor_compl
/usr/share/fish/vendor_completions.d/surface.fish

%changelog
* Sat Jan 03 2026 Vandevenne Timo <timovdvenne@gmail.com> - 0.4.11-1
- Update to 0.4.11

* Tue Dec 30 2025 Maximilian Luz <luzmaximilian@gmail.com> - 0.4.10-1
- Update dependencies

Expand Down
34 changes: 34 additions & 0 deletions src/cli/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ impl DynCommand for Command {
.about("Get the current platform profile"))
.subcommand(clap::Command::new("list")
.about("List all available platform profiles"))
.subcommand(clap::Command::new("cycle")
.about("Cycle to the next platform profile"))
}

fn execute(&self, m: &clap::ArgMatches) -> Result<()> {
match m.subcommand() {
Some(("set", m)) => self.profile_set(m),
Some(("get", m)) => self.profile_get(m),
Some(("list", m)) => self.profile_list(m),
Some(("cycle", m)) => self.profile_cycle(m),
_ => unreachable!(),
}
}
Expand Down Expand Up @@ -104,4 +107,35 @@ impl Command {

Ok(())
}

fn profile_cycle(&self, m: &clap::ArgMatches) -> Result<()> {
let dev = sys::profile::Device::open()
.context("Failed to open platform profile device")?;

let supported = dev.get_supported()
.context("Failed to get supported platform profiles")?;

if supported.is_empty() {
anyhow::bail!("No platform profiles available");
}

let current_profile = dev.get()
.context("Failed to get current platform profile")?;

// Find the next profile in the list, wrapping around to the start
let next_profile = supported.iter()
.cycle()
.skip_while(|&p| p != &current_profile)
.nth(1)
.unwrap_or(&supported[0]);

dev.set(next_profile)
.context("Failed to set platform profile")?;

if !m.get_flag("quiet") {
println!("Platform profile cycled from '{current_profile}' to '{next_profile}'");
}

Ok(())
}
}