From 9e2b51c8e698d8216f680b61dd3908d2f1823b38 Mon Sep 17 00:00:00 2001 From: krolxon Date: Wed, 24 Apr 2024 15:49:40 +0530 Subject: use tabs instead of layouts --- src/connection.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/connection.rs') diff --git a/src/connection.rs b/src/connection.rs index 16055a5..9cfd61e 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -158,15 +158,17 @@ impl Connection { } // Volume controls - /// Sets the volume - pub fn set_volume(&mut self, u: String) { + pub fn inc_volume(&mut self, v: i8) { let cur = self.conn.status().unwrap().volume; - let sym = u.get(0..1).unwrap(); - let u: i8 = u.parse::().unwrap(); - if sym == "+" || sym == "-" { - self.conn.volume(cur + u).unwrap(); - } else { - self.conn.volume(u).unwrap(); + if cur + v <= 100 { + self.conn.volume(cur + v).unwrap(); + } + } + + pub fn dec_volume(&mut self, v: i8) { + let cur = self.conn.status().unwrap().volume; + if cur - v >= 0 { + self.conn.volume(cur - v).unwrap(); } } } -- cgit v1.2.3