home-manager module
This commit is contained in:
parent
ae824fcb47
commit
f909e8c6b7
6 changed files with 103 additions and 19 deletions
|
@ -6,8 +6,15 @@ use std::io::Write;
|
|||
use std::process;
|
||||
use tracing::info;
|
||||
|
||||
// okay i don't like this.
|
||||
// we have to please the ini parser though!!
|
||||
#[derive(Deserialize)]
|
||||
pub struct Config {
|
||||
pub global: GlobalConfig
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct GlobalConfig {
|
||||
pub player_bus: Option<String>,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
|
|
|
@ -4,9 +4,9 @@ use rustfm_scrobble_proxy::Scrobbler;
|
|||
use tracing::info;
|
||||
|
||||
pub fn get_scrobbler(config: &Config) -> Result<Scrobbler> {
|
||||
let mut scrobbler = Scrobbler::new(&config.api_key, &config.api_secret);
|
||||
let mut scrobbler = Scrobbler::new(&config.global.api_key, &config.global.api_secret);
|
||||
scrobbler
|
||||
.authenticate_with_password(&config.username, &config.password)
|
||||
.authenticate_with_password(&config.global.username, &config.global.password)
|
||||
.context("failed to authenticate")?;
|
||||
|
||||
info!(" successfully authenticated");
|
||||
|
|
|
@ -15,9 +15,9 @@ pub fn is_active(player: &Player) -> bool {
|
|||
}
|
||||
|
||||
pub fn is_whitelisted(config: &Config, player: &Player) -> bool {
|
||||
if Some(player.bus_name()) == config.player_bus.as_deref() {
|
||||
if Some(player.bus_name()) == config.global.player_bus.as_deref() {
|
||||
return true
|
||||
} else if config.player_bus.is_none() {
|
||||
} else if config.global.player_bus.is_none() {
|
||||
return player.bus_name().starts_with(MPRIS_BUS_PREFIX)
|
||||
} else {
|
||||
return false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue