add linting CI jobs
This commit is contained in:
parent
9974b2f99f
commit
aa2d9fe374
12 changed files with 98 additions and 68 deletions
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
29
.github/workflows/ci.yml
vendored
Normal file
29
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
name: Continuous Integration
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
formatting:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@nightly
|
||||||
|
with:
|
||||||
|
components: rustfmt
|
||||||
|
- name: Run rustfmt
|
||||||
|
run: cargo +nightly fmt --all -- --check
|
||||||
|
|
||||||
|
linting:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@master
|
||||||
|
with:
|
||||||
|
toolchain: nightly-2023-11-18
|
||||||
|
components: clippy
|
||||||
|
- name: install dependencies
|
||||||
|
run: sudo apt install -y libxkbcommon-dev libwayland-dev libdbus-1-dev libpulse-dev
|
||||||
|
- uses: actions-rs-plus/clippy-check@v2
|
||||||
|
with:
|
||||||
|
toolchain: nightly-2023-11-18
|
||||||
|
args: --all --all-targets --all-features
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -14,7 +14,7 @@ build-aux/.flatpak-builder/
|
||||||
flatpak_app
|
flatpak_app
|
||||||
.flatpak-builder
|
.flatpak-builder
|
||||||
|
|
||||||
.*
|
.vscode/
|
||||||
debian/*
|
debian/*
|
||||||
!debian/*install
|
!debian/*install
|
||||||
!debian/*postinst
|
!debian/*postinst
|
||||||
|
|
|
||||||
|
|
@ -336,9 +336,7 @@ fn index_in_list(
|
||||||
}
|
}
|
||||||
let total_len = list_len as f32 * (item_size + divider_size) - divider_size;
|
let total_len = list_len as f32 * (item_size + divider_size) - divider_size;
|
||||||
let pos_in_list = pos_in_list * total_len;
|
let pos_in_list = pos_in_list * total_len;
|
||||||
let index = if list_len == 0 {
|
let index = if (list_len == 0) || (pos_in_list < item_size / 2.0) {
|
||||||
0
|
|
||||||
} else if pos_in_list < item_size / 2.0 {
|
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
let mut i = 1;
|
let mut i = 1;
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ pub struct PlayerStatus {
|
||||||
impl PlayerStatus {
|
impl PlayerStatus {
|
||||||
async fn new(player: Player) -> Self {
|
async fn new(player: Player) -> Self {
|
||||||
let metadata = player.metadata().await.unwrap();
|
let metadata = player.metadata().await.unwrap();
|
||||||
let title = metadata.title().map(|t| Cow::from(t));
|
let title = metadata.title().map(Cow::from);
|
||||||
let artists = metadata
|
let artists = metadata
|
||||||
.artists()
|
.artists()
|
||||||
.map(|a| a.into_iter().map(|a| Cow::from(a)).collect::<Vec<_>>());
|
.map(|a| a.into_iter().map(Cow::from).collect::<Vec<_>>());
|
||||||
let icon = metadata
|
let icon = metadata
|
||||||
.art_url()
|
.art_url()
|
||||||
.and_then(|u| url::Url::parse(&u).ok())
|
.and_then(|u| url::Url::parse(&u).ok())
|
||||||
|
|
@ -53,7 +53,7 @@ impl PlayerStatus {
|
||||||
icon,
|
icon,
|
||||||
title,
|
title,
|
||||||
artists,
|
artists,
|
||||||
status: playback_status.unwrap_or_else(|_| PlaybackStatus::Stopped),
|
status: playback_status.unwrap_or(PlaybackStatus::Stopped),
|
||||||
can_pause: can_pause.unwrap_or_default(),
|
can_pause: can_pause.unwrap_or_default(),
|
||||||
can_play: can_play.unwrap_or_default(),
|
can_play: can_play.unwrap_or_default(),
|
||||||
can_go_previous: can_go_previous.unwrap_or_default(),
|
can_go_previous: can_go_previous.unwrap_or_default(),
|
||||||
|
|
@ -109,33 +109,32 @@ async fn update(state: State, output: &mut futures::channel::mpsc::Sender<MprisU
|
||||||
.unwrap_or_else(|_| Vec::new());
|
.unwrap_or_else(|_| Vec::new());
|
||||||
if players.is_empty() {
|
if players.is_empty() {
|
||||||
let Ok(dbus) = zbus::fdo::DBusProxy::builder(&conn)
|
let Ok(dbus) = zbus::fdo::DBusProxy::builder(&conn)
|
||||||
.path("/org/freedesktop/DBus").unwrap()
|
.path("/org/freedesktop/DBus")
|
||||||
|
.unwrap()
|
||||||
.build()
|
.build()
|
||||||
.await else {
|
.await
|
||||||
tracing::error!("Failed to create dbus proxy.");
|
else {
|
||||||
return State::Finished;
|
tracing::error!("Failed to create dbus proxy.");
|
||||||
};
|
return State::Finished;
|
||||||
loop {
|
};
|
||||||
let Ok(mut stream) = dbus.receive_name_owner_changed().await else {
|
let Ok(mut stream) = dbus.receive_name_owner_changed().await else {
|
||||||
tracing::error!("Failed to receive name owner changed signal.");
|
tracing::error!("Failed to receive name owner changed signal.");
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||||
// restart from the beginning
|
// restart from the beginning
|
||||||
return State::Setup;
|
return State::Setup;
|
||||||
};
|
};
|
||||||
while let Some(c) = stream.next().await {
|
while let Some(c) = stream.next().await {
|
||||||
if let Ok(args) = c.args() {
|
if let Ok(args) = c.args() {
|
||||||
if args.name.contains("org.mpris.MediaPlayer2") {
|
if args.name.contains("org.mpris.MediaPlayer2") {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Ok(p) = mpris2_zbus::media_player::MediaPlayer::new_all(&conn).await {
|
}
|
||||||
players = p;
|
if let Ok(p) = mpris2_zbus::media_player::MediaPlayer::new_all(&conn).await {
|
||||||
break;
|
players = p;
|
||||||
} else {
|
} else {
|
||||||
// restart from the beginning
|
// restart from the beginning
|
||||||
return State::Setup;
|
return State::Setup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ impl PulseHandle {
|
||||||
// Create pulse server thread, and bidirectional comms
|
// Create pulse server thread, and bidirectional comms
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (to_pulse, mut to_pulse_recv) = tokio::sync::mpsc::channel(10);
|
let (to_pulse, mut to_pulse_recv) = tokio::sync::mpsc::channel(10);
|
||||||
let (mut from_pulse_send, from_pulse) = tokio::sync::mpsc::channel(10);
|
let (from_pulse_send, from_pulse) = tokio::sync::mpsc::channel(10);
|
||||||
// get initial connection status
|
// get initial connection status
|
||||||
to_pulse
|
to_pulse
|
||||||
.try_send(Message::UpdateConnection)
|
.try_send(Message::UpdateConnection)
|
||||||
|
|
@ -195,7 +195,7 @@ impl PulseHandle {
|
||||||
.send(Message::SetDefaultSink(sink))
|
.send(Message::SetDefaultSink(sink))
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Err(_) => Self::send_disconnected(&mut from_pulse_send).await,
|
Err(_) => Self::send_disconnected(&from_pulse_send).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::GetDefaultSource => {
|
Message::GetDefaultSource => {
|
||||||
|
|
@ -210,7 +210,7 @@ impl PulseHandle {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("ERROR! {:?}", e);
|
tracing::error!("ERROR! {:?}", e);
|
||||||
Self::send_disconnected(&mut from_pulse_send).await;
|
Self::send_disconnected(&from_pulse_send).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ impl PulseHandle {
|
||||||
.send(Message::SetSinks(sinks))
|
.send(Message::SetSinks(sinks))
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Err(_) => Self::send_disconnected(&mut from_pulse_send).await,
|
Err(_) => Self::send_disconnected(&from_pulse_send).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::GetSources => {
|
Message::GetSources => {
|
||||||
|
|
@ -237,7 +237,7 @@ impl PulseHandle {
|
||||||
.send(Message::SetSources(sinks))
|
.send(Message::SetSources(sinks))
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
Err(_) => Self::send_disconnected(&mut from_pulse_send).await,
|
Err(_) => Self::send_disconnected(&from_pulse_send).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::SetSinkVolumeByName(name, channel_volumes) => {
|
Message::SetSinkVolumeByName(name, channel_volumes) => {
|
||||||
|
|
@ -263,7 +263,7 @@ impl PulseHandle {
|
||||||
tracing::trace!("getting server info...");
|
tracing::trace!("getting server info...");
|
||||||
if cur_server.get_server_info().is_err() {
|
if cur_server.get_server_info().is_err() {
|
||||||
tracing::warn!("got error, server must be disconnected...");
|
tracing::warn!("got error, server must be disconnected...");
|
||||||
Self::send_disconnected(&mut from_pulse_send).await;
|
Self::send_disconnected(&from_pulse_send).await;
|
||||||
} else {
|
} else {
|
||||||
tracing::trace!("got server info, still connected...");
|
tracing::trace!("got server info, still connected...");
|
||||||
server = Some(cur_server);
|
server = Some(cur_server);
|
||||||
|
|
@ -272,7 +272,7 @@ impl PulseHandle {
|
||||||
match PulseServer::connect().and_then(|server| server.init()) {
|
match PulseServer::connect().and_then(|server| server.init()) {
|
||||||
Ok(new_server) => {
|
Ok(new_server) => {
|
||||||
tracing::info!("Connected to server");
|
tracing::info!("Connected to server");
|
||||||
Self::send_connected(&mut from_pulse_send).await;
|
Self::send_connected(&from_pulse_send).await;
|
||||||
server = Some(new_server);
|
server = Some(new_server);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
||||||
|
|
@ -63,15 +63,15 @@ impl NewConnectionState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<AccessPoint> for NewConnectionState {
|
impl From<NewConnectionState> for AccessPoint {
|
||||||
fn into(self) -> AccessPoint {
|
fn from(connection_state: NewConnectionState) -> Self {
|
||||||
match self {
|
match connection_state {
|
||||||
Self::EnterPassword {
|
NewConnectionState::EnterPassword {
|
||||||
access_point,
|
access_point,
|
||||||
password: _,
|
password: _,
|
||||||
} => access_point,
|
} => access_point,
|
||||||
Self::Waiting(access_point) => access_point,
|
NewConnectionState::Waiting(access_point) => access_point,
|
||||||
Self::Failure(access_point) => access_point,
|
NewConnectionState::Failure(access_point) => access_point,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub async fn active_connections(
|
||||||
let state = connection
|
let state = connection
|
||||||
.state()
|
.state()
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|_| ActiveConnectionState::Unknown);
|
.unwrap_or(ActiveConnectionState::Unknown);
|
||||||
|
|
||||||
if connection.vpn().await.unwrap_or_default() {
|
if connection.vpn().await.unwrap_or_default() {
|
||||||
info.push(ActiveConnectionInfo::Vpn {
|
info.push(ActiveConnectionInfo::Vpn {
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,7 @@ impl cosmic::Application for App {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
status_notifier_watcher::Event::Unregistered(name) => {
|
status_notifier_watcher::Event::Unregistered(name) => {
|
||||||
if let Some((id, _)) =
|
if let Some((id, _)) = self.menus.iter().find(|(_id, menu)| menu.name() == name)
|
||||||
self.menus.iter().find(|(_id, menu)| menu.name() == &name)
|
|
||||||
{
|
{
|
||||||
let id = *id;
|
let id = *id;
|
||||||
self.menus.remove(&id);
|
self.menus.remove(&id);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use std::time::Instant;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
const ID: &str = "com.system76.CosmicAppletTiling";
|
const ID: &str = "com.system76.CosmicAppletTiling";
|
||||||
const ON: &str = "com.system76.CosmicAppletTiling.On";
|
//const ON: &str = "com.system76.CosmicAppletTiling.On";
|
||||||
const OFF: &str = "com.system76.CosmicAppletTiling.Off";
|
const OFF: &str = "com.system76.CosmicAppletTiling.Off";
|
||||||
|
|
||||||
static TILE_WINDOWS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
|
static TILE_WINDOWS: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ impl cosmic::Application for IcedWorkspacesApplet {
|
||||||
cosmic::theme::iced::Button::Primary
|
cosmic::theme::iced::Button::Primary
|
||||||
}
|
}
|
||||||
Some(zcosmic_workspace_handle_v1::State::Urgent) => {
|
Some(zcosmic_workspace_handle_v1::State::Urgent) => {
|
||||||
let appearence = |theme: &Theme| button::Appearance {
|
let appearance = |theme: &Theme| button::Appearance {
|
||||||
background: Some(Background::Color(
|
background: Some(Background::Color(
|
||||||
theme.cosmic().palette.neutral_3.into(),
|
theme.cosmic().palette.neutral_3.into(),
|
||||||
)),
|
)),
|
||||||
|
|
@ -167,29 +167,29 @@ impl cosmic::Application for IcedWorkspacesApplet {
|
||||||
..button::Appearance::default()
|
..button::Appearance::default()
|
||||||
};
|
};
|
||||||
cosmic::theme::iced::Button::Custom {
|
cosmic::theme::iced::Button::Custom {
|
||||||
active: Box::new(appearence),
|
active: Box::new(appearance),
|
||||||
hover: Box::new(move |theme| button::Appearance {
|
hover: Box::new(move |theme| button::Appearance {
|
||||||
background: Some(Background::Color(
|
background: Some(Background::Color(
|
||||||
theme.current_container().component.hover.into(),
|
theme.current_container().component.hover.into(),
|
||||||
)),
|
)),
|
||||||
..appearence(theme)
|
..appearance(theme)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let appearence = |theme: &Theme| button::Appearance {
|
let appearance = |theme: &Theme| button::Appearance {
|
||||||
background: None,
|
background: None,
|
||||||
border_radius: theme.cosmic().radius_xl().into(),
|
border_radius: theme.cosmic().radius_xl().into(),
|
||||||
text_color: theme.current_container().component.on.into(),
|
text_color: theme.current_container().component.on.into(),
|
||||||
..button::Appearance::default()
|
..button::Appearance::default()
|
||||||
};
|
};
|
||||||
cosmic::theme::iced::Button::Custom {
|
cosmic::theme::iced::Button::Custom {
|
||||||
active: Box::new(appearence),
|
active: Box::new(appearance),
|
||||||
hover: Box::new(move |theme| button::Appearance {
|
hover: Box::new(move |theme| button::Appearance {
|
||||||
background: Some(Background::Color(
|
background: Some(Background::Color(
|
||||||
theme.current_container().component.hover.into(),
|
theme.current_container().component.hover.into(),
|
||||||
)),
|
)),
|
||||||
..appearence(theme)
|
..appearance(theme)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,23 +71,22 @@ pub fn main() -> iced::Result {
|
||||||
path.push(&filename);
|
path.push(&filename);
|
||||||
if let Ok(bytes) = fs::read_to_string(&path) {
|
if let Ok(bytes) = fs::read_to_string(&path) {
|
||||||
if let Ok(entry) = DesktopEntry::decode(&path, &bytes) {
|
if let Ok(entry) = DesktopEntry::decode(&path, &bytes) {
|
||||||
desktop = Some(Desktop {
|
desktop =
|
||||||
name: entry
|
Some(Desktop {
|
||||||
.name(None)
|
name: entry.name(None).map(|x| x.to_string()).unwrap_or_else(|| {
|
||||||
.map(|x| x.to_string())
|
panic!("Desktop file '{filename}' doesn't have `Name`")
|
||||||
.expect(&format!("Desktop file '{filename}' doesn't have `Name`")),
|
}),
|
||||||
icon: entry.icon().map(|x| x.to_string()),
|
icon: entry.icon().map(|x| x.to_string()),
|
||||||
exec: entry
|
exec: entry.exec().map(|x| x.to_string()).unwrap_or_else(|| {
|
||||||
.exec()
|
panic!("Desktop file '{filename}' doesn't have `Exec`")
|
||||||
.map(|x| x.to_string())
|
}),
|
||||||
.expect(&format!("Desktop file '{filename}' doesn't have `Exec`")),
|
});
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let desktop = desktop.expect(&format!(
|
let desktop = desktop.unwrap_or_else(|| {
|
||||||
"Failed to find valid desktop file '{filename}' in search paths"
|
panic!("Failed to find valid desktop file '{filename}' in search paths")
|
||||||
));
|
});
|
||||||
cosmic::applet::run::<Button>(true, desktop)
|
cosmic::applet::run::<Button>(true, desktop)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue