Skip to content

Commit

Permalink
v0.0.4 RELEASE: Removed daemon option+usaged. Updated README.
Browse files Browse the repository at this point in the history
REMOVED: Daemonization. Daemonization causes the counter to not work,
therefore it is removed.

README: Updated for v0.0.4 release.
  • Loading branch information
marttcw committed Mar 1, 2021
1 parent 2fdeaa8 commit 8765cbf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 61 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ tokio = { version = "1", features = ["full"] }
futures = "0.3"
a2s = { git = "https://github.com/rumblefrog/a2s-rs.git" }

[target.'cfg(unix)'.dependencies]
daemonize = "0.4.1"

33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# steamcountsnotifyd
SteamCountsNotifyD is a notification daemon written in Rust that notifies you when your selected game(s) gets some player activity

* Development release: v0.0.4 - Alpha
* Current release: v0.0.2 - Alpha
* Current release: v0.0.4 - Alpha
* (In-Development) Next release: v0.0.5 - Alpha

## License
SteamCountsNotifyD is released under a the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.html) a free software copyleft license.

## Dependencies
* serde, serde\_json, toml, dirs-next, notify-rust, clap, reqwest, tokio, futures, a2s
* All apart from a2s are available on [crates.io](https://crates.io/)
* a2s: [a2s-rs repo](https://github.com/rumblefrog/a2s-rs)

## Requirements to build
* [rust](https://www.rust-lang.org/)
* [Rust](https://www.rust-lang.org/)
* Just install with the instructions straight from the site. The compiler and cargo should be provided by default.

## Instructions
### Compile
* `cd steamcountsnotifyd`
* `cargo build`
### Install
* `cargo install`
### Compile and Install
* `cargo install --path .`
### Uninstall
* `cargo uninstall`

Expand All @@ -27,6 +28,7 @@ SteamCountsNotifyD is released under a the [GNU General Public License v3.0](htt
## Configuration
* Uses xdg directory: `$HOME/.config/steamcountsnotifyd/config.toml`
* Program will generate the configuration file if user requested via `--generate-config` and is not available

### Parameters
CLI | Name | Description
---|---|---
Expand All @@ -35,8 +37,7 @@ CLI | Name | Description
`-c` | `connection_timeout` | How long in seconds the connection stay puts.
`-n` | `notify_timeout` | How long in seconds the notification stays shown.
`-a` | `action_type` | Which type of clickable notification should use: 0 - click, 1 - button
`-d` | `daemonize` | This flag makes the program daemonize
`-g` | `generate` | Generates configuration file at default directory

### Example
```
interval = 1
Expand All @@ -63,16 +64,19 @@ threshold = 0
### systemd
* Use the systemd daemon as under user control, more information: [systemd/User - ArchWiki](https://wiki.archlinux.org/index.php/systemd/User)

## TODO (Possible future features)
* SOON: Per server notification
## TODO
* Edit configuration via the CLI
* Improving on the Windows port
* Better documentation and comments
* Making it work with systemd properly
* Support reload function
* Support runit and openrc also, sysvinit won't be however
* Configuration: More controls can be given for per game/server
* EX: Give interval for each game/server

## Releases
### v0.0.4 Alpha (Rust Rewrite)
### v0.0.4 Alpha (First Version of Rust Rewrite)
* 2021-03-01: Daemon option and forking/daemonization process removed
* Using [a2s-rs](https://github.com/rumblefrog/a2s-rs) library to do Source A2S Queries
* Can now query from each server
* Roughly working and ported to Windows 10
Expand All @@ -82,10 +86,12 @@ threshold = 0
* NOTE: Daemon is there but counter notification not working and CLI flag different/switched
* Non-daemon is by default
* 2021-02-22: Initial rewrite to Rust

### v0.0.3 Alpha (Final C++ Version, Unreleased)
* Notification hint set to "resident", meaning the game launcher is clickable even if after the notification goes away
* However only usable if only "default" (default anyway) is set
* Notifies that the daemon started up

### v0.0.2 Alpha
* counts to count (grammar fix)
* systemd service file available, but buggy at the moment (need `restart` after a `start`)
Expand All @@ -94,6 +100,7 @@ threshold = 0
* Added the ability to launch the game (`default` or `clicked` options available)
* Added `actiontype` to configuration and command-line paramter
* 0 = default, 1 = clicked

### v0.0.1 Alpha
* First release
* Basic daemon implementation implemented
Expand Down
4 changes: 0 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ use clap::Clap;
#[derive(Clap, Debug)]
#[clap(version = "0.0.4 Alpha", author = "mtcw <[email protected]>")]
pub struct Opts {
/// Run the program in daemonized/background mode
#[clap(short, long)]
pub daemonize: bool,

/// Generate default configuration file (if not available)
#[clap(long)]
pub generate_config: bool,
Expand Down
2 changes: 2 additions & 0 deletions src/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@ pub async fn main_loop(cfg: &config::Config) -> Result<(), Box<dyn std::error::E
}

join_all(tasks).await;

Ok(())
}

33 changes: 1 addition & 32 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,6 @@ use futures::executor::block_on;
use std::fs::{create_dir, File};
use std::io::prelude::*;

#[cfg(unix)]
use daemonize::Daemonize;

#[cfg(unix)]
fn daemonize() {
let stdout = File::create("/tmp/steamcountsnotifyd.out").unwrap();
let stderr = File::create("/tmp/steamcountsnotifyd.err").unwrap();

let daemonize = Daemonize::new()
.pid_file("/tmp/steamcountsnotifyd.pid")
.chown_pid_file(true)
.working_directory("/tmp")
.umask(0o777)
.stdout(stdout)
.stderr(stderr);

match daemonize.start() {
Ok(_) => {
println!("Running in daemonize mode...");
notify::daemon_startup();
}
Err(why) => eprintln!("ERROR: Cannot daemonize: {}", why),
}
}

#[cfg(windows)]
fn daemonize() {}

#[tokio::main]
async fn main() -> std::io::Result<()> {
let opts: cli::Opts = cli::parse();
Expand Down Expand Up @@ -89,10 +61,6 @@ async fn main() -> std::io::Result<()> {
}
}

if opts.daemonize {
daemonize();
}

match block_on(count::main_loop(&cfg)) {
Err(_) => {
eprintln!("ERROR: An error in the main loop occured.");
Expand All @@ -101,3 +69,4 @@ async fn main() -> std::io::Result<()> {
Ok(_) => Ok(()),
}
}

9 changes: 0 additions & 9 deletions src/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,3 @@ pub fn server(info: &Info, timeout: u32, address: &str, action_type: ActionType)
});
}

#[cfg(unix)]
pub fn daemon_startup() {
Notification::new()
.summary("steamcountsnotifyd")
.body("steamcountsnotifyd daemon started up")
.timeout(5000)
.show()
.unwrap();
}

0 comments on commit 8765cbf

Please sign in to comment.