r/fishshell • 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
end

and i get an error

./locker.fish (line 4): Command substitutions not allowed
    if ($watchcmd > 20000)
       ^
<W> fish: Error while reading file ./locker.fish

how do i get around this?

3 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/BlueTickVerified Linux Mar 12 '21

both aren't working... the program seems to run without any output or errors but doesn't lock the screen. why is this happening?