geri has joined #picolisp
<
geri>
hey-hey, im still alive :D
<
geri>
excuse of a question - how do i wrap this in pil code to return T/NIL depending on exit code of the operation?
<
abu[7]>
Hi geri! Good to know! :)
<
geri>
amixer get Master | grep -q '\[on\]'
<
geri>
if i do in + out i dont know how to capture exit code, and call with in doesnt seem to work
<
abu[7]>
call should return a bool
<
abu[7]>
(call "sh" "-c" "... | ...")
<
geri>
(call "sh" "-c" "amixer get Master | grep '\[on\]'") always returns T for some reason
<
geri>
maybe escapes are messing with the code, sec
<
geri>
(call "sh" "-c" "amixer get Master | grep -q '\\[on\\]'") seems to work
<
geri>
wanted to try to rewrite my bad lisp in C, stuck on data structures B)
<
abu[7]>
How about (in '("amixer" "get" "master") (from "[on]")) ?
<
geri>
seems to work
<
geri>
first time seeing from :D
<
abu[7]>
Might be faster as it avoids a pipe and proceses
<
geri>
its shorter, that's already enough for me
<
geri>
and returns NIL if couldnt find anything
<
geri>
ill drop anothe atrocious function in a second
<
geri>
for some reason i had to echo instead of using line T directly
<
abu[7]>
yes, echo is needed to transmit from one pipe to the other
<
geri>
(out '("awk" "-F" "[][%]" "/[.*%]/{ print $2; exit }")
<
geri>
(in '("amixer" "get" "Master") (echo))
<
geri>
seems to work nicer, but maybe theres a more native solution
<
geri>
nvm it doesnt work
<
abu[7]>
Yeah, there is no better way I think
<
geri>
which of those
<
abu[7]>
both do the same
<
abu[7]>
(fd 0) + exec
<
abu[7]>
avoids echo
<
geri>
(in '("amixer" "get" "Master") (from "[") (read)))
<
geri>
somehow seems to work XD
<
geri>
just need to remove last %
<
geri>
i feel like a genius now
<
abu[7]>
perfect :)
<
geri>
pil is lovely tbh
<
abu[7]>
But why (read "%")? It reads in a special mode
<
geri>
without % it reads 30% and stops
<
geri>
i need only the number
<
geri>
i make % into a token so it stops before reading that
<
geri>
hence why feel like a genius :D
<
abu[7]>
What did (line T) return?
<
geri>
awk splits by % and []'s for that reason
<
abu[7]>
then read would return a number 30
<
geri>
read without argument read 30%
<
geri>
with "%" it reads 30
<
geri>
which is what i need
<
abu[7]>
I would avoid awk and use 'from' and (format (till d
<
geri>
(in '("amixer" "get" "Master") (from "[") (read "%")))
<
geri>
this is the whole code now
<
geri>
no awk at all
<
abu[7]>
(from "[") (format (till "%"))
<
geri>
it's okay for it to be a string - it's only used for another (call), although neat
<
abu[7]>
But (read "%") is a great idea
<
geri>
got something like this
<
abu[7]>
Looks good
<
geri>
a bit shorter than sh version cause i changed the structure
<
geri>
pretty happy about it
<
geri>
it sends a notification with status of input/output audio sources and volume percentage using a notification hint - its very neat
<
abu[7]>
"notify-send" goes where?
<
geri>
libnotify works in gnome too yeah
<
geri>
im on sway though, running the component standalone
<
abu[7]>
On Android I use (call "termux-notification" ...
<
geri>
it sends an android notification?
<
geri>
im kinda misusing notifications as an active component of my gui
<
geri>
but its nice cause i dont need to waste screen real estate on a bar
beneroth has joined #picolisp
<
geri>
harro beneroth
chexum has quit [Ping timeout: 260 seconds]
chexum has joined #picolisp
geri has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.4)]
theruran has joined #picolisp
beneroth has quit [Remote host closed the connection]
beneroth has joined #picolisp
neuroevolutus has joined #picolisp
neuroevolutus has quit [Quit: Client closed]
neuroevolutus has joined #picolisp
neuroevolutus has quit [Ping timeout: 256 seconds]
beneroth has quit [Remote host closed the connection]
beneroth has joined #picolisp