From 932a82c4587cced2df8b07a9fe6ecd16bc2feb95 Mon Sep 17 00:00:00 2001 From: RestartFU Date: Wed, 13 Nov 2024 13:02:08 -0500 Subject: [PATCH] added refresh_delay to config --- src/config.cr | 11 +++++++---- src/xstatus.cr | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/config.cr b/src/config.cr index e7c2c24..1355c80 100644 --- a/src/config.cr +++ b/src/config.cr @@ -5,13 +5,16 @@ require "yaml" class Config include YAML::Serializable - getter default : String = %(seperator: "|" + getter default : String = %(refresh_delay: 1 +seperator: "|" commands: [ - "Restart", - "$(date +%a) $(date +%b) $(date +%d)", + "Restart", + "$(date +%a) $(date +%b) $(date +%d)", "$(date +%r)", ] ) + @[YAML::Field(key: "refresh_delay")] + property refresh_delay : Int64 = 1 @[YAML::Field(key: "seperator")] property seperator : String = "|" @@ -35,4 +38,4 @@ commands: [ @seperator = config.seperator @commands = config.commands end -end \ No newline at end of file +end diff --git a/src/xstatus.cr b/src/xstatus.cr index 5cbc9d0..fc3b1a6 100644 --- a/src/xstatus.cr +++ b/src/xstatus.cr @@ -19,7 +19,7 @@ class XStatus exit 0 end - def trap_signals(signals : Array) + def trap_signals(signals : Array) signals.each do |s| s.trap do terminate 0 @@ -44,7 +44,7 @@ class XStatus rescue ex Logger.fatalln ex end - sleep 1.second + sleep conf.refresh_delay.millisecond end end @@ -56,4 +56,4 @@ class XStatus end p = XStatus.new -p.run \ No newline at end of file +p.run