beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
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
<abu[7]> strange
<geri> maybe escapes are messing with the code, sec
<abu[7]> yes
<geri> (call "sh" "-c" "amixer get Master | grep -q '\\[on\\]'") seems to work
<geri> funh
<abu[7]> 👍
<geri> wanted to try to rewrite my bad lisp in C, stuck on data structures B)
<geri> c aint fun
<abu[7]> How about (in '("amixer" "get" "master") (from "[on]")) ?
<geri> seems to work
<geri> first time seeing from :D
<abu[7]> ☺
<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
<abu[7]> yeah
<geri> ill drop anothe atrocious function in a second
<abu[7]> ok
<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> (line T))
<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> ouchies
<abu[7]> hmm, wait
<abu[7]> There is http://pb1n.de/?2d7da2
<geri> which of those
<abu[7]> pilPipes
<abu[7]> both do the same
<geri> hmm
<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 %
<abu[7]> nice!
<geri> (read "%")
<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
<abu[7]> tokens
<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
<abu[7]> ok
<geri> hence why feel like a genius :D
<abu[7]> indeed :)
<abu[7]> What did (line T) return?
<abu[7]> "30%" ?
<geri> "30"
<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> ikr B)
<abu[7]> ok
<geri> got something like this
<abu[7]> Looks good
<geri> )
<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?
<abu[7]> gnome?
<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?
<abu[7]> T
<geri> that's cool
<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
<abu[7]> true
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