Skip to content

Commit 033ae51

Browse files
committed
Updated to v0.0.5 and allow custom server name
NEW RELEASE: v0.0.5 NEW: Custom server name * config file: new name field under servers * empty name field will use the server's given one instead * non-empty name field will use it
1 parent e0bec56 commit 033ae51

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "steamcountsnotifyd"
33
version = "0.0.5-alpha"
4-
authors = ["marttcw <[email protected]>"]
4+
authors = ["mtcw99 <[email protected]>"]
55
edition = "2018"
66
description = "Notification daemon that notifies you when your selected game(s) and/or server(s) gets some player activity"
77
readme = "README.md"

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# steamcountsnotifyd
22
SteamCountsNotifyD is a notification daemon written in Rust that notifies you when your selected game(s) gets some player activity
33

4-
* Current release: v0.0.4 - Alpha
5-
* (In-Development) Next release: v0.0.5 - Alpha
4+
* Current release: v0.0.5 - Alpha
5+
* (In-Development) Next release: v0.0.6 - Alpha
66

77
## License
88
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.
@@ -29,15 +29,6 @@ SteamCountsNotifyD is released under a the [GNU General Public License v3.0](htt
2929
* Uses xdg directory: `$HOME/.config/steamcountsnotifyd/config.toml`
3030
* Program will generate the configuration file if user requested via `--generate-config` and is not available
3131

32-
### Parameters
33-
CLI | Name | Description
34-
---|---|---
35-
`-i` | `interval` | How long in minutes to delay between each player count fetch.
36-
`-t` | `threshold_interval` | When the threshold's achieved, what interval gets extended to.
37-
`-c` | `connection_timeout` | How long in seconds the connection stay puts.
38-
`-n` | `notify_timeout` | How long in seconds the notification stays shown.
39-
`-a` | `action_type` | Which type of clickable notification should use: 0 - click, 1 - button
40-
4132
### Example
4233
```
4334
interval = 1
@@ -58,6 +49,7 @@ threshold = 100
5849
5950
[[servers]]
6051
address = "172.107.97.234:26300"
52+
name = "Example Server"
6153
threshold = 0
6254
```
6355

@@ -76,6 +68,10 @@ threshold = 0
7668

7769
## Releases
7870
### v0.0.5 Alpha
71+
* 2021-04-24: Custom server name
72+
* Added in the new `name` field under `servers`
73+
* Empty `name` string will use the server's given name
74+
* Non-empty `name` string will use this string instead
7975
* 2021-04-13: Ignore threshold: `--ignore-thresholds`
8076
* Ignores the threshold limits and just outputs the counters regardless
8177
* Useful with the CLI Single check

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ pub struct ConfigGame {
2727
pub struct ConfigServer {
2828
pub address: String,
2929
pub threshold: u32,
30+
31+
#[serde(default)]
32+
pub name: String,
3033
}
3134

3235
#[derive(Clone)]
@@ -58,6 +61,7 @@ impl Default for Config {
5861
],
5962
servers: vec![ConfigServer {
6063
address: String::from("172.107.97.234:26300"),
64+
name: String::from(""),
6165
threshold: 0,
6266
}],
6367
}

src/count.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,23 @@ fn server_get(cfg: &config::Config, server: &config::ConfigServer, single_check:
5050
match server::get_info(&server.address) {
5151
Ok(info) => {
5252
let current_interval = if info.players >= server.threshold || cfg.ignore_thresholds {
53+
let display_name = if server.name == "" {
54+
&info.name
55+
} else {
56+
&server.name
57+
};
58+
5359
if single_check {
5460
println!("SERVER: {} ({}): {} - {}/{} | steam://connect/{}",
55-
info.name,
61+
display_name,
5662
info.game,
5763
info.map,
5864
info.players,
5965
info.max_players,
6066
&server.address
6167
);
6268
} else {
63-
notify::server(&info, cfg.notify_timeout, &server.address, cfg.get_action_type());
69+
notify::server(&info, cfg.notify_timeout, display_name, &server.address, cfg.get_action_type());
6470
}
6571
cfg.threshold_interval
6672
} else {

src/notify.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ pub async fn new(
6161
Ok(())
6262
}
6363

64-
pub fn server(info: &Info, timeout: u32, address: &str, action_type: ActionType) {
64+
pub fn server(info: &Info, timeout: u32, display_name: &str, address: &str, action_type: ActionType) {
6565
let summary: String = format!(
6666
"{} ({})",
67-
info.name, info.game
67+
display_name, info.game
6868
);
6969
let body: String = format!(
7070
"{} ({}): {} - {}/{}",
71-
info.name, info.game, info.map, info.players, info.max_players
71+
display_name, info.game, info.map, info.players, info.max_players
7272
);
7373

7474
let address: String = address.into();

0 commit comments

Comments
 (0)