Linting and minor style changes

This commit is contained in:
AB
2020-07-07 09:17:27 +03:00
parent b1015ada2f
commit 573cb35b52
4 changed files with 47 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
# Maintainer: Alexandr Bogomyakov (ultradesu) <ab@hexor.ru> # Maintainer: Alexandr Bogomyakov (ultradesu) <ab@hexor.ru>
pkgname=tmux-helper pkgname=tmux-helper
pkgver=0.2.1 pkgver=0.3.3
pkgrel=1 pkgrel=1
pkgdesc="Tmux helper" pkgdesc="Tmux helper"
url="https://github.com/house-of-vanity/tmux-helper.git" url="https://github.com/house-of-vanity/tmux-helper.git"

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "tmux-helper" name = "tmux-helper"
version = "0.3.2" version = "0.3.3"
description = "Utility for printing system info for tmux status line." description = "Utility for printing system info for tmux status line."
authors = ["Ultra Desu <ultradesu@hexor.ru>"] authors = ["Ultra Desu <ultradesu@hexor.ru>"]
edition = "2018" edition = "2018"
@@ -11,3 +11,4 @@ dbus = "*"
chrono = "*" chrono = "*"
mpd = "*" mpd = "*"
clap = "*" clap = "*"
size_format = "1.0"

View File

@@ -2,10 +2,11 @@ use crate::config;
use crate::dbus::blocking::stdintf::org_freedesktop_dbus::Properties; use crate::dbus::blocking::stdintf::org_freedesktop_dbus::Properties;
use chrono::{DateTime, Local, Utc}; use chrono::{DateTime, Local, Utc};
use dbus::{arg, blocking::Connection}; use dbus::{arg, blocking::Connection};
use mpd::Client;
use size_format::SizeFormatterBinary;
use std::process;
use std::time::Duration; use std::time::Duration;
use sys_info; use sys_info;
use mpd::Client;
use std::process;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct TrackInfo { pub struct TrackInfo {
@@ -47,7 +48,10 @@ pub fn mem_load_bar(bar_len: i32, config: &config::Config) {
let len = let len =
((memory.total - memory.avail) as f32 / (memory.total as f32) * bar_len as f32) as i32; ((memory.total - memory.avail) as f32 / (memory.total as f32) * bar_len as f32) as i32;
to_bar(len, bar_len, 0.7, 0.9, config); to_bar(len, bar_len, 0.7, 0.9, config);
print!("{:.0} MiB#[default]", memory.avail / 1024); print!(
"{}B #[default]",
SizeFormatterBinary::new((memory.avail * 1000) as u64)
);
} }
pub fn cpu_load_bar(bar_len: i32, config: &config::Config) { pub fn cpu_load_bar(bar_len: i32, config: &config::Config) {
@@ -181,8 +185,7 @@ fn shorten(line: String, max_len: usize, max_shift: usize) -> String {
new_line.push(ch); new_line.push(ch);
counter += 1; counter += 1;
} }
} } else {
else {
new_line = line; new_line = line;
} }
new_line new_line
@@ -224,7 +227,10 @@ pub fn mpris(config: &config::Config) {
pub fn mpd(config: &config::Config) { pub fn mpd(config: &config::Config) {
let mut conn = match Client::connect(&config.mpd_server) { let mut conn = match Client::connect(&config.mpd_server) {
Ok(conn) => conn, Ok(conn) => conn,
Err(e) => {println!("Can't connect to MPD server. {}", e); process::exit(0x0001)} Err(e) => {
println!("Can't connect to MPD server. {}", e);
process::exit(0x0001)
}
}; };
let mut track_info = TrackInfo { let mut track_info = TrackInfo {
title: String::new(), title: String::new(),
@@ -253,14 +259,12 @@ pub fn mpd(config: &config::Config) {
track_info.duration = format_time(time.1.num_seconds() as i64); track_info.duration = format_time(time.1.num_seconds() as i64);
} }
let status = match conn.status() { let status = match conn.status() {
Ok(status) => { Ok(status) => match status.state {
match status.state {
mpd::State::Play => "".to_string(), mpd::State::Play => "".to_string(),
mpd::State::Pause => "".to_string(), mpd::State::Pause => "".to_string(),
mpd::State::Stop => "".to_string(), mpd::State::Stop => "".to_string(),
} },
} Err(_) => "".to_string(),
Err(_) => {"".to_string()},
}; };
track_info.status = status; track_info.status = status;
format_player(track_info, config) format_player(track_info, config)