Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use relative path instead of cwd for credentials.ini file #78

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Plex Rich Presence alternatives:
4. In the [Discord Developer Dashboard](https://discord.com/developers/applications), within your application and under **Rich Presence** -> **Art Assets**, upload the application images, either the ones located in `/images` or ones that you choose to submit (as long as the keys for those images stay `shows` and `movies`).
5. Run the respective executable, and you're ready to start sharing your progress!

*P.S.* Discord needs to be running on the machine Discrakt is running on.
*P.S.* Discord needs to be running on the machine Discrakt is running on.
*P.P.S.* Place the `credentials.ini` file in the same directory as the executable.

## Running executables

Expand All @@ -55,7 +56,7 @@ You can now use the silent Windows executable, and now you only need to follow [

#### Scoop

You can install discrakt in [Scoop](https://scoop.sh/) via the [Extras](https://github.com/ScoopInstaller/Extras) bucket:
You can install Discrakt in [Scoop](https://scoop.sh/) via the [Extras](https://github.com/ScoopInstaller/Extras) bucket:
```powershell
scoop bucket add extras # Ensure bucket is added first
scoop install discrakt
Expand Down
Binary file modified images/demo/profile-status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Discord {
Assets::new()
.large_image(&img)
.small_image("trakt")
.small_text("Trakt.tv"),
.small_text("Discrakt"),
)
.timestamps(
Timestamps::new()
Expand Down
18 changes: 12 additions & 6 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::{DateTime, FixedOffset, SecondsFormat, Utc};
use configparser::ini::Ini;
use serde::Deserialize;
use std::{io, time::Duration};
use std::{env, io, time::Duration};
use ureq::AgentBuilder;

#[derive(Deserialize)]
Expand Down Expand Up @@ -143,7 +143,11 @@ impl Env {

pub fn load_config() -> Env {
let mut config = Ini::new();
config.load("credentials.ini").unwrap();
let mut path = env::current_exe().unwrap();
path.pop();
path.push("credentials.ini");

config.load(path).expect("Failed to load credentials.ini");

Env {
discord_client_id: "826189107046121572".to_string(),
Expand Down Expand Up @@ -171,8 +175,12 @@ pub fn load_config() -> Env {

fn set_oauth_tokens(json_response: &TraktAccessToken) {
let mut config = Ini::new_cs();
let mut path = env::current_exe().unwrap();
path.pop();
path.push("credentials.ini");

config
.load("credentials.ini")
.load(path.clone())
.expect("Failed to load credentials.ini");
config.setstr(
"Trakt API",
Expand All @@ -189,9 +197,7 @@ fn set_oauth_tokens(json_response: &TraktAccessToken) {
"OAuthRefreshTokenExpiresAt",
Some(json_response.created_at.to_string()),
);
config
.write("credentials.ini")
.expect("Failed to write credentials.ini");
config.write(path).expect("Failed to write credentials.ini");
}

pub fn log(message: &str) {
Expand Down
Loading