commit e659cb2

hovercats  ·  2025-03-02 04:44:47 +0000 UTC
parent d4efa15
bri: only use awk. redirect properly, do not read and write to same file at the same time, as this is bad practice.
1 files changed,  +5, -3
M rc/bri
M rc/bri
+5, -3
 1@@ -4,11 +4,13 @@
 2 flag e +
 3 
 4 file=/sys/class/backlight/amdgpu_bl0/brightness
 5-val=`{cat $file}
 6+tmpfile=/tmp/bri.tmp
 7 
 8 switch($1) {
 9 	case d
10-		 printf %s\n $val | awk '{ print $1 - 5 }' >$file
11+		 awk <$file '{ print $1 - 5 }' >$tmpfile
12+		 cat $tmpfile >$file
13 	case i
14-		 printf %s\n $val | awk '{ print $1 + 5 }' >$file
15+		 awk <$file '{ print $1 + 5 }' >$tmpfile
16+		 cat $tmpfile >$file
17 }