Merge pull request #55 from pop-os/cleanup_jammy

Fix some warnings and clippy lints
This commit is contained in:
Ian Douglas Scott 2023-01-05 14:35:22 -08:00 committed by GitHub
commit b5371f58f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 133 additions and 111 deletions

5
Cargo.lock generated
View file

@ -602,7 +602,7 @@ dependencies = [
"libpulse-binding", "libpulse-binding",
"libpulse-glib-binding", "libpulse-glib-binding",
"logind-zbus", "logind-zbus",
"nix 0.24.3", "nix 0.26.1",
"smithay-client-toolkit", "smithay-client-toolkit",
"tokio", "tokio",
"zbus", "zbus",
@ -3968,6 +3968,7 @@ dependencies = [
"signal-hook-registry", "signal-hook-registry",
"socket2", "socket2",
"tokio-macros", "tokio-macros",
"tracing",
"windows-sys 0.42.0", "windows-sys 0.42.0",
] ]
@ -4803,6 +4804,7 @@ dependencies = [
"futures-sink", "futures-sink",
"futures-util", "futures-util",
"hex", "hex",
"lazy_static",
"nix 0.25.1", "nix 0.25.1",
"once_cell", "once_cell",
"ordered-stream", "ordered-stream",
@ -4811,6 +4813,7 @@ dependencies = [
"serde_repr", "serde_repr",
"sha1", "sha1",
"static_assertions", "static_assertions",
"tokio",
"tracing", "tracing",
"uds_windows", "uds_windows",
"winapi", "winapi",

View file

@ -271,11 +271,11 @@ impl Application for CosmicAppList {
Message::Toplevel(event) => { Message::Toplevel(event) => {
match event { match event {
ToplevelUpdate::AddToplevel(handle, info) => { ToplevelUpdate::AddToplevel(handle, info) => {
if info.app_id == "" { if info.app_id.is_empty() {
return Command::none(); return Command::none();
} }
if let Some(i) = self.toplevel_list.iter().position( if let Some(i) = self.toplevel_list.iter().position(
|Toplevel { desktop_info, .. }| &desktop_info.id == &info.app_id, |Toplevel { desktop_info, .. }| desktop_info.id == info.app_id,
) { ) {
self.toplevel_list[i].toplevels.push((handle, info)); self.toplevel_list[i].toplevels.push((handle, info));
} else { } else {
@ -309,7 +309,7 @@ impl Application for CosmicAppList {
desktop_info, desktop_info,
.. ..
}| { }| {
if let Some(ret) = toplevels.iter().position(|t| &t.0 == &handle) { if let Some(ret) = toplevels.iter().position(|t| t.0 == handle) {
toplevels.remove(ret); toplevels.remove(ret);
toplevels.is_empty() toplevels.is_empty()
&& !self.config.favorites.contains(&desktop_info.id) && !self.config.favorites.contains(&desktop_info.id)
@ -326,7 +326,7 @@ impl Application for CosmicAppList {
} }
ToplevelUpdate::UpdateToplevel(handle, info) => { ToplevelUpdate::UpdateToplevel(handle, info) => {
// TODO probably want to make sure it is removed // TODO probably want to make sure it is removed
if info.app_id == "" { if info.app_id.is_empty() {
return Command::none(); return Command::none();
} }
'toplevel_loop: for toplevel_list in &mut self.toplevel_list { 'toplevel_loop: for toplevel_list in &mut self.toplevel_list {
@ -351,12 +351,12 @@ impl Application for CosmicAppList {
Message::Exec(exec_str) => { Message::Exec(exec_str) => {
let mut exec = shlex::Shlex::new(&exec_str); let mut exec = shlex::Shlex::new(&exec_str);
let mut cmd = match exec.next() { let mut cmd = match exec.next() {
Some(cmd) if !cmd.contains("=") => tokio::process::Command::new(cmd), Some(cmd) if !cmd.contains('=') => tokio::process::Command::new(cmd),
_ => return Command::none(), _ => return Command::none(),
}; };
for arg in exec { for arg in exec {
// TODO handle "%" args here if necessary? // TODO handle "%" args here if necessary?
if !arg.starts_with("%") { if !arg.starts_with('%') {
cmd.arg(arg); cmd.arg(arg);
} }
} }
@ -398,7 +398,10 @@ impl Application for CosmicAppList {
desktop_info, desktop_info,
.. ..
}| { }| {
let cosmic_icon = cosmic::widget::icon(Path::new(&desktop_info.icon), self.applet_helper.suggested_size().0); let cosmic_icon = cosmic::widget::icon(
Path::new(&desktop_info.icon),
self.applet_helper.suggested_size().0,
);
// let icon = if desktop_info.icon.extension() == Some(&OsStr::new("svg")) { // let icon = if desktop_info.icon.extension() == Some(&OsStr::new("svg")) {
// svg::Handle::from_path(&desktop_info.icon); // svg::Handle::from_path(&desktop_info.icon);
// svg::Svg::new(handle) // svg::Svg::new(handle)
@ -433,22 +436,30 @@ impl Application for CosmicAppList {
.collect_vec(); .collect_vec();
dots.push(vertical_space(Length::Units(4)).into()); dots.push(vertical_space(Length::Units(4)).into());
let icon_wrapper = match &self.applet_helper.anchor { let icon_wrapper = match &self.applet_helper.anchor {
PanelAnchor::Left => row(vec![column(dots).spacing(4).into(), cosmic_icon.into()]) PanelAnchor::Left => {
.align_items(iced::Alignment::Center) row(vec![column(dots).spacing(4).into(), cosmic_icon.into()])
.spacing(4) .align_items(iced::Alignment::Center)
.into(), .spacing(4)
PanelAnchor::Right => row(vec![cosmic_icon.into(), column(dots).spacing(4).into()]) .into()
.align_items(iced::Alignment::Center) }
.spacing(4) PanelAnchor::Right => {
.into(), row(vec![cosmic_icon.into(), column(dots).spacing(4).into()])
PanelAnchor::Top => column(vec![row(dots).spacing(4).into(), cosmic_icon.into()]) .align_items(iced::Alignment::Center)
.align_items(iced::Alignment::Center) .spacing(4)
.spacing(4) .into()
.into(), }
PanelAnchor::Bottom => column(vec![cosmic_icon.into(), row(dots).spacing(4).into()]) PanelAnchor::Top => {
.align_items(iced::Alignment::Center) column(vec![row(dots).spacing(4).into(), cosmic_icon.into()])
.spacing(4) .align_items(iced::Alignment::Center)
.into(), .spacing(4)
.into()
}
PanelAnchor::Bottom => {
column(vec![cosmic_icon.into(), row(dots).spacing(4).into()])
.align_items(iced::Alignment::Center)
.spacing(4)
.into()
}
}; };
let mut icon_button = cosmic::widget::button(Button::Text) let mut icon_button = cosmic::widget::button(Button::Text)
.custom(vec![icon_wrapper]) .custom(vec![icon_wrapper])
@ -463,8 +474,10 @@ impl Application for CosmicAppList {
} }
// TODO tooltip on hover // TODO tooltip on hover
let icon_button = mouse_listener(icon_button.width(Length::Shrink).height(Length::Shrink)) let icon_button = mouse_listener(
.on_right_release(Message::Popup(desktop_info.id.clone())); icon_button.width(Length::Shrink).height(Length::Shrink),
)
.on_right_release(Message::Popup(desktop_info.id.clone()));
let icon_button = if let Some(tracker) = self.rectangle_tracker.as_ref() { let icon_button = if let Some(tracker) = self.rectangle_tracker.as_ref() {
tracker.container(*id, icon_button).into() tracker.container(*id, icon_button).into()
} else { } else {
@ -495,7 +508,9 @@ impl Application for CosmicAppList {
.align_items(Alignment::Center) .align_items(Alignment::Center)
.height(Length::Fill) .height(Length::Fill)
.width(Length::Fill), .width(Length::Fill),
).height(Length::Fill).width(Length::Fill), )
.height(Length::Fill)
.width(Length::Fill),
}; };
if self.popup.is_some() { if self.popup.is_some() {
mouse_listener(content) mouse_listener(content)
@ -554,19 +569,19 @@ impl Application for CosmicAppList {
.on_press(Message::Favorite(desktop_info.id.clone())) .on_press(Message::Favorite(desktop_info.id.clone()))
}); });
if toplevels.len() == 1 { content = match toplevels.len() {
content = content.push( 0 => content,
1 => content.push(
cosmic::widget::button(Button::Text) cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(fl!("quit")).into()]) .custom(vec![iced::widget::text(fl!("quit")).into()])
.on_press(Message::Quit(desktop_info.id.clone())), .on_press(Message::Quit(desktop_info.id.clone())),
) ),
} else if toplevels.len() > 1 { _ => content.push(
content = content.push(
cosmic::widget::button(Button::Text) cosmic::widget::button(Button::Text)
.custom(vec![iced::widget::text(&fl!("quit-all")).into()]) .custom(vec![iced::widget::text(&fl!("quit-all")).into()])
.on_press(Message::Quit(desktop_info.id.clone())), .on_press(Message::Quit(desktop_info.id.clone())),
) ),
} };
// return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style( // return Container::new(Container::new(content.width(Length::Shrink).height(Length::Shrink)).style(
// cosmic::Container::Custom(|theme| container::Appearance { // cosmic::Container::Custom(|theme| container::Appearance {
// text_color: Some(theme.cosmic().on_bg_color().into()), // text_color: Some(theme.cosmic().on_bg_color().into()),
@ -578,7 +593,7 @@ impl Application for CosmicAppList {
// )).into(); // )).into();
return self.applet_helper.popup_container(content).into(); return self.applet_helper.popup_container(content).into();
} }
return horizontal_space(Length::Units(1)).into(); horizontal_space(Length::Units(1)).into()
} }
} }
} }

View file

@ -38,10 +38,10 @@ async fn start_listening<I: Copy>(id: I, state: State) -> (Option<(I, ToplevelUp
std::thread::spawn(move || { std::thread::spawn(move || {
toplevel_handler(toplevel_tx, calloop_rx); toplevel_handler(toplevel_tx, calloop_rx);
}); });
return ( (
Some((id, ToplevelUpdate::Init(calloop_tx.clone()))), Some((id, ToplevelUpdate::Init(calloop_tx.clone()))),
State::Waiting(toplevel_rx, calloop_tx), State::Waiting(toplevel_rx, calloop_tx),
); )
} }
State::Waiting(mut rx, tx) => match rx.next().await { State::Waiting(mut rx, tx) => match rx.next().await {
Some(u) => (Some((id, u)), State::Waiting(rx, tx)), Some(u) => (Some((id, u)), State::Waiting(rx, tx)),

View file

@ -22,7 +22,7 @@ use iced::Color;
mod pulse; mod pulse;
use crate::pulse::DeviceInfo; use crate::pulse::DeviceInfo;
use libpulse_binding::volume::{Volume, VolumeLinear}; use libpulse_binding::volume::VolumeLinear;
pub fn main() -> cosmic::iced::Result { pub fn main() -> cosmic::iced::Result {
let helper = CosmicAppletHelper::default(); let helper = CosmicAppletHelper::default();
@ -134,7 +134,7 @@ impl Application for Audio {
if let Some(device) = &self.current_output { if let Some(device) = &self.current_output {
if let Some(name) = &device.name { if let Some(name) = &device.name {
connection.send(pulse::Message::SetSinkVolumeByName( connection.send(pulse::Message::SetSinkVolumeByName(
name.clone().to_string(), name.clone(),
device.volume, device.volume,
)) ))
} }
@ -151,7 +151,7 @@ impl Application for Audio {
if let Some(name) = &device.name { if let Some(name) = &device.name {
println!("increasing volume of {}", name); println!("increasing volume of {}", name);
connection.send(pulse::Message::SetSourceVolumeByName( connection.send(pulse::Message::SetSourceVolumeByName(
name.clone().to_string(), name.clone(),
device.volume, device.volume,
)) ))
} }
@ -241,28 +241,40 @@ impl Application for Audio {
self.current_output self.current_output
.as_ref() .as_ref()
.map(|o| o.volume.avg()) .map(|o| o.volume.avg())
.unwrap_or(Volume::default()), .unwrap_or_default(),
) )
.0 * 100.0; .0 * 100.0;
let in_f64 = VolumeLinear::from( let in_f64 = VolumeLinear::from(
self.current_input self.current_input
.as_ref() .as_ref()
.map(|o| o.volume.avg()) .map(|o| o.volume.avg())
.unwrap_or(Volume::default()), .unwrap_or_default(),
) )
.0 * 100.0; .0 * 100.0;
let sink = row![ let sink = row![
icon("audio-volume-high-symbolic", 64).width(Length::Units(24)).height(Length::Units(24)).style(Svg::SymbolicActive), icon("audio-volume-high-symbolic", 64)
slider(0.0..=100.0, out_f64, Message::SetOutputVolume).width(Length::FillPortion(5)), .width(Length::Units(24))
text(format!("{}%", out_f64.round())).width(Length::FillPortion(1)).horizontal_alignment(Horizontal::Right) .height(Length::Units(24))
.style(Svg::SymbolicActive),
slider(0.0..=100.0, out_f64, Message::SetOutputVolume)
.width(Length::FillPortion(5)),
text(format!("{}%", out_f64.round()))
.width(Length::FillPortion(1))
.horizontal_alignment(Horizontal::Right)
] ]
.spacing(10) .spacing(10)
.align_items(Alignment::Center); .align_items(Alignment::Center);
let source = row![ let source = row![
icon("audio-input-microphone-symbolic", 64).width(Length::Units(24)).height(Length::Units(24)).style(Svg::SymbolicActive), icon("audio-input-microphone-symbolic", 64)
slider(0.0..=100.0, in_f64, Message::SetInputVolume).width(Length::FillPortion(5)), .width(Length::Units(24))
text(format!("{}%", in_f64.round())).width(Length::FillPortion(1)).horizontal_alignment(Horizontal::Right) .height(Length::Units(24))
.style(Svg::SymbolicActive),
slider(0.0..=100.0, in_f64, Message::SetInputVolume)
.width(Length::FillPortion(5)),
text(format!("{}%", in_f64.round()))
.width(Length::FillPortion(1))
.horizontal_alignment(Horizontal::Right)
] ]
.spacing(10) .spacing(10)
.align_items(Alignment::Center); .align_items(Alignment::Center);
@ -322,14 +334,14 @@ fn spacer() -> iced::widget::Space {
Space::with_width(Length::Fill) Space::with_width(Length::Fill)
} }
fn revealer<'a>( fn revealer(
open: bool, open: bool,
title: &'a str, title: &str,
selected: String, selected: String,
options: Vec<String>, options: Vec<String>,
toggle: Message, toggle: Message,
_change: Message, _change: Message,
) -> widget::Column<'a, Message, Renderer> { ) -> widget::Column<Message, Renderer> {
if open { if open {
options.iter().fold( options.iter().fold(
column![revealer_head(open, title, selected, toggle)].width(Length::Fill), column![revealer_head(open, title, selected, toggle)].width(Length::Fill),
@ -340,9 +352,9 @@ fn revealer<'a>(
} }
} }
fn revealer_head<'a>( fn revealer_head(
_open: bool, _open: bool,
title: &'a str, title: &str,
selected: String, selected: String,
toggle: Message, toggle: Message,
) -> widget::Button<Message, Renderer> { ) -> widget::Button<Message, Renderer> {

View file

@ -8,7 +8,6 @@ use libpulse_binding::{
callbacks::ListResult, callbacks::ListResult,
context::{ context::{
introspect::{Introspector, SinkInfo, SourceInfo}, introspect::{Introspector, SinkInfo, SourceInfo},
subscribe::{Facility, InterestMaskSet, Operation},
Context, Context,
}, },
error::PAErr, error::PAErr,
@ -80,8 +79,7 @@ pub struct Connection(tokio::sync::mpsc::Sender<Message>);
impl Connection { impl Connection {
pub fn send(&mut self, message: Message) { pub fn send(&mut self, message: Message) {
let _ = self self.0
.0
.try_send(message) .try_send(message)
.expect("Send message to PulseAudio server"); .expect("Send message to PulseAudio server");
} }
@ -198,7 +196,7 @@ impl PulseHandle {
} }
fn blocking_send_disconnected(sender: &mut tokio::sync::mpsc::Sender<Message>) { fn blocking_send_disconnected(sender: &mut tokio::sync::mpsc::Sender<Message>) {
sender.blocking_send(Message::Disconnected); sender.blocking_send(Message::Disconnected).unwrap()
} }
fn blocking_send_connected(sender: &mut tokio::sync::mpsc::Sender<Message>) { fn blocking_send_connected(sender: &mut tokio::sync::mpsc::Sender<Message>) {
@ -209,6 +207,7 @@ impl PulseHandle {
sender.send(Message::Disconnected).await.unwrap() sender.send(Message::Disconnected).await.unwrap()
} }
#[allow(dead_code)]
async fn send_connected(sender: &mut tokio::sync::mpsc::Sender<Message>) { async fn send_connected(sender: &mut tokio::sync::mpsc::Sender<Message>) {
sender.send(Message::Connected).await.unwrap() sender.send(Message::Connected).await.unwrap()
} }
@ -258,7 +257,7 @@ impl PulseServer {
context context
.borrow_mut() .borrow_mut()
.connect(None, pulse::context::FlagSet::NOFLAGS, None) .connect(None, pulse::context::FlagSet::NOFLAGS, None)
.map_err(|e| PulseServerError::PAErr(e))?; .map_err(PulseServerError::PAErr)?;
Ok(PulseServer { Ok(PulseServer {
mainloop, mainloop,
@ -308,13 +307,11 @@ impl PulseServer {
} }
}, },
); );
self.wait_for_result(operation) self.wait_for_result(operation).and_then(|_| {
.and_then(|_| { list.borrow_mut().take().ok_or(PulseServerError::Misc(
list.borrow_mut().take().ok_or(PulseServerError::Misc( "get_sinks(): failed to wait for operation",
"get_sinks(): failed to wait for operation", ))
)) })
})
.and_then(|result| Ok(result))
} }
// Get a list of input devices // Get a list of input devices
@ -329,13 +326,11 @@ impl PulseServer {
} }
}, },
); );
self.wait_for_result(operation) self.wait_for_result(operation).and_then(|_| {
.and_then(|_| { list.borrow_mut().take().ok_or(PulseServerError::Misc(
list.borrow_mut().take().ok_or(PulseServerError::Misc( "get_sources(): Failed to wait for operation",
"get_sources(): Failed to wait for operation", ))
)) })
})
.and_then(|result| Ok(result))
} }
pub fn get_server_info(&mut self) -> Result<ServerInfo, PulseServerError> { pub fn get_server_info(&mut self) -> Result<ServerInfo, PulseServerError> {
@ -355,7 +350,7 @@ impl PulseServer {
let server_info = self.get_server_info(); let server_info = self.get_server_info();
match server_info { match server_info {
Ok(info) => { Ok(info) => {
let name = &info.default_sink_name.unwrap_or(String::new()); let name = &info.default_sink_name.unwrap_or_default();
let device = Rc::new(RefCell::new(Some(None))); let device = Rc::new(RefCell::new(Some(None)));
let dev_ref = device.clone(); let dev_ref = device.clone();
let op = self.introspector.get_sink_info_by_name( let op = self.introspector.get_sink_info_by_name(
@ -368,7 +363,7 @@ impl PulseServer {
); );
self.wait_for_result(op)?; self.wait_for_result(op)?;
let mut result = device.borrow_mut(); let mut result = device.borrow_mut();
result.take().unwrap().ok_or_else(|| { result.take().unwrap().ok_or({
PulseServerError::Misc("get_default_sink(): Error getting requested device") PulseServerError::Misc("get_default_sink(): Error getting requested device")
}) })
} }
@ -380,7 +375,7 @@ impl PulseServer {
let server_info = self.get_server_info(); let server_info = self.get_server_info();
match server_info { match server_info {
Ok(info) => { Ok(info) => {
let name = &info.default_source_name.unwrap_or(String::new()); let name = &info.default_source_name.unwrap_or_default();
let device = Rc::new(RefCell::new(Some(None))); let device = Rc::new(RefCell::new(Some(None)));
let dev_ref = device.clone(); let dev_ref = device.clone();
let op = self.introspector.get_source_info_by_name( let op = self.introspector.get_source_info_by_name(
@ -393,7 +388,7 @@ impl PulseServer {
); );
self.wait_for_result(op)?; self.wait_for_result(op)?;
let mut result = device.borrow_mut(); let mut result = device.borrow_mut();
result.take().unwrap().ok_or_else(|| { result.take().unwrap().ok_or({
PulseServerError::Misc("get_default_source(): Error getting requested device") PulseServerError::Misc("get_default_source(): Error getting requested device")
}) })
} }

View file

@ -8,7 +8,7 @@ once_cell = "1.16.0"
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" } sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" }
futures = "0.3" futures = "0.3"
zbus = { version = "3.5", no-default-features = true } zbus = { version = "3.5", default-features = false, features = ["tokio"] }
log = "0.4" log = "0.4"
pretty_env_logger = "0.4" pretty_env_logger = "0.4"
# Application i18n # Application i18n

View file

@ -111,7 +111,7 @@ impl Application for CosmicBatteryApplet {
} }
} }
Message::SetScreenBrightness(brightness) => { Message::SetScreenBrightness(brightness) => {
self.screen_brightness = (brightness as f64 / 100.0).max(0.01).min(1.0); self.screen_brightness = (brightness as f64 / 100.0).clamp(0.01, 1.0);
if let Some(tx) = &self.screen_sender { if let Some(tx) = &self.screen_sender {
let _ = tx.send(ScreenBacklightRequest::Set(self.screen_brightness)); let _ = tx.send(ScreenBacklightRequest::Set(self.screen_brightness));
} }

View file

@ -114,10 +114,10 @@ async fn start_listening<I: Copy>(
let b = (backlight.brightness().await.unwrap_or_default() as f64 let b = (backlight.brightness().await.unwrap_or_default() as f64
/ backlight.max_brightness().await.unwrap_or(1) as f64) / backlight.max_brightness().await.unwrap_or(1) as f64)
.clamp(0., 1.); .clamp(0., 1.);
return ( (
Some((id, ScreenBacklightUpdate::Init(tx, b))), Some((id, ScreenBacklightUpdate::Init(tx, b))),
State::Waiting(backlight, screen_proxy, rx), State::Waiting(backlight, screen_proxy, rx),
); )
} }
State::Waiting(backlight, proxy, mut rx) => match rx.recv().await { State::Waiting(backlight, proxy, mut rx) => match rx.recv().await {
Some(req) => match req { Some(req) => match req {

View file

@ -199,7 +199,7 @@ async fn start_listening<I: Copy>(id: I, state: State) -> (Option<(I, DeviceDbus
State::Waiting(device), State::Waiting(device),
); );
} }
return (None, State::Finished); (None, State::Finished)
} }
State::Waiting(device) => { State::Waiting(device) => {
let mut stream = futures::stream_select!( let mut stream = futures::stream_select!(

View file

@ -66,10 +66,10 @@ async fn start_listening<I: Copy>(
let b = kbd_proxy.get_brightness().await.unwrap_or_default() as f64 let b = kbd_proxy.get_brightness().await.unwrap_or_default() as f64
/ kbd_proxy.get_max_brightness().await.unwrap_or(1) as f64; / kbd_proxy.get_max_brightness().await.unwrap_or(1) as f64;
return ( (
Some((id, KeyboardBacklightUpdate::Init(tx, b))), Some((id, KeyboardBacklightUpdate::Init(tx, b))),
State::Waiting(kbd_proxy, rx), State::Waiting(kbd_proxy, rx),
); )
} }
State::Waiting(proxy, mut rx) => match rx.recv().await { State::Waiting(proxy, mut rx) => match rx.recv().await {
Some(req) => match req { Some(req) => match req {

View file

@ -79,13 +79,13 @@ impl Application for Window {
let mut window = Window::default(); let mut window = Window::default();
let pixels = std::env::var("COSMIC_PANEL_SIZE") let pixels = std::env::var("COSMIC_PANEL_SIZE")
.ok() .ok()
.and_then(|size| match size.parse::<PanelSize>() { .map(|size| match size.parse::<PanelSize>() {
Ok(PanelSize::XL) => Some(64), Ok(PanelSize::XL) => 64,
Ok(PanelSize::L) => Some(36), Ok(PanelSize::L) => 36,
Ok(PanelSize::M) => Some(24), Ok(PanelSize::M) => 24,
Ok(PanelSize::S) => Some(16), Ok(PanelSize::S) => 16,
Ok(PanelSize::XS) => Some(12), Ok(PanelSize::XS) => 12,
Err(_) => Some(12), Err(_) => 12,
}) })
.unwrap_or(16); .unwrap_or(16);
window.icon_size = pixels; window.icon_size = pixels;
@ -96,10 +96,7 @@ impl Application for Window {
Err(_) => PanelAnchor::Top, Err(_) => PanelAnchor::Top,
}) })
.unwrap_or(PanelAnchor::Top); .unwrap_or(PanelAnchor::Top);
( (window, Command::perform(dbus::init(), Message::DBusInit))
window,
Command::perform(dbus::init(), |dbus_init| Message::DBusInit(dbus_init)),
)
} }
fn title(&self) -> String { fn title(&self) -> String {
@ -202,28 +199,28 @@ impl Application for Window {
"Integrated Graphics", "Integrated Graphics",
Graphics::Integrated, Graphics::Integrated,
self.graphics_mode.map(|g| g.inner()), self.graphics_mode.map(|g| g.inner()),
|g| Message::SelectGraphicsMode(g), Message::SelectGraphicsMode,
) )
.into(), .into(),
radio( radio(
"Nvidia Graphics", "Nvidia Graphics",
Graphics::Nvidia, Graphics::Nvidia,
self.graphics_mode.map(|g| g.inner()), self.graphics_mode.map(|g| g.inner()),
|g| Message::SelectGraphicsMode(g), Message::SelectGraphicsMode,
) )
.into(), .into(),
radio( radio(
"Hybrid Graphics", "Hybrid Graphics",
Graphics::Hybrid, Graphics::Hybrid,
self.graphics_mode.map(|g| g.inner()), self.graphics_mode.map(|g| g.inner()),
|g| Message::SelectGraphicsMode(g), Message::SelectGraphicsMode,
) )
.into(), .into(),
radio( radio(
"Compute Graphics", "Compute Graphics",
Graphics::Compute, Graphics::Compute,
self.graphics_mode.map(|g| g.inner()), self.graphics_mode.map(|g| g.inner()),
|g| Message::SelectGraphicsMode(g), Message::SelectGraphicsMode,
) )
.into(), .into(),
]; ];

View file

@ -11,7 +11,7 @@ libpulse-glib-binding = "2.25.0"
tokio = { version = "1.20.1", features=["full"] } tokio = { version = "1.20.1", features=["full"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] } libcosmic = { git = "https://github.com/pop-os/libcosmic/", branch = "master", default-features = false, features = ["wayland", "applet"] }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" } sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/client-toolkit", rev = "3776d4a" }
nix = "0.24.1" nix = "0.26.1"
# Until the 3.6.3 release, need the implementation of clone on zbus::Error # Until the 3.6.3 release, need the implementation of clone on zbus::Error
[dependencies.zbus] [dependencies.zbus]

View file

@ -23,14 +23,16 @@ use crate::wayland::{WorkspaceEvent, WorkspaceList};
use crate::wayland_subscription::{workspaces, WorkspacesUpdate}; use crate::wayland_subscription::{workspaces, WorkspacesUpdate};
pub fn run() -> cosmic::iced::Result { pub fn run() -> cosmic::iced::Result {
let mut settings = Settings::default(); let settings = Settings {
settings.initial_surface = InitialSurface::XdgWindow(SctkWindowSettings { initial_surface: InitialSurface::XdgWindow(SctkWindowSettings {
iced_settings: cosmic::iced_native::window::Settings { iced_settings: cosmic::iced_native::window::Settings {
size: (32, 32), size: (32, 32),
..Default::default()
},
..Default::default() ..Default::default()
}, }),
..Default::default() ..Default::default()
}); };
IcedWorkspacesApplet::run(settings) IcedWorkspacesApplet::run(settings)
} }

View file

@ -117,12 +117,10 @@ pub fn spawn_workspaces(tx: mpsc::Sender<WorkspaceList>) -> SyncSender<Workspace
} else { } else {
w_i.wrapping_add(1) w_i.wrapping_add(1)
} }
} else if w_i == 0 {
max_w
} else { } else {
if w_i == 0 { w_i.wrapping_sub(1)
max_w
} else {
w_i.wrapping_sub(1)
}
}; };
if let Some(w) = w_g.workspaces.get(d_i) { if let Some(w) = w_g.workspaces.get(d_i) {
w.handle.activate(); w.handle.activate();