mirror of
https://github.com/house-of-vanity/tmux-helper.git
synced 2026-02-04 17:57:58 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb3577979c | ||
|
|
c082c328f5 | ||
|
|
c9a7c33356 | ||
|
|
a910ea39f4 | ||
|
|
337949a792 | ||
|
|
d09629794f | ||
|
|
59240601fe | ||
|
|
00b0b5f3ef | ||
|
|
60c014347c | ||
|
|
e0ff50a7fa | ||
|
|
df1ccc4054 | ||
|
|
86596eed29 | ||
|
|
4af53996a7 | ||
|
|
25fe327294 |
143
.github/workflows/build.yml
vendored
143
.github/workflows/build.yml
vendored
@@ -1,84 +1,95 @@
|
|||||||
name: Build and publish
|
name: Build and publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# Sequence of patterns matched against refs/tags
|
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
- 'v*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
BINARY_NAME: tmux-helper
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
make_bin:
|
build:
|
||||||
name: Build binary
|
name: Build binaries
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
platform_name: linux-amd64
|
||||||
|
- os: macos-latest
|
||||||
|
platform_name: macos-arm64
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Pre-build
|
- name: Pre-build (Linux)
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: sudo apt install -y libdbus-1-dev pkg-config libdbus-1-3 libfuse-dev
|
run: sudo apt install -y libdbus-1-dev pkg-config libdbus-1-3 libfuse-dev
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
- name: Pre-build (macOS)
|
||||||
|
if: matrix.os == 'macos-latest'
|
||||||
|
run: brew install dbus
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
run: cargo build --release
|
run: cargo build --release
|
||||||
- name: Upload binary
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: tmux-helper
|
|
||||||
path: ./target/release/tmux-helper
|
|
||||||
make_arch:
|
|
||||||
name: Make Arch Linux package
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: archlinux
|
|
||||||
options: --privileged
|
|
||||||
volumes:
|
|
||||||
- /sys/fs/cgroup:/sys/fs/cgroup
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Build Arch Linux package
|
|
||||||
uses: FFY00/build-arch-package@master
|
|
||||||
with:
|
|
||||||
PKGBUILD: $GITHUB_WORKSPACE/.github/workflows/PKGBUILD
|
|
||||||
OUTDIR: $HOME/arch-packages
|
|
||||||
- run: mv $HOME/arch-packages/*pkg.tar.zst tmux-helper-x86_64.pkg.tar.zst
|
|
||||||
- name: Upload Arch Package
|
|
||||||
uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: arch_linux_tmux-helper-x86_64.pkg.tar.zst
|
|
||||||
path: ./tmux-helper-x86_64.pkg.tar.zst
|
|
||||||
|
|
||||||
publish:
|
- name: Rename binary
|
||||||
name: Publish release
|
|
||||||
needs: [make_bin, make_arch]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Get the version (git tag)
|
|
||||||
id: get_version
|
|
||||||
run: |
|
run: |
|
||||||
echo ${GITHUB_REF/refs\/tags\/v/}
|
mkdir -p ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
|
||||||
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
|
cp target/release/${{ env.BINARY_NAME }} ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}/${{ env.BINARY_NAME }}
|
||||||
echo ::set-output name=FULL_TAG::${GITHUB_REF/refs\/tags\//}
|
|
||||||
- name: Create Release
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
|
||||||
|
path: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Create Release Page
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ncipollo/release-action@v1
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref }}
|
allowUpdates: true
|
||||||
release_name: Release ${{ github.ref }}
|
tag: ${{ github.ref_name }}
|
||||||
draft: false
|
|
||||||
prerelease: false
|
upload:
|
||||||
- name: Download binary
|
name: Upload Release Assets
|
||||||
uses: actions/download-artifact@v1
|
needs: release
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
platform_name: linux-amd64
|
||||||
|
- os: macos-latest
|
||||||
|
platform_name: macos-arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
name: Download ${{ matrix.platform_name }} artifact
|
||||||
with:
|
with:
|
||||||
name: tmux-helper
|
name: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
|
||||||
path: ./
|
path: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
|
||||||
- name: Download Arch Package
|
|
||||||
uses: actions/download-artifact@v1
|
- name: Upload Release Asset
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
name: arch_linux_tmux-helper-x86_64.pkg.tar.zst
|
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||||
path: ./
|
asset_path: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}/${{ env.BINARY_NAME }}
|
||||||
- name: Upload binary assets
|
asset_name: ${{ env.BINARY_NAME }}_${{ matrix.platform_name }}
|
||||||
run: |
|
asset_content_type: application/octet-stream
|
||||||
wget https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2
|
|
||||||
tar xjf linux-amd64-github-release.tar.bz2
|
|
||||||
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
|
||||||
./bin/linux/amd64/github-release upload -u house-of-vanity -r tmux-helper --tag ${{ steps.get_version.outputs.FULL_TAG }} --name arch_linux_tmux-helper-${{ steps.get_version.outputs.VERSION }}-x86_64.pkg.tar.zst --file ./tmux-helper-x86_64.pkg.tar.zst
|
|
||||||
./bin/linux/amd64/github-release upload -u house-of-vanity -r tmux-helper --tag ${{ steps.get_version.outputs.FULL_TAG }} --name tmux-helper-${{ steps.get_version.outputs.VERSION }} --file ./tmux-helper
|
|
||||||
|
|||||||
16
Cargo.toml
16
Cargo.toml
@@ -1,14 +1,14 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tmux-helper"
|
name = "tmux-helper"
|
||||||
version = "0.3.4"
|
version = "0.4.0"
|
||||||
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 = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sys-info = "*"
|
sys-info = "0.9"
|
||||||
dbus = "*"
|
dbus = "0.9"
|
||||||
chrono = "*"
|
chrono = "0.4"
|
||||||
mpd = "*"
|
mpd = "0.1"
|
||||||
clap = "*"
|
clap = "4"
|
||||||
size_format = "1.0"
|
size_format = "1"
|
||||||
|
|||||||
243
src/config.rs
243
src/config.rs
@@ -1,4 +1,4 @@
|
|||||||
use clap::{App, Arg};
|
use clap::{Arg, Command};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
@@ -22,6 +22,10 @@ pub struct Config {
|
|||||||
pub mpd_server: String,
|
pub mpd_server: String,
|
||||||
pub lt_format: Option<String>,
|
pub lt_format: Option<String>,
|
||||||
pub ut_format: Option<String>,
|
pub ut_format: Option<String>,
|
||||||
|
pub bar_symbol: Option<String>,
|
||||||
|
pub bar_empty_symbol: Option<String>,
|
||||||
|
pub low_threshold: f32,
|
||||||
|
pub mid_threshold: f32,
|
||||||
pub color_low: String,
|
pub color_low: String,
|
||||||
pub color_mid: String,
|
pub color_mid: String,
|
||||||
pub color_high: String,
|
pub color_high: String,
|
||||||
@@ -36,191 +40,206 @@ fn colorize(color: String) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn read() -> Config {
|
pub fn read() -> Config {
|
||||||
// Parse opts and args
|
let cli_args = Command::new(env!("CARGO_PKG_NAME"))
|
||||||
let cli_args = App::new(env!("CARGO_PKG_NAME"))
|
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
.author(env!("CARGO_PKG_AUTHORS"))
|
.author(env!("CARGO_PKG_AUTHORS"))
|
||||||
.about(env!("CARGO_PKG_DESCRIPTION"))
|
.about(env!("CARGO_PKG_DESCRIPTION"))
|
||||||
// Flags
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("cpu")
|
Arg::new("cpu")
|
||||||
.short("c")
|
.short('c')
|
||||||
.long("cpu")
|
.long("cpu")
|
||||||
.help("Print cpu load bar.")
|
.help("Print cpu load bar.")
|
||||||
.conflicts_with_all(&["mem", "mpris", "mpd", "localtime", "utctime"])
|
.action(clap::ArgAction::SetTrue)
|
||||||
.required(false),
|
.conflicts_with_all(["mem", "mpris", "mpd", "localtime", "utctime"]),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("mem")
|
Arg::new("mem")
|
||||||
.short("m")
|
.short('m')
|
||||||
.long("mem")
|
.long("mem")
|
||||||
.help("Print mem usage bar.")
|
.action(clap::ArgAction::SetTrue)
|
||||||
// .conflicts_with("cpu")
|
.help("Print mem usage bar."),
|
||||||
// .conflicts_with("mpris")
|
|
||||||
// .conflicts_with("mpd")
|
|
||||||
// .conflicts_with("localtime")
|
|
||||||
// .conflicts_with("utctime")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("mpris")
|
Arg::new("low")
|
||||||
.short("p")
|
.long("low")
|
||||||
|
.help("Low threshold (0.0 - 1.0)")
|
||||||
|
.value_parser(clap::value_parser!(f32))
|
||||||
|
.default_value("0.7"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("mid")
|
||||||
|
.long("mid")
|
||||||
|
.help("Mid threshold (0.0 - 1.0)")
|
||||||
|
.value_parser(clap::value_parser!(f32))
|
||||||
|
.default_value("0.9"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("mpris")
|
||||||
|
.short('p')
|
||||||
.long("mpris")
|
.long("mpris")
|
||||||
.help("Show player info using MPRIS2 interface.")
|
.action(clap::ArgAction::SetTrue)
|
||||||
// .conflicts_with("cpu")
|
.help("Show player info using MPRIS2 interface."),
|
||||||
// .conflicts_with("mem")
|
|
||||||
// .conflicts_with("localtime")
|
|
||||||
// .conflicts_with("mpd")
|
|
||||||
// .conflicts_with("utctime")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("mpd")
|
Arg::new("mpd")
|
||||||
.short("d")
|
.short('d')
|
||||||
.long("mpd")
|
.long("mpd")
|
||||||
.help("Show mpd player using MPD native protocol.")
|
.action(clap::ArgAction::SetTrue)
|
||||||
// .conflicts_with("cpu")
|
.help("Show mpd player using MPD native protocol."),
|
||||||
// .conflicts_with("mem")
|
|
||||||
// .conflicts_with("localtime")
|
|
||||||
// .conflicts_with("mpris")
|
|
||||||
// .conflicts_with("utctime")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
// Options
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("localtime")
|
Arg::new("localtime")
|
||||||
.short("l")
|
.short('l')
|
||||||
.long("localtime")
|
.long("localtime")
|
||||||
.help("Local time")
|
.help("Local time")
|
||||||
// .conflicts_with_all(&["mem", "mpris", "mpd", "cpu", "utctime"])
|
.num_args(0..=1)
|
||||||
.takes_value(true)
|
.default_missing_value("%H:%M"),
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("utctime")
|
Arg::new("utctime")
|
||||||
.short("u")
|
.short('u')
|
||||||
.long("utctime")
|
.long("utctime")
|
||||||
.help("UTC time")
|
.help("UTC time")
|
||||||
// .conflicts_with_all(&["mem", "mpris", "mpd", "cpu", "localtime"])
|
.num_args(0..=1)
|
||||||
.takes_value(true)
|
.default_missing_value("%H:%M"),
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("mpd_address")
|
Arg::new("bar_symbol")
|
||||||
.short("a")
|
.short('s')
|
||||||
|
.long("symbol")
|
||||||
|
.help("Symbol to build bar")
|
||||||
|
.num_args(0..=1)
|
||||||
|
.default_value("▮"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("bar_empty_symbol")
|
||||||
|
.short('e')
|
||||||
|
.long("empty-symbol")
|
||||||
|
.help("Symbol to represent the empty part of the bar")
|
||||||
|
.num_args(0..=1)
|
||||||
|
.default_value("▯"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("mpd_address")
|
||||||
|
.short('a')
|
||||||
.long("mpd-address")
|
.long("mpd-address")
|
||||||
.help("<ADDR>:<PORT> of MPD server.")
|
.help("<ADDR>:<PORT> of MPD server.")
|
||||||
.takes_value(true)
|
.default_value("127.0.0.1:6600"),
|
||||||
.default_value("127.0.0.1:6600")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_LOW")
|
Arg::new("COLOR_LOW")
|
||||||
.long("COLOR_LOW")
|
.long("COLOR_LOW")
|
||||||
.help("CPU and MEM bar color while low usage.")
|
.help("CPU and MEM bar color while low usage.")
|
||||||
.takes_value(true)
|
.default_value("119"),
|
||||||
.default_value("119")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_MID")
|
Arg::new("COLOR_MID")
|
||||||
.long("COLOR_MID")
|
.long("COLOR_MID")
|
||||||
.help("CPU and MEM bar color while mid usage.")
|
.help("CPU and MEM bar color while mid usage.")
|
||||||
.takes_value(true)
|
.default_value("220"),
|
||||||
.default_value("220")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_HIGH")
|
Arg::new("COLOR_HIGH")
|
||||||
.long("COLOR_HIGH")
|
.long("COLOR_HIGH")
|
||||||
.help("CPU and MEM bar color while high usage.")
|
.help("CPU and MEM bar color while high usage.")
|
||||||
.takes_value(true)
|
.default_value("197"),
|
||||||
.default_value("197")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_TRACK_NAME")
|
Arg::new("COLOR_TRACK_NAME")
|
||||||
.long("COLOR_TRACK_NAME")
|
.long("COLOR_TRACK_NAME")
|
||||||
.help("Color of track name filed.")
|
.help("Color of track name filed.")
|
||||||
.takes_value(true)
|
.default_value("46"),
|
||||||
.default_value("46")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_TRACK_ARTIST")
|
Arg::new("COLOR_TRACK_ARTIST")
|
||||||
.long("COLOR_TRACK_ARTIST")
|
.long("COLOR_TRACK_ARTIST")
|
||||||
.help("Color of artist name filed.")
|
.help("Color of artist name filed.")
|
||||||
.takes_value(true)
|
.default_value("46"),
|
||||||
.default_value("46")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_TRACK_TIME")
|
Arg::new("COLOR_TRACK_TIME")
|
||||||
.long("COLOR_TRACK_TIME")
|
.long("COLOR_TRACK_TIME")
|
||||||
.help("Color of playing time field.")
|
.help("Color of playing time field.")
|
||||||
.takes_value(true)
|
.default_value("153"),
|
||||||
.default_value("153")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("COLOR_END")
|
Arg::new("COLOR_END")
|
||||||
.long("COLOR_END")
|
.long("COLOR_END")
|
||||||
.help("Default color using to terminate others.")
|
.help("Default color using to terminate others.")
|
||||||
.takes_value(true)
|
.default_value("153"),
|
||||||
.default_value("153")
|
|
||||||
.required(false),
|
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
// cpu - cpu usage bar
|
let lt_format = cli_args
|
||||||
// mem - mem usage bar
|
.get_one::<String>("localtime")
|
||||||
// mpris - player info using MPRIS2 interface
|
.map(|s| s.to_string());
|
||||||
// mpd - player info using MPD native interface
|
let ut_format = cli_args.get_one::<String>("utctime").map(|s| s.to_string());
|
||||||
// utctime - utc time
|
let bar_symbol = cli_args
|
||||||
// localtime - local time
|
.get_one::<String>("bar_symbol")
|
||||||
// lt_format - local time format
|
.map(|s| s.to_string());
|
||||||
// ut_format - utc time format
|
let bar_empty_symbol = cli_args
|
||||||
|
.get_one::<String>("bar_empty_symbol")
|
||||||
let lt_format = Some(match cli_args.value_of("localtime") {
|
.map(|s| s.to_string());
|
||||||
Some(format) => format.to_string(),
|
|
||||||
None => "%H:%M".to_string(),
|
|
||||||
});
|
|
||||||
let ut_format = Some(match cli_args.value_of("utctime") {
|
|
||||||
Some(format) => format.to_string(),
|
|
||||||
None => "%H:%M".to_string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut cfg = Config {
|
let mut cfg = Config {
|
||||||
action: Action::Cpu,
|
action: Action::Cpu,
|
||||||
mpd_server: cli_args.value_of("mpd_address").unwrap().to_string(),
|
mpd_server: cli_args
|
||||||
lt_format: lt_format,
|
.get_one::<String>("mpd_address")
|
||||||
ut_format: ut_format,
|
.unwrap()
|
||||||
color_low: colorize(cli_args.value_of("COLOR_LOW").unwrap().to_string()),
|
.to_string(),
|
||||||
color_mid: colorize(cli_args.value_of("COLOR_MID").unwrap().to_string()),
|
lt_format,
|
||||||
color_high: colorize(cli_args.value_of("COLOR_HIGH").unwrap().to_string()),
|
ut_format,
|
||||||
color_track_name: colorize(cli_args.value_of("COLOR_TRACK_NAME").unwrap().to_string()),
|
bar_symbol,
|
||||||
color_track_artist: colorize(cli_args.value_of("COLOR_TRACK_ARTIST").unwrap().to_string()),
|
bar_empty_symbol,
|
||||||
color_track_time: colorize(cli_args.value_of("COLOR_TRACK_TIME").unwrap().to_string()),
|
low_threshold: *cli_args.get_one::<f32>("low").unwrap(),
|
||||||
color_end: colorize(cli_args.value_of("COLOR_END").unwrap().to_string()),
|
mid_threshold: *cli_args.get_one::<f32>("mid").unwrap(),
|
||||||
|
color_low: colorize(cli_args.get_one::<String>("COLOR_LOW").unwrap().to_string()),
|
||||||
|
color_mid: colorize(cli_args.get_one::<String>("COLOR_MID").unwrap().to_string()),
|
||||||
|
color_high: colorize(
|
||||||
|
cli_args
|
||||||
|
.get_one::<String>("COLOR_HIGH")
|
||||||
|
.unwrap()
|
||||||
|
.to_string(),
|
||||||
|
),
|
||||||
|
color_track_name: colorize(
|
||||||
|
cli_args
|
||||||
|
.get_one::<String>("COLOR_TRACK_NAME")
|
||||||
|
.unwrap()
|
||||||
|
.to_string(),
|
||||||
|
),
|
||||||
|
color_track_artist: colorize(
|
||||||
|
cli_args
|
||||||
|
.get_one::<String>("COLOR_TRACK_ARTIST")
|
||||||
|
.unwrap()
|
||||||
|
.to_string(),
|
||||||
|
),
|
||||||
|
color_track_time: colorize(
|
||||||
|
cli_args
|
||||||
|
.get_one::<String>("COLOR_TRACK_TIME")
|
||||||
|
.unwrap()
|
||||||
|
.to_string(),
|
||||||
|
),
|
||||||
|
color_end: colorize(cli_args.get_one::<String>("COLOR_END").unwrap().to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if cli_args.is_present("cpu") {
|
if cli_args.get_flag("cpu") {
|
||||||
cfg.action = Action::Cpu;
|
cfg.action = Action::Cpu;
|
||||||
}
|
}
|
||||||
if cli_args.is_present("mem") {
|
if cli_args.get_flag("mem") {
|
||||||
cfg.action = Action::Mem;
|
cfg.action = Action::Mem;
|
||||||
}
|
}
|
||||||
if cli_args.is_present("localtime") {
|
if cli_args.contains_id("localtime") {
|
||||||
cfg.action = Action::Localtime;
|
cfg.action = Action::Localtime;
|
||||||
}
|
}
|
||||||
if cli_args.is_present("utctime") {
|
if cli_args.contains_id("utctime") {
|
||||||
cfg.action = Action::Utctime;
|
cfg.action = Action::Utctime;
|
||||||
}
|
}
|
||||||
if cli_args.is_present("mpris") {
|
if cli_args.get_flag("mpris") {
|
||||||
cfg.action = Action::Mpris;
|
cfg.action = Action::Mpris;
|
||||||
}
|
}
|
||||||
if cli_args.is_present("mpd") {
|
if cli_args.get_flag("mpd") {
|
||||||
cfg.action = Action::Mpd;
|
cfg.action = Action::Mpd;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg
|
cfg
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/main.rs
23
src/main.rs
@@ -1,27 +1,18 @@
|
|||||||
extern crate chrono;
|
|
||||||
extern crate dbus;
|
|
||||||
extern crate mpd;
|
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct TrackInfo {
|
pub struct TrackInfo {
|
||||||
title: String,
|
pub title: String,
|
||||||
artist: String,
|
pub artist: String,
|
||||||
position: String,
|
pub position: String,
|
||||||
duration: String,
|
pub duration: String,
|
||||||
status: String,
|
pub status: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let conf = config::read();
|
let conf = config::read();
|
||||||
// cpu - cpu usage bar
|
|
||||||
// mem - mem usage bar
|
|
||||||
// mpris - player info using MPRIS2 interface
|
|
||||||
// mpd - player info using MPD native interface
|
|
||||||
// utctime - utc time
|
|
||||||
// localtime - local time
|
|
||||||
match conf.action {
|
match conf.action {
|
||||||
config::Action::Cpu => utils::cpu_load_bar(15, &conf),
|
config::Action::Cpu => utils::cpu_load_bar(15, &conf),
|
||||||
config::Action::Mem => utils::mem_load_bar(15, &conf),
|
config::Action::Mem => utils::mem_load_bar(15, &conf),
|
||||||
|
|||||||
340
src/utils.rs
340
src/utils.rs
@@ -1,6 +1,7 @@
|
|||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::dbus::blocking::stdintf::org_freedesktop_dbus::Properties;
|
use chrono::{Local, Utc};
|
||||||
use chrono::{DateTime, Local, Utc};
|
use dbus::arg::RefArg;
|
||||||
|
use dbus::blocking::stdintf::org_freedesktop_dbus::Properties;
|
||||||
use dbus::{arg, blocking::Connection};
|
use dbus::{arg, blocking::Connection};
|
||||||
use mpd::Client;
|
use mpd::Client;
|
||||||
use size_format::SizeFormatterBinary;
|
use size_format::SizeFormatterBinary;
|
||||||
@@ -10,199 +11,157 @@ use sys_info;
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TrackInfo {
|
pub struct TrackInfo {
|
||||||
title: String,
|
pub title: String,
|
||||||
artist: String,
|
pub artist: String,
|
||||||
position: String,
|
pub position: String,
|
||||||
duration: String,
|
pub duration: String,
|
||||||
status: String,
|
pub status: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_bar(value: i32, max: i32, low: f32, mid: f32, config: &config::Config) {
|
pub fn to_bar(value: i32, max: i32, low: f32, mid: f32, config: &config::Config) {
|
||||||
let mut bar = "".to_string();
|
let mut bar = "".to_string();
|
||||||
let bar_sym = "▮".to_string();
|
let ratio = (value as f32) / (max as f32);
|
||||||
if (value as f32) / (max as f32) < low {
|
bar.push_str(if ratio < low {
|
||||||
bar.push_str(&config.color_low);
|
&config.color_low
|
||||||
} else if (value as f32) / (max as f32) < mid {
|
} else if ratio < mid {
|
||||||
bar.push_str(&config.color_mid);
|
&config.color_mid
|
||||||
} else {
|
} else {
|
||||||
bar.push_str(&config.color_high);
|
&config.color_high
|
||||||
}
|
});
|
||||||
|
let symbol = config.bar_symbol.as_deref().unwrap_or("█");
|
||||||
|
let empty = config.bar_empty_symbol.as_deref().unwrap_or(" ");
|
||||||
for i in 0..max {
|
for i in 0..max {
|
||||||
if i < value as i32 {
|
bar.push_str(if i < value { symbol } else { empty });
|
||||||
bar.push_str(&bar_sym);
|
|
||||||
} else {
|
|
||||||
bar.push_str(" ")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bar.push_str(&config.color_end);
|
bar.push_str(&config.color_end);
|
||||||
bar.push_str("|");
|
bar.push('|');
|
||||||
print!("{}", bar)
|
print!("{}", bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mem_load_bar(bar_len: i32, config: &config::Config) {
|
pub fn mem_load_bar(bar_len: i32, config: &config::Config) {
|
||||||
let memory;
|
let memory = sys_info::mem_info().expect("Failed to get mem_info");
|
||||||
match sys_info::mem_info() {
|
let used_ratio = (memory.total - memory.avail) as f32 / memory.total as f32;
|
||||||
Err(w) => panic!("{:?}", w),
|
let len = (used_ratio * bar_len as f32) as i32;
|
||||||
Ok(mem_data) => memory = mem_data,
|
to_bar(
|
||||||
}
|
len,
|
||||||
let len =
|
bar_len,
|
||||||
((memory.total - memory.avail) as f32 / (memory.total as f32) * bar_len as f32) as i32;
|
config.low_threshold,
|
||||||
to_bar(len, bar_len, 0.7, 0.9, config);
|
config.mid_threshold,
|
||||||
|
config,
|
||||||
|
);
|
||||||
print!(
|
print!(
|
||||||
"{}B #[default]",
|
"{}B #[default]",
|
||||||
SizeFormatterBinary::new((memory.avail * 1000) as u64)
|
SizeFormatterBinary::new((memory.avail * 1024) as u64)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cpu_load_bar(bar_len: i32, config: &config::Config) {
|
pub fn cpu_load_bar(bar_len: i32, config: &config::Config) {
|
||||||
let cpu_count = match sys_info::cpu_num() {
|
let cpu_count = sys_info::cpu_num().expect("Failed to get cpu_num");
|
||||||
Ok(c) => c,
|
let la_one = sys_info::loadavg().expect("Failed to get loadavg").one;
|
||||||
Err(e) => panic!("{:?}", e),
|
let len = (la_one / cpu_count as f64 * bar_len as f64).round() as i32;
|
||||||
};
|
to_bar(
|
||||||
let la_one: f32 = match sys_info::loadavg() {
|
len,
|
||||||
Ok(l) => l.one as f32,
|
bar_len,
|
||||||
Err(e) => panic!("{:?}", e),
|
config.low_threshold,
|
||||||
};
|
config.mid_threshold,
|
||||||
let len: f32 = la_one as f32 / cpu_count as f32 * bar_len as f32;
|
config,
|
||||||
to_bar(len as i32, bar_len, 0.3, 0.7, config);
|
);
|
||||||
|
|
||||||
print!("{:.2} LA1#[default]", la_one);
|
print!("{:.2} LA1#[default]", la_one);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_player() -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
pub fn get_player() -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||||
let conn = Connection::new_session()?;
|
let conn = Connection::new_session()?;
|
||||||
let proxy = conn.with_proxy("org.freedesktop.DBus", "/", Duration::from_millis(5000));
|
let proxy = conn.with_proxy("org.freedesktop.DBus", "/", Duration::from_secs(5));
|
||||||
let (names,): (Vec<String>,) = proxy.method_call("org.freedesktop.DBus", "ListNames", ())?;
|
let (names,): (Vec<String>,) = proxy.method_call("org.freedesktop.DBus", "ListNames", ())?;
|
||||||
let mut players: Vec<String> = Vec::new();
|
Ok(names
|
||||||
for name in names {
|
.into_iter()
|
||||||
if name.contains("org.mpris.MediaPlayer2") {
|
.filter(|n| n.contains("org.mpris.MediaPlayer2"))
|
||||||
players.push(name);
|
.collect())
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(players)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn player_info(players: Vec<String>) -> Result<TrackInfo, Box<dyn std::error::Error>> {
|
pub fn player_info(players: Vec<String>) -> Result<TrackInfo, Box<dyn std::error::Error>> {
|
||||||
let mut players_vec: Vec<TrackInfo> = Vec::new();
|
|
||||||
for player in players {
|
for player in players {
|
||||||
let mut track_info = TrackInfo {
|
|
||||||
artist: "".to_string(),
|
|
||||||
title: "".to_string(),
|
|
||||||
position: "".to_string(),
|
|
||||||
duration: "".to_string(),
|
|
||||||
status: "".to_string(),
|
|
||||||
};
|
|
||||||
let conn = Connection::new_session()?;
|
let conn = Connection::new_session()?;
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(player, "/org/mpris/MediaPlayer2", Duration::from_secs(5));
|
||||||
player,
|
let metadata: arg::PropMap = proxy.get("org.mpris.MediaPlayer2.Player", "Metadata")?;
|
||||||
"/org/mpris/MediaPlayer2",
|
|
||||||
Duration::from_millis(5000),
|
let title = metadata
|
||||||
);
|
.get("xesam:title")
|
||||||
let metadata: Box<dyn arg::RefArg> =
|
.and_then(|v| v.as_str())
|
||||||
proxy.get("org.mpris.MediaPlayer2.Player", "Metadata")?;
|
.unwrap_or("")
|
||||||
let mut iter = metadata.as_iter().unwrap();
|
.to_string();
|
||||||
while let Some(key) = iter.next() {
|
let artist = metadata
|
||||||
if key.as_str() == Some("xesam:title") {
|
.get("xesam:artist")
|
||||||
if let Some(title) = iter.next().unwrap().as_str() {
|
.and_then(|v| v.as_iter())
|
||||||
track_info.title = title.to_string();
|
.and_then(|mut artists| artists.next().and_then(|a| a.as_str()))
|
||||||
}
|
.unwrap_or("")
|
||||||
}
|
.to_string();
|
||||||
if key.as_str() == Some("mpris:length") {
|
let duration_us = metadata
|
||||||
if let Some(length) = iter.next().unwrap().as_i64() {
|
.get("mpris:length")
|
||||||
track_info.duration = format_time(length / 1000000);
|
.and_then(|v| v.as_i64())
|
||||||
}
|
.unwrap_or(0);
|
||||||
}
|
let position_us: i64 = proxy.get("org.mpris.MediaPlayer2.Player", "Position")?;
|
||||||
if key.as_str() == Some("xesam:artist") {
|
let status_text: String = proxy.get("org.mpris.MediaPlayer2.Player", "PlaybackStatus")?;
|
||||||
if let Some(mut artists) = iter.next().unwrap().as_iter() {
|
|
||||||
while let Some(artist) = artists.next() {
|
let status = match status_text.as_str() {
|
||||||
if let Some(mut line) = artist.as_iter() {
|
"Playing" => "▶",
|
||||||
track_info.artist = line.next().unwrap().as_str().unwrap().to_string();
|
"Paused" => "⏸",
|
||||||
}
|
_ => "⏹",
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let position: Box<dyn arg::RefArg> =
|
.to_string();
|
||||||
proxy.get("org.mpris.MediaPlayer2.Player", "Position")?;
|
|
||||||
track_info.position = format_time(position.as_i64().unwrap() / 1000000);
|
let track_info = TrackInfo {
|
||||||
// ugly
|
title,
|
||||||
let _status_text_box: Box<dyn arg::RefArg> =
|
artist,
|
||||||
proxy.get("org.mpris.MediaPlayer2.Player", "PlaybackStatus")?;
|
position: format_time(position_us / 1_000_000),
|
||||||
let _status_text = _status_text_box.as_str().unwrap();
|
duration: format_time(duration_us / 1_000_000),
|
||||||
match _status_text.as_ref() {
|
status,
|
||||||
"Playing" => track_info.status = "▶".to_string(),
|
|
||||||
"Paused" => track_info.status = "⏸".to_string(),
|
|
||||||
_ => track_info.status = "⏹".to_string(),
|
|
||||||
};
|
};
|
||||||
players_vec.push(track_info);
|
|
||||||
}
|
if track_info.status == "▶" {
|
||||||
for player in &players_vec {
|
return Ok(track_info);
|
||||||
if player.status == "▶".to_string() {
|
|
||||||
return Ok(player.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(players_vec[players_vec.len() - 1].clone())
|
Err("No active player".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format_time(sec: i64) -> String {
|
pub fn format_time(sec: i64) -> String {
|
||||||
let minutes = sec / 60;
|
format!("{:02}:{:02}", sec / 60, sec % 60)
|
||||||
let secondes = sec % 60;
|
|
||||||
let result = format!("{:02}:{:02}", minutes, secondes);
|
|
||||||
result.to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_time(utc: bool, format: Option<String>) {
|
pub fn get_time(utc: bool, format: Option<String>) {
|
||||||
// Format reference: https://docs.rs/chrono/0.4.10/chrono/format/strftime/index.html
|
let fmt = format.unwrap_or_else(|| "%H:%M".to_string());
|
||||||
let fmt = match format {
|
let now = if utc {
|
||||||
Some(format) => format,
|
Utc::now().format(&fmt)
|
||||||
None => "%H:%M".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if utc {
|
|
||||||
let local_time = Local::now();
|
|
||||||
let utc_time = DateTime::<Utc>::from_utc(local_time.naive_utc(), Utc);
|
|
||||||
println!("{}", utc_time.format(&fmt));
|
|
||||||
} else {
|
} else {
|
||||||
let local_time = Local::now();
|
Local::now().format(&fmt)
|
||||||
println!("{}", local_time.format(&fmt));
|
};
|
||||||
}
|
println!("{}", now);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shorten(line: String, max_len: usize, max_shift: usize) -> String {
|
fn shorten(line: &str, max_len: usize) -> String {
|
||||||
let mut new_line = String::new();
|
if line.chars().count() > max_len {
|
||||||
let len = if max_len + max_shift >= line.chars().count() {
|
format!("{}..", line.chars().take(max_len).collect::<String>())
|
||||||
line.chars().count()
|
|
||||||
} else {
|
} else {
|
||||||
max_len
|
line.to_string()
|
||||||
};
|
|
||||||
if line.len() > len {
|
|
||||||
let mut counter = 0;
|
|
||||||
for ch in line.chars() {
|
|
||||||
if counter == len {
|
|
||||||
new_line.push_str("..");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
new_line.push(ch);
|
|
||||||
counter += 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
new_line = line;
|
|
||||||
}
|
}
|
||||||
new_line
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_player(track_info: TrackInfo, config: &config::Config) {
|
fn format_player(track_info: TrackInfo, config: &config::Config) {
|
||||||
let mut separator: String = " — ".to_string();
|
let separator = if track_info.artist.is_empty() {
|
||||||
let mut max_len = 30;
|
""
|
||||||
if track_info.artist.chars().count() == 0 {
|
} else {
|
||||||
separator = "".to_string();
|
" — "
|
||||||
max_len = max_len * 2;
|
};
|
||||||
}
|
let max_len = if track_info.artist.is_empty() { 60 } else { 30 };
|
||||||
let artist_line = shorten(track_info.artist, max_len, 6);
|
|
||||||
let title_line = shorten(track_info.title, max_len, 6);
|
let artist_line = shorten(&track_info.artist, max_len);
|
||||||
if track_info.position == "00:00" || track_info.duration == "" {
|
let title_line = shorten(&track_info.title, max_len);
|
||||||
|
|
||||||
|
if track_info.position == "00:00" || track_info.duration.is_empty() {
|
||||||
println!(
|
println!(
|
||||||
"#[none]#[bold]{}{}{}#[none]{}{}{}{} {}{} {}#[default]",
|
"#[bold]{}{}{}{}{}{} {}{} {}#[default]",
|
||||||
config.color_track_name,
|
config.color_track_name,
|
||||||
title_line,
|
title_line,
|
||||||
config.color_end,
|
config.color_end,
|
||||||
@@ -211,12 +170,11 @@ fn format_player(track_info: TrackInfo, config: &config::Config) {
|
|||||||
artist_line,
|
artist_line,
|
||||||
config.color_end,
|
config.color_end,
|
||||||
config.color_track_time,
|
config.color_track_time,
|
||||||
track_info.status,
|
track_info.status
|
||||||
config.color_end,
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"#[none]#[bold]{}{}{}#[none]{}{}{}{} {}[{}/{}] {} {}#[default]",
|
"#[bold]{}{}{}{}{}{} {}[{}/{}] {}{}{}#[default]",
|
||||||
config.color_track_name,
|
config.color_track_name,
|
||||||
title_line,
|
title_line,
|
||||||
config.color_end,
|
config.color_end,
|
||||||
@@ -228,60 +186,52 @@ fn format_player(track_info: TrackInfo, config: &config::Config) {
|
|||||||
track_info.position,
|
track_info.position,
|
||||||
track_info.duration,
|
track_info.duration,
|
||||||
track_info.status,
|
track_info.status,
|
||||||
config.color_end,
|
config.color_end
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mpris(config: &config::Config) {
|
pub fn mpris(config: &config::Config) {
|
||||||
match player_info(get_player().unwrap()) {
|
match player_info(get_player().unwrap_or_default()) {
|
||||||
Ok(track_info) => format_player(track_info, config),
|
Ok(track_info) => format_player(track_info, config),
|
||||||
Err(_e) => println!("No music playing"),
|
Err(_) => println!("No music playing"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mpd(config: &config::Config) {
|
pub fn mpd(config: &config::Config) {
|
||||||
let mut conn = match Client::connect(&config.mpd_server) {
|
let mut conn = Client::connect(&config.mpd_server).unwrap_or_else(|e| {
|
||||||
Ok(conn) => conn,
|
println!("Can't connect to MPD server. {}", e);
|
||||||
Err(e) => {
|
process::exit(1);
|
||||||
println!("Can't connect to MPD server. {}", e);
|
});
|
||||||
process::exit(0x0001)
|
|
||||||
|
let song = conn.currentsong().unwrap_or(None);
|
||||||
|
let status = conn.status().unwrap();
|
||||||
|
|
||||||
|
let artist = song
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|s| s.tags.iter().find(|(k, _)| k == "Artist").map(|(_, v)| v))
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let title = song
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|s| s.title.clone().or_else(|| s.name.clone()))
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let (position, duration) = status.time.unwrap_or_default();
|
||||||
|
|
||||||
|
let track_info = TrackInfo {
|
||||||
|
title,
|
||||||
|
artist,
|
||||||
|
position: format_time(position.as_secs() as i64),
|
||||||
|
duration: format_time(duration.as_secs() as i64),
|
||||||
|
status: match status.state {
|
||||||
|
mpd::State::Play => "▶",
|
||||||
|
mpd::State::Pause => "⏸",
|
||||||
|
mpd::State::Stop => "⏹",
|
||||||
}
|
}
|
||||||
|
.to_string(),
|
||||||
};
|
};
|
||||||
let mut track_info = TrackInfo {
|
|
||||||
title: String::new(),
|
format_player(track_info, config);
|
||||||
artist: String::new(),
|
|
||||||
position: String::new(),
|
|
||||||
duration: String::new(),
|
|
||||||
status: String::new(),
|
|
||||||
};
|
|
||||||
// println!("{:?}", conn.currentsong());
|
|
||||||
if let Some(song) = conn.currentsong().unwrap() {
|
|
||||||
if let Some(title) = song.title {
|
|
||||||
track_info.title = title
|
|
||||||
}
|
|
||||||
if let Some(artist) = song.tags.get("Artist") {
|
|
||||||
track_info.artist = artist.to_string()
|
|
||||||
}
|
|
||||||
// if there is no tags and title.
|
|
||||||
if track_info.artist == track_info.title {
|
|
||||||
if let Some(name) = song.name {
|
|
||||||
track_info.title = name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(time) = conn.status().unwrap().time {
|
|
||||||
track_info.position = format_time(time.0.num_seconds() as i64);
|
|
||||||
track_info.duration = format_time(time.1.num_seconds() as i64);
|
|
||||||
}
|
|
||||||
let status = match conn.status() {
|
|
||||||
Ok(status) => match status.state {
|
|
||||||
mpd::State::Play => "▶".to_string(),
|
|
||||||
mpd::State::Pause => "⏸".to_string(),
|
|
||||||
mpd::State::Stop => "⏹".to_string(),
|
|
||||||
},
|
|
||||||
Err(_) => "⏹".to_string(),
|
|
||||||
};
|
|
||||||
track_info.status = status;
|
|
||||||
format_player(track_info, config)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user