Compare commits
11 commits
process_du
...
master
Author | SHA1 | Date | |
---|---|---|---|
bd015a83f6 | |||
037ab2d409 | |||
![]() |
d43af93c99 | ||
![]() |
d2d00497e1 | ||
e362382cae | |||
bb8c4a9cda | |||
70c20c9e3c | |||
f910b29a6b | |||
9e83feb07e | |||
bc8fc48033 | |||
23d282ff12 |
16 changed files with 304 additions and 245 deletions
15
.drp_config
15
.drp_config
|
@ -1,15 +0,0 @@
|
|||
SHOULD_EXCLUDE_BE_ANONYMOUS:{
|
||||
n
|
||||
}
|
||||
|
||||
PORTFOLIO_LINK:{
|
||||
djkato.net
|
||||
}
|
||||
|
||||
EXCLUDE_CHARACTERS_LIST:{
|
||||
no_drp
|
||||
}
|
||||
|
||||
HIDE_PORTFOLIO_ROW:{
|
||||
no
|
||||
}
|
113
Cargo.lock
generated
113
Cargo.lock
generated
|
@ -251,12 +251,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "drp_creative"
|
||||
version = "1.0.1"
|
||||
version = "1.0.4"
|
||||
dependencies = [
|
||||
"discord-rich-presence",
|
||||
"lazy_static",
|
||||
"regex",
|
||||
"self_update",
|
||||
"serde",
|
||||
"toml 0.7.6",
|
||||
"tray-item",
|
||||
"win-msgbox",
|
||||
"windows",
|
||||
|
@ -278,6 +280,12 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.1"
|
||||
|
@ -641,7 +649,7 @@ dependencies = [
|
|||
"futures-sink",
|
||||
"futures-util",
|
||||
"http",
|
||||
"indexmap",
|
||||
"indexmap 1.9.3",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
|
@ -654,6 +662,12 @@ version = "0.12.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
|
@ -763,7 +777,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
"hashbrown 0.12.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1014,7 +1038,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
|||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.15",
|
||||
"syn 2.0.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1123,7 +1147,7 @@ checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9"
|
|||
dependencies = [
|
||||
"once_cell",
|
||||
"thiserror",
|
||||
"toml",
|
||||
"toml 0.5.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1152,9 +1176,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.56"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
@ -1170,9 +1194,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.27"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500"
|
||||
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -1346,19 +1370,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.144"
|
||||
version = "1.0.170"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
|
||||
checksum = "a56657f512baabca8f840542f9ca8152aecf182c473c26e46e58d6aab4f6e439"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.144"
|
||||
version = "1.0.170"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
|
||||
checksum = "77d477848e6b23adba0db397777d5aad864555bc17fd9c89abb3b8009788b7b8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1372,6 +1399,15 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
|
@ -1422,9 +1458,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.15"
|
||||
version = "2.0.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
|
||||
checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1440,7 +1476,7 @@ dependencies = [
|
|||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"toml 0.5.9",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
|
@ -1557,6 +1593,40 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78"
|
||||
dependencies = [
|
||||
"indexmap 2.0.0",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.2"
|
||||
|
@ -2007,6 +2077,15 @@ dependencies = [
|
|||
"find-winsdk",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.5.1"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[package]
|
||||
name = "drp_creative"
|
||||
version = "1.0.1"
|
||||
version = "1.0.4"
|
||||
edition = "2021"
|
||||
author = "https://djkato.net"
|
||||
authors = ["djkatovfx@gmail.com"]
|
||||
|
||||
[dependencies]
|
||||
discord-rich-presence = "0.2.2"
|
||||
|
@ -11,6 +11,8 @@ tray-item = "0.7.0"
|
|||
lazy_static = "1.4.0"
|
||||
self_update = { version = "0.36.0", features = ["archive-zip"] }
|
||||
win-msgbox = "0.1.2"
|
||||
serde = { version = "1.0.170", features = ["derive"] }
|
||||
toml = "0.7.6"
|
||||
|
||||
[dependencies.windows]
|
||||
version = "0.39.0"
|
||||
|
|
1
FUNDING.yml
Normal file
1
FUNDING.yml
Normal file
|
@ -0,0 +1 @@
|
|||
ko_fi: djkato
|
38
README.md
38
README.md
|
@ -1,3 +1,4 @@
|
|||
<a href='https://ko-fi.com/A0A8Q3SVZ' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi4.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||
# Discord Rich Presence for Creative Apps
|
||||
### Show your friends what you're working on, be it in Adobe Suite, Autodesk Suite, Cinema 4D or many more!
|
||||
This app runs in the background and looks for processes, then parses the windows title and turns it into a project name to display with Discords Rich Presence.
|
||||
|
@ -6,7 +7,7 @@ Examples:
|
|||

|
||||

|
||||

|
||||
|
||||

|
||||
## how to install:
|
||||
1. Grab the latest version from the [Releases](https://github.com/djkato/DRP_Creative/releases) page, then make a folder in `C:/Program Files/` and call it whatever, for example `DRP Creative`.
|
||||
3. Put the exe inside the folder you created and create a link to it.
|
||||
|
@ -17,29 +18,21 @@ Examples:
|
|||
|
||||
## How to use:
|
||||
- App updates will be notified and suggested on startup via popup window.
|
||||
- When it's running, you'll notice a new icon appear on your Taskbar. If you want to exclude the **currently open project** from showing up, click on the icon and click on `Don't show current project`.
|
||||

|
||||
- When it's running, you'll notice a new icon appear on your Taskbar. If you want to include/exclude the **currently open project** from showing up, click on the icon and click on `Remove project from include/exclude list`.
|
||||
- There are two modes for the keywords list:
|
||||
1. Exclude(default): If the currently open project files name contains the keyword anywhere, it will show the default project name instead.
|
||||
2. Include: All projects will show default names, unless the the currently open project files name contains a keyword, then it will display the real name. This is a good alternative if you find yourself hiding more than showing what you're working on.
|
||||
- If you don't want to see the default project names, and instead just not display anything, you can change that behavior by setting `show_default_when_excluded` to `false` in the config file.
|
||||
- If you don't like the *"Portfolio: [your link]"* line on your status, you can disable it by setting `hide_portfolio_link` to `true`
|
||||
|
||||
- To change the portfolio website or remove excluded projects and words from the program, run the program at least once, and a `.drp_config` file will appear. You can open this with any text editor and rewrite the lines there. be gentle though, program expects a certain format for the file ^^'
|
||||
- To disable the portfolio row, there's a "HIDE_PORTFOLIO_ROW" setting.
|
||||
Example `drp_config.toml`:
|
||||
```toml
|
||||
keywords_list = ["WORK", "Untitled 681*"]
|
||||
show_default_when_excluded = true # or false
|
||||
portfolio_link = "djkato.net"
|
||||
hide_portfolio_row = false
|
||||
should_list_include_or_exclude = "Include" # Or "Exclude", capital sensitive
|
||||
|
||||
Example `.drp_config`:
|
||||
```json
|
||||
SHOULD_EXCLUDE_BE_ANONYMOUS:{
|
||||
n
|
||||
}
|
||||
|
||||
PORTFOLIO_LINK:{
|
||||
djkato.net
|
||||
}
|
||||
|
||||
EXCLUDE_CHARACTERS_LIST:{
|
||||
no_drp
|
||||
}
|
||||
|
||||
HIDE_PORTFOLIO_ROW:{
|
||||
no
|
||||
}
|
||||
```
|
||||
### Currently supported programs:
|
||||
**Full support:**
|
||||
|
@ -63,5 +56,6 @@ no
|
|||
- Substance Painter ¹*
|
||||
- Adobe Audition ¹*
|
||||
- ZBrush ¹*
|
||||
- Darktable ¹*
|
||||
|
||||
¹*sadly not doable, project name not in proces window title. They will show up though, just with default project name*
|
||||
|
|
5
drp_config.toml
Normal file
5
drp_config.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
keywords_list = []
|
||||
show_default_when_excluded = true
|
||||
portfolio_link = "djkato.net"
|
||||
hide_portfolio_row = false
|
||||
should_list_include_or_exclude = "Exclude"
|
2
log.txt
Normal file
2
log.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
'Process_list_dump.exe' is not recognized as an internal or external command,
|
||||
operable program or batch file.
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 26.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 256.4 256.4" style="enable-background:new 0 0 256.4 256.4;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#00005B;}
|
||||
.st1{fill:#9999FF;}
|
||||
</style>
|
||||
<g>
|
||||
<path class="st0" d="M65.9,34.1h124.7c18.9,0,34.2,15.3,34.2,34.2v119.9c0,18.9-15.3,34.2-34.2,34.2H65.9
|
||||
c-18.9,0-34.2-15.3-34.2-34.2V68.3C31.7,49.4,47,34.1,65.9,34.1z"/>
|
||||
<g>
|
||||
<path class="st1" d="M107.5,146.7H77.6l-6.1,19c-0.2,0.8-0.8,1.2-1.5,1.1H54.9c-0.9,0-1.1-0.5-0.9-1.4L79.9,91
|
||||
c0.2-0.8,0.5-1.7,0.8-2.6c0.4-1.7,0.7-3.4,0.7-5.1c-0.1-0.4,0.2-0.8,0.7-0.9c0.1,0,0.2,0,0.2,0h20.6c0.5,0,1,0.2,1.1,0.7
|
||||
l29.2,82.5c0.2,0.9,0,1.3-0.8,1.3h-16.8c-0.5,0.1-1.1-0.3-1.3-0.9L107.5,146.7z M82.3,130.7h20.4c-0.5-1.7-1.1-3.7-1.9-5.8
|
||||
c-0.8-2.2-1.4-4.5-2.2-6.9c-0.8-2.5-1.5-4.9-2.3-7.4s-1.5-4.8-2.2-7.2c-0.7-2.3-1.2-4.4-1.8-6.2h-0.2c-0.8,3.5-1.6,6.9-2.7,10.4
|
||||
c-1.2,3.8-2.4,7.9-3.7,11.9C84.8,123.5,83.5,127.3,82.3,130.7L82.3,130.7z"/>
|
||||
<path class="st1" d="M194.8,103.4v49.3c0,2.2,0,4.1,0.1,5.8c0.1,1.7,0.2,3.2,0.2,4.4c0.2,1.3,0.2,2,0.3,2.9
|
||||
c0.1,0.8-0.2,1.1-0.9,1.1h-13.8c-0.7,0.1-1.3-0.3-1.5-0.9c-0.2-0.7-0.3-1.4-0.5-2c-0.2-0.5-0.2-1.1-0.2-1.7c-2.6,2.3-5.7,4-9.1,5
|
||||
c-2.9,0.8-5.9,1.2-9,1.2s-5.9-0.4-8.7-1.4c-2.6-0.9-5-2.4-6.9-4.4c-2.1-2.3-3.6-4.9-4.5-7.8c-1.1-3.7-1.7-7.5-1.6-11.4v-39.9
|
||||
c-0.1-0.5,0.2-1,0.8-1.1c0.1,0,0.2,0,0.2,0h15.4c0.5-0.1,1,0.2,1.1,0.8c0,0.1,0,0.2,0,0.2v37.8c0,3.5,0.8,6.3,2.3,8.4
|
||||
c1.5,2,4.7,3.1,8.3,3.1c1.9,0,3.7-0.3,5.5-1c1.9-0.7,3.5-1.5,5-2.6v-45.7c0-0.5,0.4-0.9,1.1-0.9H194c0.4-0.1,0.9,0.2,0.9,0.7
|
||||
C194.8,103.3,194.8,103.4,194.8,103.4z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
BIN
program icons/after-effects.png
Normal file
BIN
program icons/after-effects.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
program icons/darktable.png
Normal file
BIN
program icons/darktable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
41
src/app.rs
41
src/app.rs
|
@ -31,6 +31,7 @@ pub enum AppKind {
|
|||
SubstanceDesigner,
|
||||
Vegas,
|
||||
ZBrush,
|
||||
Darktable,
|
||||
}
|
||||
|
||||
pub struct Apps {
|
||||
|
@ -54,10 +55,11 @@ pub struct Apps {
|
|||
SubstanceDesigner: App,
|
||||
Vegas: App,
|
||||
ZBrush: App,
|
||||
Darktable: App,
|
||||
}
|
||||
impl Apps {
|
||||
pub fn as_iter(&self) -> [&App; 20] {
|
||||
let APPS: [&App; 20] = [
|
||||
pub fn as_iter(&self) -> [&App; 21] {
|
||||
let APPS: [&App; 21] = [
|
||||
&self.C4d,
|
||||
&self.Maya,
|
||||
&self.ThreeDsMax,
|
||||
|
@ -78,13 +80,14 @@ impl Apps {
|
|||
&self.SubstanceDesigner,
|
||||
&self.Vegas,
|
||||
&self.ZBrush,
|
||||
&self.Darktable,
|
||||
];
|
||||
APPS
|
||||
}
|
||||
}
|
||||
impl AppKind {
|
||||
pub fn as_iter() -> [AppKind; 20] {
|
||||
let APPKINDS: [AppKind; 20] = [
|
||||
pub fn as_iter() -> [AppKind; 21] {
|
||||
let APPKINDS: [AppKind; 21] = [
|
||||
AppKind::C4d,
|
||||
AppKind::Maya,
|
||||
AppKind::ThreeDsMax,
|
||||
|
@ -105,6 +108,7 @@ impl AppKind {
|
|||
AppKind::SubstanceDesigner,
|
||||
AppKind::Vegas,
|
||||
AppKind::ZBrush,
|
||||
AppKind::Darktable,
|
||||
];
|
||||
APPKINDS
|
||||
}
|
||||
|
@ -232,6 +236,12 @@ impl Apps {
|
|||
drp_client_id: "1112734356855865425".to_string(),
|
||||
process_search_string: "ZBrush".to_string(),
|
||||
},
|
||||
Darktable: App {
|
||||
kind: AppKind::Darktable,
|
||||
default_project_name: "Darktable Project".to_string(),
|
||||
drp_client_id: "1116027286110609459".to_string(),
|
||||
process_search_string: "darktable.exe".to_string(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +249,10 @@ impl Apps {
|
|||
impl Apps {
|
||||
pub fn find_app(&self, str: &String) -> Option<&App> {
|
||||
for app in self.as_iter() {
|
||||
if str.contains(&app.process_search_string) {
|
||||
if str
|
||||
.to_lowercase()
|
||||
.contains(&app.process_search_string.to_lowercase())
|
||||
{
|
||||
return Some(&app);
|
||||
}
|
||||
}
|
||||
|
@ -251,20 +264,13 @@ impl App {
|
|||
pub fn parse(&self, window_title: &String) -> String {
|
||||
match self.kind {
|
||||
AppKind::C4d => {
|
||||
let mut end_i: usize = window_title.len();
|
||||
let mut start_i: usize = 0;
|
||||
for (i, char) in window_title.chars().enumerate() {
|
||||
if char == '[' {
|
||||
start_i = i;
|
||||
if let Some(curr_end_i) = window_title.rfind("] - ") {
|
||||
end_i = curr_end_i;
|
||||
} else {
|
||||
if let Some(split1) = window_title.rsplit_once("]") {
|
||||
if let Some(split2) = split1.0.rsplit_once("[") {
|
||||
return split2.1.to_string();
|
||||
}
|
||||
}
|
||||
return self.default_project_name.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
return window_title[start_i + 1..end_i].to_string();
|
||||
}
|
||||
AppKind::Maya => {
|
||||
let match_index = match window_title.as_str().find(".mb* - Autodesk Maya") {
|
||||
Some(i) => i + 5,
|
||||
|
@ -467,6 +473,7 @@ impl App {
|
|||
return window_title[..match_index as usize].to_string();
|
||||
}
|
||||
AppKind::ZBrush => self.default_project_name.clone(),
|
||||
AppKind::Darktable => self.default_project_name.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
201
src/config.rs
201
src/config.rs
|
@ -1,136 +1,91 @@
|
|||
use std::fs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
fs,
|
||||
io::{Read, Write},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub exclude_keywords_list: Vec<String>,
|
||||
pub should_exclude_be_invisible: bool,
|
||||
pub keywords_list: Vec<String>,
|
||||
pub show_default_when_excluded: bool,
|
||||
pub portfolio_link: String,
|
||||
pub hide_portfolio_row: bool,
|
||||
pub should_list_include_or_exclude: IncludeExclude,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Config {
|
||||
keywords_list: Vec::new(),
|
||||
should_list_include_or_exclude: IncludeExclude::Exclude,
|
||||
portfolio_link: "djkato.net".to_owned(),
|
||||
hide_portfolio_row: false,
|
||||
show_default_when_excluded: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum IncludeExclude {
|
||||
Include,
|
||||
Exclude,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load() -> Config {
|
||||
let default_config = use_default_config();
|
||||
|
||||
//if no config file, parse default config file and try save it, then use it
|
||||
let config_file: Config = match fs::read_to_string(".drp_config") {
|
||||
Result::Err(_err) => {
|
||||
let def_config = parse_config_file(&default_config);
|
||||
make_config_file(&def_config);
|
||||
def_config
|
||||
}
|
||||
Result::Ok(val) => parse_config_file(&val),
|
||||
};
|
||||
config_file
|
||||
}
|
||||
}
|
||||
impl Config {
|
||||
pub fn exclude_project(&mut self, project_name: &String) {
|
||||
if self.exclude_keywords_list.contains(&project_name) {
|
||||
pub fn add_project(&mut self, project_name: &String) {
|
||||
if self.keywords_list.contains(&project_name) {
|
||||
return;
|
||||
}
|
||||
self.exclude_keywords_list.push(project_name.clone());
|
||||
make_config_file(&self);
|
||||
}
|
||||
}
|
||||
fn parse_config_file(config_file: &String) -> Config {
|
||||
let mut exclude_keywords_list: Vec<String> = Vec::new();
|
||||
let mut should_exclude_be_invisible = false;
|
||||
let mut portfolio_link = String::new();
|
||||
let mut hide_portfolio_row = false;
|
||||
for (i, line) in config_file.lines().enumerate() {
|
||||
if line.contains("SHOULD_EXCLUDE_BE_ANONYMOUS:") {
|
||||
match config_file
|
||||
.lines()
|
||||
.nth(i + 1)
|
||||
.expect("index out of bounds")
|
||||
.to_lowercase()
|
||||
.as_str()
|
||||
.trim()
|
||||
{
|
||||
"n" => should_exclude_be_invisible = false,
|
||||
"no" => should_exclude_be_invisible = false,
|
||||
"y" => should_exclude_be_invisible = true,
|
||||
"yes" => should_exclude_be_invisible = true,
|
||||
_ => should_exclude_be_invisible = false,
|
||||
}
|
||||
}
|
||||
if line.contains("EXCLUDE_CHARACTERS_LIST:") {
|
||||
for arg_line in config_file.lines().skip(i + 1) {
|
||||
if arg_line.trim().contains("}") {
|
||||
break;
|
||||
}
|
||||
exclude_keywords_list.push(arg_line.to_string())
|
||||
}
|
||||
}
|
||||
if line.contains("PORTFOLIO_LINK:") {
|
||||
for arg_line in config_file.lines().skip(i) {
|
||||
if arg_line.trim().contains("}") {
|
||||
break;
|
||||
}
|
||||
portfolio_link = arg_line.to_string();
|
||||
}
|
||||
}
|
||||
if line.contains("HIDE_PORTFOLIO_ROW:") {
|
||||
match config_file
|
||||
.lines()
|
||||
.nth(i + 1)
|
||||
.expect("index out of bounds")
|
||||
.to_lowercase()
|
||||
.as_str()
|
||||
.trim()
|
||||
{
|
||||
"n" => hide_portfolio_row = false,
|
||||
"no" => hide_portfolio_row = false,
|
||||
"y" => hide_portfolio_row = true,
|
||||
"yes" => hide_portfolio_row = true,
|
||||
_ => hide_portfolio_row = false,
|
||||
}
|
||||
}
|
||||
}
|
||||
Config {
|
||||
exclude_keywords_list,
|
||||
should_exclude_be_invisible,
|
||||
portfolio_link,
|
||||
hide_portfolio_row,
|
||||
}
|
||||
self.keywords_list.push(project_name.clone());
|
||||
self.write();
|
||||
}
|
||||
|
||||
fn make_config_file(config: &Config) {
|
||||
let mut config_file = String::from("SHOULD_EXCLUDE_BE_ANONYMOUS:{");
|
||||
config_file = config_file
|
||||
+ match config.should_exclude_be_invisible {
|
||||
true => "\ny\n}\n",
|
||||
false => "\nn\n}\n",
|
||||
};
|
||||
|
||||
config_file = config_file + "\nPORTFOLIO_LINK:{\ndjkato.net\n}\n";
|
||||
|
||||
config_file = config_file + "\nEXCLUDE_CHARACTERS_LIST:{";
|
||||
for exclusive_word in &config.exclude_keywords_list {
|
||||
config_file = config_file + format!("\n{}", exclusive_word).as_str();
|
||||
}
|
||||
config_file = config_file + "\n}\n";
|
||||
|
||||
match fs::write(".drp_config", config_file) {
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn use_default_config() -> String {
|
||||
let str = String::from(
|
||||
"SHOULD_EXCLUDE_BE_ANONYMOUS:{
|
||||
n
|
||||
}
|
||||
|
||||
PORTFOLIO_LINK:{
|
||||
djkato.net
|
||||
}
|
||||
|
||||
EXCLUDE_CHARACTERS_LIST:{
|
||||
no_drp
|
||||
}
|
||||
",
|
||||
pub fn remove_project(&mut self, project_name: &String) {
|
||||
if self.keywords_list.contains(&project_name) {
|
||||
self.keywords_list.remove(
|
||||
self.keywords_list
|
||||
.iter()
|
||||
.position(|proj| proj == project_name)
|
||||
.unwrap(),
|
||||
);
|
||||
str
|
||||
self.write();
|
||||
}
|
||||
}
|
||||
pub fn load_from_file(&mut self) {
|
||||
if !std::path::Path::new("drp_config.toml").exists() {
|
||||
self.write();
|
||||
} else {
|
||||
let mut file = fs::File::options()
|
||||
.read(true)
|
||||
.open("drp_config.toml")
|
||||
.expect(
|
||||
"Config file exists but can't be acccessed. Check permissions for the file.",
|
||||
);
|
||||
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content)
|
||||
.expect("config file not valid");
|
||||
|
||||
if content.is_empty() {
|
||||
self.write();
|
||||
}
|
||||
|
||||
*self = toml::from_str::<Config>(content.as_str())
|
||||
.expect("Config file exists, but the format of it is wrong.");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write(&self) {
|
||||
let mut file = fs::File::options()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open("drp_config.toml")
|
||||
.expect("Couldn't write to file");
|
||||
let buff =
|
||||
toml::ser::to_string_pretty(self).expect("Something is wrong with the default config");
|
||||
|
||||
file.write_all(buff.as_bytes())
|
||||
.expect("Failed to write files");
|
||||
}
|
||||
}
|
||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -7,7 +7,7 @@ pub mod config;
|
|||
pub mod program_status;
|
||||
pub mod self_updater;
|
||||
pub mod tray_icon;
|
||||
use crate::config::Config;
|
||||
use crate::config::{Config, IncludeExclude};
|
||||
use crate::program_status::*;
|
||||
use crate::self_updater::try_update;
|
||||
use app::{App, Apps};
|
||||
|
@ -21,7 +21,9 @@ fn main() {
|
|||
Err(e) => println!("Failed to update! {e}"),
|
||||
}
|
||||
let apps = Apps::construct_apps();
|
||||
let mut config = Config::load();
|
||||
let mut config = Config::default();
|
||||
|
||||
config.load_from_file();
|
||||
|
||||
let timeout = time::Duration::from_millis(5000);
|
||||
|
||||
|
@ -33,17 +35,37 @@ fn main() {
|
|||
let mut drp_is_running = false;
|
||||
let mut discord_client: Option<DiscordIpcClient> = None;
|
||||
let mut current_app_option: Option<&App> = None;
|
||||
loop {
|
||||
'main: loop {
|
||||
if let Some(current_app) = current_app_option {
|
||||
if let Some(real_project_name) = is_program_still_running(¤t_app) {
|
||||
//if project name includes filtered words, use default project name
|
||||
for excluded_word in &config.exclude_keywords_list {
|
||||
if real_project_name.contains(excluded_word.as_str()) {
|
||||
project_name = match config.should_list_include_or_exclude {
|
||||
IncludeExclude::Exclude => real_project_name.clone(),
|
||||
IncludeExclude::Include => current_app.default_project_name.clone(),
|
||||
};
|
||||
for listed_word in &config.keywords_list {
|
||||
match &config.should_list_include_or_exclude {
|
||||
&IncludeExclude::Exclude => {
|
||||
if real_project_name.contains(listed_word.as_str()) {
|
||||
if !&config.show_default_when_excluded {
|
||||
continue 'main;
|
||||
}
|
||||
project_name = current_app.default_project_name.clone();
|
||||
} else {
|
||||
project_name = real_project_name.clone();
|
||||
}
|
||||
}
|
||||
&IncludeExclude::Include => {
|
||||
if real_project_name.contains(listed_word.as_str()) {
|
||||
project_name = real_project_name.clone();
|
||||
} else {
|
||||
if !&config.show_default_when_excluded {
|
||||
continue 'main;
|
||||
}
|
||||
project_name = current_app.default_project_name.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//If discord client isn't connected create and conenct it
|
||||
if !drp_is_running {
|
||||
//make a new client with current_app ID
|
||||
|
@ -86,7 +108,10 @@ fn main() {
|
|||
//if discord client exists, update status
|
||||
if let Some(dc) = discord_client.as_mut() {
|
||||
match dc.set_activity(activity) {
|
||||
_ => (),
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
dbg!(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,20 +124,26 @@ fn main() {
|
|||
//respond to tray icon messages
|
||||
match tray_receiver.try_recv() {
|
||||
Ok(msg) => match msg {
|
||||
tray_icon::Message::AnonymiseProject => {
|
||||
//only exclude project name if it's not the default one
|
||||
for app in apps.as_iter() {
|
||||
if app.kind == current_app.kind {
|
||||
if app.default_project_name != project_name {
|
||||
config.exclude_project(&project_name);
|
||||
tray_icon::Message::AddProjectToList => {
|
||||
if let Some(real_project_name) = is_program_still_running(¤t_app) {
|
||||
config.add_project(&real_project_name);
|
||||
}
|
||||
}
|
||||
tray_icon::Message::RemoveProjectFromList => {
|
||||
if let Some(real_project_name) = is_program_still_running(¤t_app) {
|
||||
config.remove_project(&real_project_name);
|
||||
}
|
||||
}
|
||||
tray_icon::Message::Quit => {
|
||||
println!("qiuitting!");
|
||||
exit(0)
|
||||
}
|
||||
tray_icon::Message::OpenOptionsFile => {
|
||||
let _ = std::process::Command::new("notepad")
|
||||
.arg("drp_config.toml")
|
||||
.current_dir("./")
|
||||
.spawn();
|
||||
}
|
||||
},
|
||||
Err(_err) => (),
|
||||
}
|
||||
|
@ -120,8 +151,8 @@ fn main() {
|
|||
//respond to tray icon messages
|
||||
match tray_receiver.try_recv() {
|
||||
Ok(msg) => match msg {
|
||||
tray_icon::Message::AnonymiseProject => {}
|
||||
tray_icon::Message::Quit => exit(0),
|
||||
_ => (),
|
||||
},
|
||||
Err(_err) => (),
|
||||
}
|
||||
|
|
|
@ -8,7 +8,10 @@ pub fn get_running_program(apps: &Apps) -> Option<(&App, String)> {
|
|||
for window_name in running_window_names {
|
||||
//println!("{}", &window_name);
|
||||
if let Some(app) = apps.find_app(&window_name) {
|
||||
if !window_name.contains("- Google Chrome") {
|
||||
if !window_name.contains("- Google Chrome")
|
||||
|| !window_name.contains(" Mozilla Firefox")
|
||||
|| !window_name.contains("- Brave")
|
||||
{
|
||||
//So googling it won't affect the DRP lol
|
||||
return Some((&app, app.parse(&window_name)));
|
||||
}
|
||||
|
@ -20,8 +23,14 @@ pub fn is_program_still_running(app: &App) -> Option<String> {
|
|||
let running_window_names = unsafe { get_running_windows_titles() };
|
||||
|
||||
for window_name in running_window_names {
|
||||
if window_name.contains(&app.process_search_string) {
|
||||
if !window_name.contains("- Google Chrome") {
|
||||
if window_name
|
||||
.to_lowercase()
|
||||
.contains(&app.process_search_string.to_lowercase())
|
||||
{
|
||||
if !window_name.contains("- Google Chrome")
|
||||
|| !window_name.contains(" Mozilla Firefox")
|
||||
|| !window_name.contains("- Brave")
|
||||
{
|
||||
//So googling it won't affect the DRP lol
|
||||
return Some(app.parse(&window_name));
|
||||
}
|
||||
|
|
|
@ -4,23 +4,38 @@ use {std::sync::mpsc, tray_item::TrayItem};
|
|||
|
||||
pub enum Message {
|
||||
Quit,
|
||||
AnonymiseProject,
|
||||
AddProjectToList,
|
||||
RemoveProjectFromList,
|
||||
OpenOptionsFile,
|
||||
}
|
||||
|
||||
pub fn create_tray() -> (Receiver<Message>, TrayItem) {
|
||||
let mut tray = TrayItem::new("DRP Creative", "drp-icon").unwrap();
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let tx1 = tx.clone();
|
||||
tray.add_label("DRP Creative Options").unwrap();
|
||||
let tx2 = tx.clone();
|
||||
let tx3 = tx.clone();
|
||||
let tx4 = tx.clone();
|
||||
tray.add_menu_item("Open options file", move || {
|
||||
tx4.send(Message::OpenOptionsFile).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
tray.add_menu_item("Don't show current project", move || {
|
||||
tx.send(Message::AnonymiseProject).unwrap();
|
||||
tray.add_menu_item("Add project to include/exclude list", move || {
|
||||
tx1.send(Message::AddProjectToList).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
tray.add_menu_item("Remove project from include/exclude list", move || {
|
||||
println!("REMOVE");
|
||||
tx3.send(Message::RemoveProjectFromList).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
tray.add_menu_item("Quit", move || {
|
||||
tx1.send(Message::Quit).unwrap();
|
||||
tx2.send(Message::Quit).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
return (rx, tray);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue