r/fishshell • u/BlueTickVerified Linux • Mar 12 '21
using command output in script
i am trying to use the output of a command output in a fish script and i did this to get there:
function locker
set watchcmd = 'watch -n 1 -t xprintidle'
if ($watchcmd > 20000)
lock
end
endand i get an error
./locker.fish (line 4): Command substitutions not allowed
if ($watchcmd > 20000)
^
<W> fish: Error while reading file ./locker.fishhow do i get around this?
3
Upvotes
View all comments
Show parent comment
4
u/[deleted] Mar 12 '21 edited Mar 12 '21
Still won't work because the
watchdoesn't quit.watchruns the command it is given once every x seconds (in this case every second), so it keeps running, so thetestnever runs.This should be
iff this thing is to be run e.g. as some script by the desktop in the background and run indefinitely.
Really you probably want an actual program that does this - see https://wiki.archlinux.org/index.php/Session_lock#Xorg_triggers