mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 06:11:03 +02:00
refactor: update to rust 2024, fix strict clippy warnings
This commit is contained in:
parent
79c917857c
commit
202c19efd4
57 changed files with 132 additions and 124 deletions
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "ironbar"
|
||||
version = "0.16.1"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
description = "Customisable GTK Layer Shell wlroots/sway bar"
|
||||
repository = "https://github.com/jakestanger/ironbar"
|
||||
|
|
2
build.rs
2
build.rs
|
@ -22,8 +22,8 @@ mod ipc {
|
|||
|
||||
use clap::Command;
|
||||
use clap::CommandFactory;
|
||||
use clap_complete::generate_to;
|
||||
use clap_complete::Shell::{Bash, Fish, Zsh};
|
||||
use clap_complete::generate_to;
|
||||
use cli::Args;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::Ironbar;
|
||||
use crate::config::{BarConfig, BarPosition, MarginConfig, ModuleConfig};
|
||||
use crate::modules::{BarModuleFactory, ModuleInfo, ModuleLocation};
|
||||
use crate::popup::Popup;
|
||||
use crate::Ironbar;
|
||||
use color_eyre::Result;
|
||||
use glib::Propagation;
|
||||
use gtk::gdk::Monitor;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::wayland::{self, ClipboardItem};
|
||||
use crate::{arc_mut, lock, register_client, spawn, try_send};
|
||||
use indexmap::map::Iter;
|
||||
use indexmap::IndexMap;
|
||||
use indexmap::map::Iter;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, trace};
|
||||
|
|
|
@ -10,7 +10,7 @@ use hyprland::dispatch::{Dispatch, DispatchType, WorkspaceIdentifierWithSpecial}
|
|||
use hyprland::event_listener::EventListener;
|
||||
use hyprland::prelude::*;
|
||||
use hyprland::shared::{HyprDataVec, WorkspaceType};
|
||||
use tokio::sync::broadcast::{channel, Receiver, Sender};
|
||||
use tokio::sync::broadcast::{Receiver, Sender, channel};
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -250,7 +250,7 @@ impl Client {
|
|||
//
|
||||
// Here we are trying to recover `layout_name` from `keyboard_name`
|
||||
|
||||
let layout = layout_event.keyboard_name.as_str().split(",").nth(1);
|
||||
let layout = layout_event.keyboard_name.as_str().split(',').nth(1);
|
||||
let Some(layout) = layout else {
|
||||
error!(
|
||||
"Failed to get layout from string: {}. The failed logic is a workaround for a bug in `hyprland 0.4.0-alpha.3`", layout_event.keyboard_name);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::clients::ClientResult;
|
||||
use crate::register_fallible_client;
|
||||
use cfg_if::cfg_if;
|
||||
use color_eyre::{Help, Report, Result};
|
||||
|
@ -67,7 +68,7 @@ impl Compositor {
|
|||
|
||||
pub fn create_keyboard_layout_client(
|
||||
clients: &mut super::Clients,
|
||||
) -> Result<Arc<dyn KeyboardLayoutClient + Send + Sync>> {
|
||||
) -> ClientResult<dyn KeyboardLayoutClient + Send + Sync> {
|
||||
let current = Self::get_current();
|
||||
debug!("Getting keyboard_layout client for: {current}");
|
||||
match current {
|
||||
|
@ -76,9 +77,7 @@ impl Compositor {
|
|||
.sway()
|
||||
.map(|client| client as Arc<dyn KeyboardLayoutClient + Send + Sync>),
|
||||
#[cfg(feature = "keyboard+hyprland")]
|
||||
Self::Hyprland => clients
|
||||
.hyprland()
|
||||
.map(|client| client as Arc<dyn KeyboardLayoutClient + Send + Sync>),
|
||||
Self::Hyprland => Ok(clients.hyprland()),
|
||||
Self::Niri | Self::Unsupported => Err(Report::msg("Unsupported compositor").note(
|
||||
"Currently keyboard layout functionality are only supported by Sway and Hyprland",
|
||||
)),
|
||||
|
@ -98,9 +97,7 @@ impl Compositor {
|
|||
.sway()
|
||||
.map(|client| client as Arc<dyn WorkspaceClient + Send + Sync>),
|
||||
#[cfg(feature = "workspaces+hyprland")]
|
||||
Self::Hyprland => clients
|
||||
.hyprland()
|
||||
.map(|client| client as Arc<dyn WorkspaceClient + Send + Sync>),
|
||||
Self::Hyprland => Ok(clients.hyprland()),
|
||||
#[cfg(feature = "workspaces+niri")]
|
||||
Self::Niri => Ok(Arc::new(niri::Client::new())),
|
||||
Self::Unsupported => Err(Report::msg("Unsupported compositor")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// to reduce compile times.
|
||||
use crate::clients::compositor::Workspace as IronWorkspace;
|
||||
use crate::{await_sync, clients::compositor::Visibility};
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
use color_eyre::eyre::{Result, eyre};
|
||||
use core::str;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{env, path::Path};
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::clients::sway::Client;
|
|||
use crate::{await_sync, error, send, spawn};
|
||||
use color_eyre::Report;
|
||||
use swayipc_async::{InputChange, InputEvent, Node, WorkspaceChange, WorkspaceEvent};
|
||||
use tokio::sync::broadcast::{channel, Receiver};
|
||||
use tokio::sync::broadcast::{Receiver, channel};
|
||||
|
||||
impl WorkspaceClient for Client {
|
||||
fn focus(&self, id: i64) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{arc_rw, read_lock, send, spawn, spawn_blocking, write_lock};
|
||||
use color_eyre::{Report, Result};
|
||||
use evdev_rs::enums::{int_to_ev_key, EventCode, EV_KEY, EV_LED};
|
||||
use evdev_rs::DeviceWrapper;
|
||||
use evdev_rs::enums::{EV_KEY, EV_LED, EventCode, int_to_ev_key};
|
||||
use input::event::keyboard::{KeyState, KeyboardEventTrait};
|
||||
use input::event::{DeviceEvent, EventTrait, KeyboardEvent};
|
||||
use input::{DeviceCapability, Libinput, LibinputInterface};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{await_sync, Ironbar};
|
||||
use crate::{Ironbar, await_sync};
|
||||
use color_eyre::Result;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
@ -129,16 +129,14 @@ impl Clients {
|
|||
}
|
||||
|
||||
#[cfg(feature = "hyprland")]
|
||||
pub fn hyprland(&mut self) -> ClientResult<compositor::hyprland::Client> {
|
||||
let client = if let Some(client) = &self.hyprland {
|
||||
pub fn hyprland(&mut self) -> Arc<compositor::hyprland::Client> {
|
||||
if let Some(client) = &self.hyprland {
|
||||
client.clone()
|
||||
} else {
|
||||
let client = Arc::new(compositor::hyprland::Client::new());
|
||||
self.hyprland.replace(client.clone());
|
||||
client
|
||||
};
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cairo")]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use super::{
|
||||
MusicClient, PlayerState, PlayerUpdate, ProgressTick, Status, Track, TICK_INTERVAL_MS,
|
||||
MusicClient, PlayerState, PlayerUpdate, ProgressTick, Status, TICK_INTERVAL_MS, Track,
|
||||
};
|
||||
use crate::{await_sync, send, spawn, Ironbar};
|
||||
use crate::{Ironbar, await_sync, send, spawn};
|
||||
use color_eyre::Report;
|
||||
use color_eyre::Result;
|
||||
use mpd_client::client::{ConnectionEvent, Subsystem};
|
||||
use mpd_client::commands::{self, SeekMode};
|
||||
use mpd_client::responses::{PlayState, Song};
|
||||
use mpd_client::tag::Tag;
|
||||
use mpd_utils::{mpd_client, PersistentClient};
|
||||
use mpd_utils::{PersistentClient, mpd_client};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{MusicClient, PlayerState, PlayerUpdate, Status, Track, TICK_INTERVAL_MS};
|
||||
use super::{MusicClient, PlayerState, PlayerUpdate, Status, TICK_INTERVAL_MS, Track};
|
||||
use crate::clients::music::ProgressTick;
|
||||
use crate::{arc_mut, lock, send, spawn_blocking};
|
||||
use color_eyre::Result;
|
||||
|
|
|
@ -7,10 +7,10 @@ use tracing::error;
|
|||
use zbus::export::ordered_stream::OrderedStreamExt;
|
||||
use zbus::fdo::PropertiesProxy;
|
||||
use zbus::{
|
||||
Connection,
|
||||
names::InterfaceName,
|
||||
proxy,
|
||||
zvariant::{ObjectPath, Str},
|
||||
Connection,
|
||||
};
|
||||
|
||||
const DBUS_BUS: &str = "org.freedesktop.NetworkManager";
|
||||
|
|
|
@ -394,7 +394,7 @@ impl Client {
|
|||
}
|
||||
|
||||
/// Gets system uptime formatted as `HH:mm`.
|
||||
pub fn uptime(&self) -> String {
|
||||
pub fn uptime() -> String {
|
||||
let uptime = System::uptime();
|
||||
let hours = uptime / 3600;
|
||||
format!("{:0>2}:{:0>2}", hours, (uptime % 3600) / 60)
|
||||
|
@ -513,7 +513,7 @@ impl Namespace for Client {
|
|||
TokenType::LoadAverage1 => get(self.load_average_1()),
|
||||
TokenType::LoadAverage5 => get(self.load_average_5()),
|
||||
TokenType::LoadAverage15 => get(self.load_average_15()),
|
||||
TokenType::Uptime => Some(self.uptime()),
|
||||
TokenType::Uptime => Some(Client::uptime()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/// Originally taken from `upower-dbus` crate
|
||||
/// https://github.com/pop-os/upower-dbus/blob/main/LICENSE
|
||||
/// <https://github.com/pop-os/upower-dbus/blob/main/LICENSE>
|
||||
// Copyright 2021 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
use zbus::proxy;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mod sink;
|
||||
mod sink_input;
|
||||
|
||||
use crate::{arc_mut, lock, register_client, send, spawn_blocking, APP_ID};
|
||||
use crate::{APP_ID, arc_mut, lock, register_client, send, spawn_blocking};
|
||||
use libpulse_binding::callbacks::ListResult;
|
||||
use libpulse_binding::context::introspect::{Introspector, ServerInfo};
|
||||
use libpulse_binding::context::subscribe::{Facility, InterestMaskSet, Operation};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use super::{percent_to_volume, volume_to_percent, ArcMutVec, Client, ConnectionState, Event};
|
||||
use super::{ArcMutVec, Client, ConnectionState, Event, percent_to_volume, volume_to_percent};
|
||||
use crate::{lock, send};
|
||||
use libpulse_binding::callbacks::ListResult;
|
||||
use libpulse_binding::context::Context;
|
||||
use libpulse_binding::context::introspect::SinkInfo;
|
||||
use libpulse_binding::context::subscribe::Operation;
|
||||
use libpulse_binding::context::Context;
|
||||
use libpulse_binding::def::SinkState;
|
||||
use std::sync::{mpsc, Arc, Mutex};
|
||||
use std::sync::{Arc, Mutex, mpsc};
|
||||
use tokio::sync::broadcast;
|
||||
use tracing::{debug, error};
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use super::{percent_to_volume, volume_to_percent, ArcMutVec, Client, ConnectionState, Event};
|
||||
use super::{ArcMutVec, Client, ConnectionState, Event, percent_to_volume, volume_to_percent};
|
||||
use crate::{lock, send};
|
||||
use libpulse_binding::callbacks::ListResult;
|
||||
use libpulse_binding::context::Context;
|
||||
use libpulse_binding::context::introspect::SinkInputInfo;
|
||||
use libpulse_binding::context::subscribe::Operation;
|
||||
use libpulse_binding::context::Context;
|
||||
use std::sync::{mpsc, Arc, Mutex};
|
||||
use std::sync::{Arc, Mutex, mpsc};
|
||||
use tokio::sync::broadcast;
|
||||
use tracing::{debug, error};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ mod macros;
|
|||
mod wl_output;
|
||||
mod wl_seat;
|
||||
|
||||
use crate::error::{ExitCode, ERR_CHANNEL_RECV};
|
||||
use crate::error::{ERR_CHANNEL_RECV, ExitCode};
|
||||
use crate::{arc_mut, lock, register_client, send, spawn, spawn_blocking};
|
||||
use std::process::exit;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -11,8 +11,8 @@ use calloop_channel::Event::Msg;
|
|||
use cfg_if::cfg_if;
|
||||
use color_eyre::Report;
|
||||
use smithay_client_toolkit::output::OutputState;
|
||||
use smithay_client_toolkit::reexports::calloop::channel as calloop_channel;
|
||||
use smithay_client_toolkit::reexports::calloop::EventLoop;
|
||||
use smithay_client_toolkit::reexports::calloop::channel as calloop_channel;
|
||||
use smithay_client_toolkit::reexports::calloop_wayland_source::WaylandSource;
|
||||
use smithay_client_toolkit::registry::{ProvidesRegistryState, RegistryState};
|
||||
use smithay_client_toolkit::seat::SeatState;
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::error::ERR_WAYLAND_DATA;
|
|||
use crate::lock;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tracing::warn;
|
||||
use wayland_client::{event_created_child, Connection, Dispatch, Proxy, QueueHandle};
|
||||
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle, event_created_child};
|
||||
use wayland_protocols_wlr::data_control::v1::client::{
|
||||
zwlr_data_control_device_v1::{Event, ZwlrDataControlDeviceV1},
|
||||
zwlr_data_control_offer_v1::ZwlrDataControlOfferV1,
|
||||
|
@ -37,7 +37,9 @@ pub trait DataControlDeviceDataExt: Send + Sync {
|
|||
|
||||
fn selection_mime_types(&self) -> Vec<String> {
|
||||
let inner = self.data_control_device_data();
|
||||
lock!(lock!(inner.inner).selection_offer)
|
||||
let offer = &lock!(inner.inner).selection_offer;
|
||||
|
||||
lock!(offer)
|
||||
.as_ref()
|
||||
.map(|offer| {
|
||||
let data = offer
|
||||
|
@ -51,14 +53,14 @@ pub trait DataControlDeviceDataExt: Send + Sync {
|
|||
/// Get the active selection offer if it exists.
|
||||
fn selection_offer(&self) -> Option<SelectionOffer> {
|
||||
let inner = self.data_control_device_data();
|
||||
lock!(lock!(inner.inner).selection_offer)
|
||||
.as_ref()
|
||||
.and_then(|offer| {
|
||||
let data = offer
|
||||
.data::<Self::DataControlOfferInner>()
|
||||
.expect(ERR_WAYLAND_DATA);
|
||||
data.as_selection_offer()
|
||||
})
|
||||
let offer = &lock!(inner.inner).selection_offer;
|
||||
|
||||
lock!(offer).as_ref().and_then(|offer| {
|
||||
let data = offer
|
||||
.data::<Self::DataControlOfferInner>()
|
||||
.expect(ERR_WAYLAND_DATA);
|
||||
data.as_selection_offer()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +161,9 @@ where
|
|||
}
|
||||
}
|
||||
Event::Finished => {
|
||||
warn!("Data control offer is no longer valid, but has not been dropped by client. This could cause clipboard issues.");
|
||||
warn!(
|
||||
"Data control offer is no longer valid, but has not been dropped by client. This could cause clipboard issues."
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ use self::device::{DataControlDeviceDataExt, DataControlDeviceHandler};
|
|||
use self::offer::{DataControlDeviceOffer, DataControlOfferHandler};
|
||||
use self::source::DataControlSourceHandler;
|
||||
use super::{Client, Environment, Event, Request, Response};
|
||||
use crate::{lock, spawn, try_send, Ironbar};
|
||||
use crate::{Ironbar, lock, spawn, try_send};
|
||||
use device::DataControlDevice;
|
||||
use glib::Bytes;
|
||||
use nix::fcntl::{fcntl, F_GETPIPE_SZ, F_SETPIPE_SZ};
|
||||
use nix::fcntl::{F_GETPIPE_SZ, F_SETPIPE_SZ, fcntl};
|
||||
use nix::sys::epoll::{Epoll, EpollCreateFlags, EpollEvent, EpollFlags, EpollTimeout};
|
||||
use smithay_client_toolkit::data_device_manager::WritePipe;
|
||||
use std::cmp::min;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::manager::ToplevelManagerState;
|
||||
use crate::{lock, Ironbar};
|
||||
use crate::{Ironbar, lock};
|
||||
use std::collections::HashSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tracing::trace;
|
||||
|
|
|
@ -4,7 +4,7 @@ use smithay_client_toolkit::globals::{GlobalData, ProvidesBoundGlobal};
|
|||
use std::marker::PhantomData;
|
||||
use tracing::{debug, warn};
|
||||
use wayland_client::globals::{BindError, GlobalList};
|
||||
use wayland_client::{event_created_child, Connection, Dispatch, QueueHandle};
|
||||
use wayland_client::{Connection, Dispatch, QueueHandle, event_created_child};
|
||||
use wayland_protocols_wlr::foreign_toplevel::v1::client::{
|
||||
zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1,
|
||||
zwlr_foreign_toplevel_manager_v1::{Event, ZwlrForeignToplevelManagerV1},
|
||||
|
@ -67,7 +67,9 @@ where
|
|||
state.toplevel(conn, qhandle);
|
||||
}
|
||||
Event::Finished => {
|
||||
warn!("Foreign toplevel manager is no longer valid, but has not been dropped by client. This could cause window tracking issues.");
|
||||
warn!(
|
||||
"Foreign toplevel manager is no longer valid, but has not been dropped by client. This could cause window tracking issues."
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::dynamic_value::{dynamic_string, DynamicBool};
|
||||
use crate::dynamic_value::{DynamicBool, dynamic_string};
|
||||
use crate::script::{Script, ScriptInput};
|
||||
use glib::Propagation;
|
||||
use gtk::gdk::ScrollDirection;
|
||||
|
|
|
@ -52,9 +52,9 @@ where
|
|||
}
|
||||
|
||||
#[cfg(feature = "schema")]
|
||||
pub fn schema_layer(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||
pub fn schema_layer(generator: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||
use schemars::JsonSchema;
|
||||
let mut schema: schemars::schema::SchemaObject = <String>::json_schema(gen).into();
|
||||
let mut schema: schemars::schema::SchemaObject = <String>::json_schema(generator).into();
|
||||
schema.enum_values = Some(vec![
|
||||
"background".into(),
|
||||
"bottom".into(),
|
||||
|
|
|
@ -31,7 +31,7 @@ fn find_application_dirs() -> Vec<PathBuf> {
|
|||
|
||||
let xdg_dirs = env::var_os("XDG_DATA_DIRS");
|
||||
if let Some(xdg_dirs) = xdg_dirs {
|
||||
for mut xdg_dir in env::split_paths(&xdg_dirs).map(PathBuf::from) {
|
||||
for mut xdg_dir in env::split_paths(&xdg_dirs) {
|
||||
xdg_dir.push("applications");
|
||||
dirs.push(xdg_dir);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::script::Script;
|
||||
use crate::{glib_recv_mpsc, spawn, try_send};
|
||||
#[cfg(feature = "ipc")]
|
||||
use crate::{send_async, Ironbar};
|
||||
use crate::{Ironbar, send_async};
|
||||
use crate::{glib_recv_mpsc, spawn, try_send};
|
||||
use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::script::{OutputStream, Script};
|
||||
#[cfg(feature = "ipc")]
|
||||
use crate::Ironbar;
|
||||
use crate::script::{OutputStream, Script};
|
||||
use crate::{arc_mut, glib_recv_mpsc, lock, spawn, try_send};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::config::TruncateMode;
|
||||
use glib::{markup_escape_text, IsA};
|
||||
use glib::{IsA, markup_escape_text};
|
||||
use gtk::pango::EllipsizeMode;
|
||||
use gtk::prelude::*;
|
||||
use gtk::{Label, Orientation, Widget};
|
||||
|
|
|
@ -23,7 +23,9 @@ impl Ipc {
|
|||
.join("ironbar-ipc.sock");
|
||||
|
||||
if format!("{}", ipc_socket_file.display()).len() > 100 {
|
||||
warn!("The IPC socket file's absolute path exceeds 100 bytes, the socket may fail to create.");
|
||||
warn!(
|
||||
"The IPC socket file's absolute path exceeds 100 bytes, the socket may fail to create."
|
||||
);
|
||||
}
|
||||
|
||||
Self {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use super::Response;
|
||||
use crate::Ironbar;
|
||||
use crate::bar::Bar;
|
||||
use crate::ipc::{BarCommand, BarCommandType};
|
||||
use crate::modules::PopupButton;
|
||||
use crate::Ironbar;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn handle_command(command: BarCommand, ironbar: &Rc<Ironbar>) -> Response {
|
||||
pub fn handle_command(command: &BarCommand, ironbar: &Rc<Ironbar>) -> Response {
|
||||
use BarCommandType::*;
|
||||
|
||||
let bars = ironbar.bars_by_name(&command.name);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::ipc::commands::IronvarCommand;
|
||||
use crate::ipc::Response;
|
||||
use crate::ironvar::{Namespace, WritableNamespace};
|
||||
use crate::Ironbar;
|
||||
use crate::ipc::{IronvarCommand, Response};
|
||||
use crate::ironvar::{Namespace, WritableNamespace};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn handle_command(command: IronvarCommand) -> Response {
|
||||
|
|
|
@ -6,8 +6,8 @@ use std::path::Path;
|
|||
use std::rc::Rc;
|
||||
|
||||
use color_eyre::{Report, Result};
|
||||
use gtk::prelude::*;
|
||||
use gtk::Application;
|
||||
use gtk::prelude::*;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net::{UnixListener, UnixStream};
|
||||
use tokio::sync::mpsc::{self, Receiver, Sender};
|
||||
|
@ -15,7 +15,7 @@ use tracing::{debug, error, info, warn};
|
|||
|
||||
use crate::ipc::{Command, Response};
|
||||
use crate::style::load_css;
|
||||
use crate::{glib_recv_mpsc, send_async, spawn, try_send, Ironbar};
|
||||
use crate::{Ironbar, glib_recv_mpsc, send_async, spawn, try_send};
|
||||
|
||||
use super::Ipc;
|
||||
|
||||
|
@ -150,7 +150,7 @@ impl Ipc {
|
|||
}
|
||||
}
|
||||
Command::Var(cmd) => ironvar::handle_command(cmd),
|
||||
Command::Bar(cmd) => bar::handle_command(cmd, ironbar),
|
||||
Command::Bar(cmd) => bar::handle_command(&cmd, ironbar),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use tracing_appender::rolling::Rotation;
|
|||
use tracing_error::ErrorLayer;
|
||||
use tracing_subscriber::fmt::{Layer, MakeWriter};
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
use tracing_subscriber::{EnvFilter, fmt};
|
||||
|
||||
struct MakeFileWriter {
|
||||
file_writer: NonBlocking,
|
||||
|
@ -32,7 +32,11 @@ impl<'a> MakeWriter<'a> for MakeFileWriter {
|
|||
pub fn install_logging() -> Result<WorkerGuard> {
|
||||
// Disable backtraces by default
|
||||
if env::var("RUST_LIB_BACKTRACE").is_err() {
|
||||
env::set_var("RUST_LIB_BACKTRACE", "0");
|
||||
// as this is the very first thing we do (before runtimes are set up)
|
||||
// we can be sure that it only runs in a single-thread context
|
||||
unsafe {
|
||||
env::set_var("RUST_LIB_BACKTRACE", "0");
|
||||
}
|
||||
}
|
||||
|
||||
// keep guard in scope
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -7,26 +7,26 @@ use std::path::PathBuf;
|
|||
use std::process::exit;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::{mpsc, Arc, Mutex, OnceLock};
|
||||
use std::sync::{Arc, Mutex, OnceLock, mpsc};
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
#[cfg(feature = "cli")]
|
||||
use clap::Parser;
|
||||
use color_eyre::eyre::Result;
|
||||
use color_eyre::Report;
|
||||
use color_eyre::eyre::Result;
|
||||
use dirs::config_dir;
|
||||
use gtk::Application;
|
||||
use gtk::gdk::Display;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Application;
|
||||
use smithay_client_toolkit::output::OutputInfo;
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::task::{block_in_place, JoinHandle};
|
||||
use tokio::task::{JoinHandle, block_in_place};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use universal_config::ConfigLoader;
|
||||
|
||||
use crate::bar::{create_bar, Bar};
|
||||
use crate::clients::wayland::OutputEventType;
|
||||
use crate::bar::{Bar, create_bar};
|
||||
use crate::clients::Clients;
|
||||
use crate::clients::wayland::OutputEventType;
|
||||
use crate::config::{Config, MonitorConfig};
|
||||
use crate::error::ExitCode;
|
||||
#[cfg(feature = "ipc")]
|
||||
|
|
|
@ -2,13 +2,13 @@ use crate::config::CommonConfig;
|
|||
use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
|
||||
use crate::{glib_recv, module_impl, spawn, try_send};
|
||||
use cairo::{Format, ImageSurface};
|
||||
use glib::translate::IntoGlibPtr;
|
||||
use glib::Propagation;
|
||||
use gtk::prelude::*;
|
||||
use glib::translate::IntoGlibPtr;
|
||||
use gtk::DrawingArea;
|
||||
use gtk::prelude::*;
|
||||
use mlua::{Error, Function, LightUserData};
|
||||
use notify::event::ModifyKind;
|
||||
use notify::{recommended_watcher, Event, EventKind, RecursiveMode, Watcher};
|
||||
use notify::{Event, EventKind, RecursiveMode, Watcher, recommended_watcher};
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use gtk::prelude::*;
|
||||
use gtk::Image;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::build;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use gtk::prelude::*;
|
||||
use gtk::Label;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
|
|
@ -5,16 +5,16 @@ mod label;
|
|||
mod progress;
|
||||
mod slider;
|
||||
|
||||
use self::r#box::BoxWidget;
|
||||
use self::image::ImageWidget;
|
||||
use self::label::LabelWidget;
|
||||
use self::r#box::BoxWidget;
|
||||
use self::slider::SliderWidget;
|
||||
use crate::config::{CommonConfig, ModuleConfig};
|
||||
use crate::modules::custom::button::ButtonWidget;
|
||||
use crate::modules::custom::progress::ProgressWidget;
|
||||
use crate::modules::{
|
||||
wrap_widget, AnyModuleFactory, BarModuleFactory, Module, ModuleInfo, ModuleParts, ModulePopup,
|
||||
ModuleUpdateEvent, PopupButton, PopupModuleFactory, WidgetContext,
|
||||
AnyModuleFactory, BarModuleFactory, Module, ModuleInfo, ModuleParts, ModulePopup,
|
||||
ModuleUpdateEvent, PopupButton, PopupModuleFactory, WidgetContext, wrap_widget,
|
||||
};
|
||||
use crate::script::Script;
|
||||
use crate::{module_impl, send_async, spawn};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use gtk::prelude::*;
|
||||
use gtk::ProgressBar;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::error;
|
||||
|
|
|
@ -2,8 +2,8 @@ use glib::Propagation;
|
|||
use std::cell::Cell;
|
||||
use std::ops::Neg;
|
||||
|
||||
use gtk::prelude::*;
|
||||
use gtk::Scale;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::error;
|
||||
|
|
|
@ -6,8 +6,8 @@ use crate::image::ImageProvider;
|
|||
use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
|
||||
use crate::{glib_recv, module_impl, send_async, spawn, try_send};
|
||||
use color_eyre::Result;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Label;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::debug;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use color_eyre::eyre::Report;
|
||||
use color_eyre::Result;
|
||||
use gtk::{prelude::*, Button};
|
||||
use color_eyre::eyre::Report;
|
||||
use gtk::{Button, prelude::*};
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, trace};
|
||||
|
@ -217,7 +217,9 @@ impl Module<gtk::Box> for KeyboardModule {
|
|||
module_update!(tx, KeyboardUpdate::Layout(payload));
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(count)) => {
|
||||
tracing::warn!("Channel lagged behind by {count}, this may result in unexpected or broken behaviour");
|
||||
tracing::warn!(
|
||||
"Channel lagged behind by {count}, this may result in unexpected or broken behaviour"
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!("{err:?}");
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::clients::wayland::ToplevelInfo;
|
|||
use crate::config::{BarPosition, TruncateMode};
|
||||
use crate::gtk_helpers::{IronbarGtkExt, IronbarLabelExt};
|
||||
use crate::image::ImageProvider;
|
||||
use crate::modules::launcher::{ItemEvent, LauncherUpdate};
|
||||
use crate::modules::ModuleUpdateEvent;
|
||||
use crate::modules::launcher::{ItemEvent, LauncherUpdate};
|
||||
use crate::{read_lock, try_send};
|
||||
use glib::Propagation;
|
||||
use gtk::gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY};
|
||||
|
|
|
@ -221,7 +221,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
let icon_override = info
|
||||
.icon_overrides
|
||||
.get(app_id)
|
||||
.map_or_else(String::new, |v| v.to_string());
|
||||
.map_or_else(String::new, ToString::to_string);
|
||||
|
||||
(
|
||||
app_id.to_string(),
|
||||
|
@ -250,19 +250,16 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
for info in handles {
|
||||
let mut items = lock!(items);
|
||||
let item = items.get_mut(&info.app_id);
|
||||
match item {
|
||||
Some(item) => {
|
||||
item.merge_toplevel(info.clone());
|
||||
}
|
||||
None => {
|
||||
let mut item = Item::from(info.clone());
|
||||
if let Some(item) = item {
|
||||
item.merge_toplevel(info.clone());
|
||||
} else {
|
||||
let mut item = Item::from(info.clone());
|
||||
|
||||
if let Some(icon) = icon_overrides.get(&info.app_id) {
|
||||
item.icon_override = icon.clone();
|
||||
}
|
||||
|
||||
items.insert(info.app_id.clone(), item);
|
||||
if let Some(icon) = icon_overrides.get(&info.app_id) {
|
||||
item.icon_override.clone_from(icon);
|
||||
}
|
||||
|
||||
items.insert(info.app_id.clone(), item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +291,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
let mut item: Item = info.into();
|
||||
|
||||
if let Some(icon) = icon_overrides.get(&app_id) {
|
||||
item.icon_override = icon.clone();
|
||||
item.icon_override.clone_from(icon);
|
||||
}
|
||||
|
||||
items.insert(app_id.clone(), item.clone());
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::clients::{ClientResult, ProvidesClient, ProvidesFallibleClient};
|
|||
use crate::config::{BarPosition, CommonConfig, TransitionType};
|
||||
use crate::gtk_helpers::{IronbarGtkExt, WidgetGeometry};
|
||||
use crate::popup::Popup;
|
||||
use crate::{glib_recv_mpsc, send, Ironbar};
|
||||
use crate::{Ironbar, glib_recv_mpsc, send};
|
||||
|
||||
#[cfg(feature = "cairo")]
|
||||
pub mod cairo;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::cell::RefMut;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
use color_eyre::Result;
|
||||
|
@ -12,12 +12,12 @@ use regex::Regex;
|
|||
use tokio::sync::{broadcast, mpsc};
|
||||
use tracing::error;
|
||||
|
||||
use crate::clients::Clients;
|
||||
use crate::clients::music::{
|
||||
self, MusicClient, PlayerState, PlayerUpdate, ProgressTick, Status, Track,
|
||||
};
|
||||
use crate::clients::Clients;
|
||||
use crate::gtk_helpers::{IronbarGtkExt, IronbarLabelExt};
|
||||
use crate::image::{new_icon_button, IconLabel, ImageProvider};
|
||||
use crate::image::{IconLabel, ImageProvider, new_icon_button};
|
||||
use crate::modules::PopupButton;
|
||||
use crate::modules::{
|
||||
Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, WidgetContext,
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetC
|
|||
use crate::script::{OutputStream, Script, ScriptMode};
|
||||
use crate::{glib_recv, module_impl, spawn, try_send};
|
||||
use color_eyre::{Help, Report, Result};
|
||||
use gtk::prelude::*;
|
||||
use gtk::Label;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::error;
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::gtk_helpers::IronbarLabelExt;
|
|||
use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
|
||||
use crate::{await_sync, glib_recv, module_impl, try_send};
|
||||
use color_eyre::{Report, Result};
|
||||
use gtk::prelude::*;
|
||||
use gtk::Label;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use swayipc_async::ModeEvent;
|
||||
use tokio::sync::mpsc;
|
||||
|
|
|
@ -9,8 +9,8 @@ use crate::modules::sysinfo::token::Part;
|
|||
use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
|
||||
use crate::{clients, glib_recv, module_impl, send_async, spawn, try_send};
|
||||
use color_eyre::Result;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Label;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::mpsc;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::token::{Alignment, Part, Token};
|
||||
use super::Interval;
|
||||
use super::token::{Alignment, Part, Token};
|
||||
use crate::clients;
|
||||
use crate::clients::sysinfo::{TokenType, Value, ValueSet};
|
||||
|
||||
|
@ -85,7 +85,7 @@ impl Token {
|
|||
TokenType::LoadAverage15 => get(client.load_average_15()),
|
||||
|
||||
// String tokens
|
||||
TokenType::Uptime => TokenValue::String(client.uptime()),
|
||||
TokenType::Uptime => TokenValue::String(clients::sysinfo::Client::uptime()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,10 @@ impl Module<gtk::Box> for TrayModule {
|
|||
let client = context.try_client::<tray::Client>()?;
|
||||
let mut tray_rx = client.subscribe();
|
||||
|
||||
let initial_items = lock!(client.items()).clone();
|
||||
let initial_items = {
|
||||
let items = client.items();
|
||||
lock!(items).clone()
|
||||
};
|
||||
|
||||
// listen to tray updates
|
||||
spawn(async move {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use color_eyre::Result;
|
||||
use futures_lite::stream::StreamExt;
|
||||
use gtk::{prelude::*, Button};
|
||||
use gtk::{Button, prelude::*};
|
||||
use gtk::{Label, Orientation};
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::{broadcast, mpsc};
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::gtk_helpers::IronbarGtkExt;
|
|||
use crate::image::new_icon_button;
|
||||
use crate::modules::workspaces::WorkspaceItemContext;
|
||||
use crate::try_send;
|
||||
use gtk::prelude::*;
|
||||
use gtk::Button as GtkButton;
|
||||
use gtk::prelude::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Button {
|
||||
|
|
|
@ -10,8 +10,8 @@ use crate::modules::workspaces::open_state::OpenState;
|
|||
use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
|
||||
use crate::{glib_recv, module_impl, send_async, spawn};
|
||||
use color_eyre::{Report, Result};
|
||||
use gtk::prelude::*;
|
||||
use gtk::IconTheme;
|
||||
use gtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::clients::wayland::{OutputEvent, OutputEventType};
|
|||
use crate::config::BarPosition;
|
||||
use crate::gtk_helpers::{IronbarGtkExt, WidgetGeometry};
|
||||
use crate::modules::{ModuleInfo, ModulePopupParts, PopupButton};
|
||||
use crate::{glib_recv, rc_mut, Ironbar};
|
||||
use crate::{Ironbar, glib_recv, rc_mut};
|
||||
use gtk::prelude::*;
|
||||
use gtk::{ApplicationWindow, Button, Orientation};
|
||||
use gtk_layer_shell::LayerShell;
|
||||
|
|
|
@ -2,9 +2,9 @@ use crate::{glib_recv_mpsc, spawn, try_send};
|
|||
use color_eyre::{Help, Report};
|
||||
use gtk::ffi::GTK_STYLE_PROVIDER_PRIORITY_USER;
|
||||
use gtk::prelude::*;
|
||||
use gtk::{gdk, gio, Application, CssProvider, StyleContext};
|
||||
use gtk::{Application, CssProvider, StyleContext, gdk, gio};
|
||||
use notify::event::ModifyKind;
|
||||
use notify::{recommended_watcher, Event, EventKind, RecursiveMode, Result, Watcher};
|
||||
use notify::{Event, EventKind, RecursiveMode, Result, Watcher, recommended_watcher};
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue