Some easy of access + readme

This commit is contained in:
niku 2023-04-09 12:17:17 +02:00
parent c9a14a9b1d
commit 21a52e65eb
6 changed files with 71 additions and 14 deletions

View File

@ -1,3 +1,3 @@
DISCORD_APP_ID=
LASTFM_USERNAME=
LASTFM_API_KEY=
DISCORD_APP_ID="906984497524903937"
LASTFM_API_KEY="71e8ca3f186b0a68342577b4401658e4"
LASTFM_USERNAME="strnophix"

View File

@ -1,2 +1,29 @@
# lfm-discord-presence
Discord RPC for LastFM
Discord Rich Presence for LastFM.
![](./assets/screenshot.png)
## Dependencies
- [Rust](https://www.rust-lang.org/)
- [Just](https://github.com/casey/just)
## Usage
### Setup
```bash
git clone https://git.cesium.pw/niku/lfm-discord-presence.git && cd $_
cp .env.sample .env
```
### Using systemd
Install:
```bash
just install
```
Uninstall:
```bash
just uninstall
```
### Using cargo
```bash
cargo run <lastfm-username>
```

BIN
assets/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,6 +1,24 @@
load-dotenv:
set -a; source .env; set +a
set -a; source ./.env; set +a
build-release:
cross build --target x86_64-pc-windows-gnu --release
cross build --target x86_64-unknown-linux-gnu --release
cargo build --target x86_64-unknown-linux-gnu --release
install:
just build-release
sudo cp ./target/x86_64-unknown-linux-gnu/release/lfm-discord-presence /usr/local/bin
mkdir -p ~/.config/systemd/user
cp ./systemd/lfm-discord-presence.service ~/.config/systemd/user
sed -i "s/LASTFM_USERNAME/$LASTFM_USERNAME/g" ~/.config/systemd/user/lfm-discord-presence.service
systemctl enable --user lfm-discord-presence.service --now
uninstall:
systemctl disable --user lfm-discord-presence.service --now
sudo rm /usr/local/bin/lfm-discord-presence
reinstall:
just uninstall
just install

View File

@ -13,19 +13,20 @@ use tokio::{
sync::oneshot::{self, channel},
};
const DISCORD_APP_ID: &'static str = env!("DISCORD_APP_ID", "Missing DISCORD_APP_ID in env");
const LFM_API_KEY: &'static str = env!("LASTFM_API_KEY", "Missing LASTFM_API_KEY in env");
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let discord_app_id = env::var("DISCORD_APP_ID").expect("Missing DISCORD_APP_ID in env");
let lfm_username = env::var("LASTFM_USERNAME").expect("Missing LASTFM_USERNAME in env");
let lfm_api_key = env::var("LASTFM_API_KEY").expect("Missing LASTFM_API_KEY in env");
let (send_stop, mut recv_stop) = channel::<()>();
let mut lfm = lastfm_rs::Client::new(lfm_api_key.as_str());
let lfm_username = std::env::args()
.nth(1)
.expect("No LastFM username provided");
let mut lfm = lastfm_rs::Client::new(LFM_API_KEY);
let _ipc_client = Arc::new(Mutex::new(
DiscordIpcClient::new(discord_app_id.as_str())
.expect("failed to create Discord IPC-client"),
DiscordIpcClient::new(DISCORD_APP_ID).expect("failed to create Discord IPC-client"),
));
let _ipc_client2 = Arc::clone(&_ipc_client);

View File

@ -0,0 +1,11 @@
[Unit]
Description=Discord Rich Presence for LastFM
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/lfm-discord-presence LASTFM_USERNAME
Restart=always
[Install]
WantedBy=multi-user.target