Compare commits

..

No commits in common. "master" and "v0.1.3" have entirely different histories.

18 changed files with 273 additions and 1450 deletions

15
.drp_config Normal file
View file

@ -0,0 +1,15 @@
SHOULD_EXCLUDE_BE_ANONYMOUS:{
n
}
PORTFOLIO_LINK:{
djkato.net
}
EXCLUDE_CHARACTERS_LIST:{
no_drp
}
HIDE_PORTFOLIO_ROW:{
no
}

1185
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,18 +1,16 @@
[package] [package]
name = "drp_creative" name = "DRP_Creative"
version = "1.0.4" version = "0.1.3"
edition = "2021" edition = "2021"
authors = ["djkatovfx@gmail.com"] author = "https://djkato.net"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
discord-rich-presence = "0.2.2" discord-rich-presence = "0.2.2"
regex = "1.6.0" regex = "1.6.0"
tray-item = "0.7.0" tray-item = "0.7.0"
lazy_static = "1.4.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] [dependencies.windows]
version = "0.39.0" version = "0.39.0"
@ -25,9 +23,4 @@ features = [
] ]
[target.'cfg(windows)'.build-dependencies] [target.'cfg(windows)'.build-dependencies]
windres = "0.2.2" windres = "0.2.2"
# prefix binary with x86_64-pc-windows-msvc for self_updater
[[bin]]
name = "DRP_Creative--x86_64-pc-windows-msvc"
path = "src/main.rs"

View file

@ -1 +0,0 @@
ko_fi: djkato

View file

