Score:3

Why does this bash script generate Exit code 2 in i3block?

gb flag

I used this bash script for i3block, but I get Exit code 2:

#!/bin/bash
sink=$(pacmd list-sinks | grep '* index:')
if [[ "${sink:11:11}" -eq "1" ]]
then
    echo 'usb'
else
    echo 'mic'
fi

The script works fine when run from the command line, but it doesn't work for i3block, why?

terdon avatar
cn flag
How are you using this script in i3block? Does it work if you change the `if` to `if [ "${sink:11:11}" -eq "1" ]` (using single instead of double braces)? It might be that i3block is executing this as an sh script and not bash and `[[` is a bash thing.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.