Some easy of access + readme
This commit is contained in:
parent
c9a14a9b1d
commit
21a52e65eb
@ -1,3 +1,3 @@
|
|||||||
DISCORD_APP_ID=
|
DISCORD_APP_ID="906984497524903937"
|
||||||
LASTFM_USERNAME=
|
LASTFM_API_KEY="71e8ca3f186b0a68342577b4401658e4"
|
||||||
LASTFM_API_KEY=
|
LASTFM_USERNAME="strnophix"
|
||||||
|
29
README.md
29
README.md
@ -1,2 +1,29 @@
|
|||||||
# lfm-discord-presence
|
# lfm-discord-presence
|
||||||
Discord RPC for LastFM
|
Discord Rich Presence for LastFM.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 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
BIN
assets/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
24
justfile
24
justfile
@ -1,6 +1,24 @@
|
|||||||
load-dotenv:
|
load-dotenv:
|
||||||
set -a; source .env; set +a
|
set -a; source ./.env; set +a
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
cross build --target x86_64-pc-windows-gnu --release
|
cargo build --target x86_64-unknown-linux-gnu --release
|
||||||
cross 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
|
||||||
|
15
src/main.rs
15
src/main.rs
@ -13,19 +13,20 @@ use tokio::{
|
|||||||
sync::oneshot::{self, channel},
|
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]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
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 (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(
|
let _ipc_client = Arc::new(Mutex::new(
|
||||||
DiscordIpcClient::new(discord_app_id.as_str())
|
DiscordIpcClient::new(DISCORD_APP_ID).expect("failed to create Discord IPC-client"),
|
||||||
.expect("failed to create Discord IPC-client"),
|
|
||||||
));
|
));
|
||||||
let _ipc_client2 = Arc::clone(&_ipc_client);
|
let _ipc_client2 = Arc::clone(&_ipc_client);
|
||||||
|
|
||||||
|
11
systemd/lfm-discord-presence.service
Normal file
11
systemd/lfm-discord-presence.service
Normal 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
|
Loading…
x
Reference in New Issue
Block a user