@ -1,4 +1,3 @@
<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 # 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! ### 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. 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.
@ -7,33 +6,21 @@ Examples:
![example1](https://i.imgur.com/yFzQh6O.png) ![example1](https://i.imgur.com/yFzQh6O.png)
![example2](https://i.imgur.com/fziotzt.png) ![example2](https://i.imgur.com/fziotzt.png)
![example3](https://i.imgur.com/9SEXuQr.png) ![example3](https://i.imgur.com/9SEXuQr.png)
![example4](https://i.imgur.com/ANAW6Ub.png)
## how to install: ## 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`. 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. 3. Do `[WindowsButton] + R`, type `Shell:StartUp`, hit enter. A folder will open.
4. Do `[WindowsButton] + R`, type `Shell:StartUp`, hit enter. A folder will open. 4. Put the exe file inside this folder(Now the app will start on pc start)
5. Take the link file and put it inside the startup folder (Now the app will start on pc start) 5. If you want to run it now, double click it
6. If you want to run it now, double click it 6. Enjoy!
7. Enjoy!
## How to use: ## 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 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`
Example `drp_config.toml`: - 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`.
```toml ![icon showcase](https://i.imgur.com/nADffGB.png)
keywords_list = ["WORK", "Untitled 681*"]
show_default_when_excluded = true # or false - 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 ^^'
portfolio_link = "djkato.net"
hide_portfolio_row = false
should_list_include_or_exclude = "Include" # Or "Exclude", capital sensitive
```
### Currently supported programs: ### Currently supported programs:
**Full support:** **Full support:**
- Cinema 4D - Cinema 4D
@ -45,7 +32,7 @@ should_list_include_or_exclude = "Include" # Or "Exclude", capital sensitive
- Autodesk 3Ds Max - Autodesk 3Ds Max
- Davinci Resolve - Davinci Resolve
- Isotropix Clarisse - Isotropix Clarisse
- Cavalry - Calvary
- Ableton - Ableton
- FL Studio - FL Studio
- Blender - Blender
@ -55,7 +42,5 @@ should_list_include_or_exclude = "Include" # Or "Exclude", capital sensitive
- Substance Designer ¹* - Substance Designer ¹*
- Substance Painter ¹* - Substance Painter ¹*
- Adobe Audition ¹* - Adobe Audition ¹*
- ZBrush ¹*
- Darktable ¹*
¹*sadly not doable, project name not in proces window title. They will show up though, just with default project name* ¹*sadly not doable, project name not in proces window title. They will show up though, just with default project name*

View file

@ -1,5 +0,0 @@
keywords_list = []
show_default_when_excluded = true
portfolio_link = "djkato.net"
hide_portfolio_row = false
should_list_include_or_exclude = "Exclude"

View file

@ -1,2 +0,0 @@
'Process_list_dump.exe' is not recognized as an internal or external command,
operable program or batch file.

View file

@ -0,0 +1,26 @@
<?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>

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
program icons/ae.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View file

@ -30,8 +30,6 @@ pub enum AppKind {
SubstancePainter, SubstancePainter,
SubstanceDesigner, SubstanceDesigner,
Vegas, Vegas,
ZBrush,
Darktable,
} }
pub struct Apps { pub struct Apps {
@ -54,12 +52,10 @@ pub struct Apps {
SubstancePainter: App, SubstancePainter: App,
SubstanceDesigner: App, SubstanceDesigner: App,
Vegas: App, Vegas: App,
ZBrush: App,
Darktable: App,
} }
impl Apps { impl Apps {
pub fn as_iter(&self) -> [&App; 21] { pub fn as_iter(&self) -> [&App; 19] {
let APPS: [&App; 21] = [ let APPS: [&App; 19] = [
&self.C4d, &self.C4d,
&self.Maya, &self.Maya,
&self.ThreeDsMax, &self.ThreeDsMax,
@ -79,15 +75,13 @@ impl Apps {
&self.SubstancePainter, &self.SubstancePainter,
&self.SubstanceDesigner, &self.SubstanceDesigner,
&self.Vegas, &self.Vegas,
&self.ZBrush,
&self.Darktable,
]; ];
APPS APPS
} }
} }
impl AppKind { impl AppKind {
pub fn as_iter() -> [AppKind; 21] { pub fn as_iter() -> [AppKind; 19] {
let APPKINDS: [AppKind; 21] = [ let APPKINDS: [AppKind; 19] = [
AppKind::C4d, AppKind::C4d,
AppKind::Maya, AppKind::Maya,
AppKind::ThreeDsMax, AppKind::ThreeDsMax,
@ -107,8 +101,6 @@ impl AppKind {
AppKind::SubstancePainter, AppKind::SubstancePainter,
AppKind::SubstanceDesigner, AppKind::SubstanceDesigner,
AppKind::Vegas, AppKind::Vegas,
AppKind::ZBrush,
AppKind::Darktable,
]; ];
APPKINDS APPKINDS
} }
@ -230,18 +222,6 @@ impl Apps {
drp_client_id: "1017882355723153448".to_string(), drp_client_id: "1017882355723153448".to_string(),
process_search_string: "VEGAS Pro".to_string(), process_search_string: "VEGAS Pro".to_string(),
}, },
ZBrush: App {
kind: AppKind::Vegas,
default_project_name: "ZBrush Project".to_string(),
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(),
},
} }
} }
} }
@ -249,10 +229,7 @@ impl Apps {
impl Apps { impl Apps {
pub fn find_app(&self, str: &String) -> Option<&App> { pub fn find_app(&self, str: &String) -> Option<&App> {
for app in self.as_iter() { for app in self.as_iter() {
if str if str.contains(&app.process_search_string) {
.to_lowercase()
.contains(&app.process_search_string.to_lowercase())
{
return Some(&app); return Some(&app);
} }
} }
@ -264,12 +241,19 @@ impl App {
pub fn parse(&self, window_title: &String) -> String { pub fn parse(&self, window_title: &String) -> String {
match self.kind { match self.kind {
AppKind::C4d => { AppKind::C4d => {
if let Some(split1) = window_title.rsplit_once("]") { let mut end_i: usize = window_title.len();
if let Some(split2) = split1.0.rsplit_once("[") { let mut start_i: usize = 0;
return split2.1.to_string(); 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 {
return self.default_project_name.clone();
}
} }
} }
return self.default_project_name.clone(); return window_title[start_i + 1..end_i].to_string();
} }
AppKind::Maya => { AppKind::Maya => {
let match_index = match window_title.as_str().find(".mb* - Autodesk Maya") { let match_index = match window_title.as_str().find(".mb* - Autodesk Maya") {
@ -472,8 +456,6 @@ impl App {
}; };
return window_title[..match_index as usize].to_string(); return window_title[..match_index as usize].to_string();
} }
AppKind::ZBrush => self.default_project_name.clone(),
AppKind::Darktable => self.default_project_name.clone(),
} }
} }
} }

View file

@ -1,91 +1,136 @@
use serde::{Deserialize, Serialize}; use std::fs;
use std::{
fs,
io::{Read, Write},
};
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug)]
pub struct Config { pub struct Config {
pub keywords_list: Vec<String>, pub exclude_keywords_list: Vec<String>,
pub show_default_when_excluded: bool, pub should_exclude_be_invisible: bool,
pub portfolio_link: String, pub portfolio_link: String,
pub hide_portfolio_row: bool, 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 { impl Config {
pub fn add_project(&mut self, project_name: &String) { pub fn load() -> Config {
if self.keywords_list.contains(&project_name) { let default_config = use_default_config();
return;
}
self.keywords_list.push(project_name.clone());
self.write();
}
pub fn remove_project(&mut self, project_name: &String) { //if no config file, parse default config file and try save it, then use it
if self.keywords_list.contains(&project_name) { let config_file: Config = match fs::read_to_string(".drp_config") {
self.keywords_list.remove( Result::Err(_err) => {
self.keywords_list let def_config = parse_config_file(&default_config);
.iter() make_config_file(&def_config);
.position(|proj| proj == project_name) def_config
.unwrap(),
);
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();
} }
Result::Ok(val) => parse_config_file(&val),
*self = toml::from_str::<Config>(content.as_str()) };
.expect("Config file exists, but the format of it is wrong."); config_file
}
}
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");
} }
} }
impl Config {
pub fn exclude_project(&mut self, project_name: &String) {
if self.exclude_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,
}
}
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
}
",
);
str
}

View file

@ -1,29 +1,17 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![windows_subsystem = "windows"] //UNCOMMENT ONLY WHEN BUILDING FOR RELEASE TO NOT SHOW TERMINAL WINDOW!
#[macro_use]
extern crate self_update;
pub mod app; pub mod app;
pub mod config; pub mod config;
pub mod program_status; pub mod program_status;
pub mod self_updater;
pub mod tray_icon; pub mod tray_icon;
use crate::config::{Config, IncludeExclude}; use crate::config::Config;
use crate::program_status::*; use crate::program_status::*;
use crate::self_updater::try_update;
use app::{App, Apps}; use app::{App, Apps};
use discord_rich_presence::{activity, DiscordIpc, DiscordIpcClient}; use discord_rich_presence::{activity, DiscordIpc, DiscordIpcClient};
use std::process::exit;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
use std::{thread, time}; use std::{thread, time};
fn main() { fn main() {
match try_update() {
Ok(_) => {}
Err(e) => println!("Failed to update! {e}"),
}
let apps = Apps::construct_apps(); let apps = Apps::construct_apps();
let mut config = Config::default(); let mut config = Config::load();
config.load_from_file();
let timeout = time::Duration::from_millis(5000); let timeout = time::Duration::from_millis(5000);
@ -38,32 +26,12 @@ fn main() {
'main: loop { 'main: loop {
if let Some(current_app) = current_app_option { if let Some(current_app) = current_app_option {
if let Some(real_project_name) = is_program_still_running(&current_app) { if let Some(real_project_name) = is_program_still_running(&current_app) {
project_name = match config.should_list_include_or_exclude { //if project name includes filtered words, use default project name
IncludeExclude::Exclude => real_project_name.clone(), for excluded_word in &config.exclude_keywords_list {
IncludeExclude::Include => current_app.default_project_name.clone(), if real_project_name.contains(excluded_word.as_str()) {
}; project_name = current_app.default_project_name.clone();
for listed_word in &config.keywords_list { } else {
match &config.should_list_include_or_exclude { project_name = real_project_name.clone();
&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 discord client isn't connected create and conenct it
@ -108,10 +76,7 @@ fn main() {
//if discord client exists, update status //if discord client exists, update status
if let Some(dc) = discord_client.as_mut() { if let Some(dc) = discord_client.as_mut() {
match dc.set_activity(activity) { match dc.set_activity(activity) {
Ok(_) => (), _ => (),
Err(e) => {
dbg!(e);
}
} }
} }
} }
@ -124,38 +89,21 @@ fn main() {
//respond to tray icon messages //respond to tray icon messages
match tray_receiver.try_recv() { match tray_receiver.try_recv() {
Ok(msg) => match msg { Ok(msg) => match msg {
tray_icon::Message::AddProjectToList => { tray_icon::Message::AnonymiseProject => {
if let Some(real_project_name) = is_program_still_running(&current_app) { //only exclude project name if it's not the default one
config.add_project(&real_project_name); 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::RemoveProjectFromList => { tray_icon::Message::Quit => break 'main,
if let Some(real_project_name) = is_program_still_running(&current_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) => (), Err(_err) => (),
} }
} else { } else {
//respond to tray icon messages
match tray_receiver.try_recv() {
Ok(msg) => match msg {
tray_icon::Message::Quit => exit(0),
_ => (),
},
Err(_err) => (),
}
//If nothing is running try to find it //If nothing is running try to find it
if let Some(proj_name) = get_running_program(&apps) { if let Some(proj_name) = get_running_program(&apps) {
let temp_curr_app: &App; let temp_curr_app: &App;

View file

@ -8,10 +8,7 @@ pub fn get_running_program(apps: &Apps) -> Option<(&App, String)> {
for window_name in running_window_names { for window_name in running_window_names {
//println!("{}", &window_name); //println!("{}", &window_name);
if let Some(app) = apps.find_app(&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 //So googling it won't affect the DRP lol
return Some((&app, app.parse(&window_name))); return Some((&app, app.parse(&window_name)));
} }
@ -23,14 +20,8 @@ pub fn is_program_still_running(app: &App) -> Option<String> {
let running_window_names = unsafe { get_running_windows_titles() }; let running_window_names = unsafe { get_running_windows_titles() };
for window_name in running_window_names { for window_name in running_window_names {
if window_name if window_name.contains(&app.process_search_string) {
.to_lowercase() if !window_name.contains("- Google Chrome") {
.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 //So googling it won't affect the DRP lol
return Some(app.parse(&window_name)); return Some(app.parse(&window_name));
} }

View file

@ -1,46 +0,0 @@
use windows::w;
pub fn try_update() -> Result<(), Box<dyn std::error::Error>> {
let build = self_update::backends::github::Update::configure()
.repo_owner("djkato")
.repo_name("DRP_Creative")
.bin_name("DRP_Creative")
.no_confirm(true)
.current_version(cargo_crate_version!())
.build()?;
let latest_release = build.get_latest_release()?;
if self_update::version::bump_is_greater(
build.current_version().as_str(),
latest_release.version.as_str(),
)? {
let body: windows::core::HSTRING = format!(
"Found update! \nCurrent version: {}\nFound Version: {}\nUpdate?",
build.current_version(),
latest_release.version
)
.into();
if let Ok(response) = win_msgbox::MessageBox::<win_msgbox::OkayCancel>::new(body.as_ptr())
.title(w!("DRP Creative Updater").as_ptr())
.show()
{
match response {
win_msgbox::OkayCancel::Cancel => {}
win_msgbox::OkayCancel::Okay => {
build.update()?;
win_msgbox::MessageBox::<win_msgbox::Okay>::new(
w!("Update successful, restart app to apply").as_ptr(),
)
.title(w!("DRP Creative").as_ptr())
.icon(win_msgbox::Icon::Information)
.show()
.expect("Failed to show update successful window");
return Ok(());
}
}
};
} else {
return Err("No updates found".into());
}
Err("Something got skipped".into())
}

View file

@ -4,38 +4,23 @@ use {std::sync::mpsc, tray_item::TrayItem};
pub enum Message { pub enum Message {
Quit, Quit,
AddProjectToList, AnonymiseProject,
RemoveProjectFromList,
OpenOptionsFile,
} }
pub fn create_tray() -> (Receiver<Message>, TrayItem) { pub fn create_tray() -> (Receiver<Message>, TrayItem) {
let mut tray = TrayItem::new("DRP Creative", "drp-icon").unwrap(); let mut tray = TrayItem::new("DRP Creative", "drp-icon").unwrap();
let (tx, rx) = mpsc::channel(); let (tx, rx) = mpsc::channel();
let tx1 = tx.clone(); let tx1 = tx.clone();
let tx2 = tx.clone(); tray.add_label("DRP Creative Options").unwrap();
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("Add project to include/exclude list", move || { tray.add_menu_item("Don't show current project", move || {
tx1.send(Message::AddProjectToList).unwrap(); tx.send(Message::AnonymiseProject).unwrap();
})
.unwrap();
tray.add_menu_item("Remove project from include/exclude list", move || {
println!("REMOVE");
tx3.send(Message::RemoveProjectFromList).unwrap();
}) })
.unwrap(); .unwrap();
tray.add_menu_item("Quit", move || { tray.add_menu_item("Quit", move || {
tx2.send(Message::Quit).unwrap(); tx1.send(Message::Quit).unwrap();
}) })
.unwrap(); .unwrap();
return (rx, tray); return (rx, tray);
} }