Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mailcheck: fix problem when calling check_cmd with a variable in profile #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions foldercheck
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ ORIG_CMD="$0 $*"
MBLAZE=${MBLAZE-$HOME/.mblaze}
profile="$MBLAZE/profile"

date_fmt=$(mhdr -h FolderCheckDateFmt $profile)
[ -z "$date_fmt" ] && date_fmt="%Y-%m-%d %H:%M"
sleep=$(mhdr -h FolderCheckSleep $profile)
[ -z "$sleep" ] && sleep=30
getmblazeopt () {
[[ -n $1 ]] && mhdr -h $1 $profile | envsubst && return 0
return 1
}

check_cmd=$(getmblazeopt MailCheckCommand)
check_cmd=${check_cmd:-"fdm -q fetch"}

sleep=$(getmblazeopt FolderCheckSleep)
sleep=${sleep:-30}
default_sleep=$sleep

date_fmt=$(getmblazeopt FolderCheckDateFmt)
date_fmt=${date_fmt:-"%Y-%m-%d %H:%M"}

TEMPFILES=""

if [ $# -gt 0 ]; then
Expand Down
36 changes: 25 additions & 11 deletions mailcheck
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,38 @@ MBLAZE=${MBLAZE-$HOME/.mblaze}
profile="$MBLAZE/profile"

sleep=$1
[ -z "$sleep" ] && sleep=$(mhdr -h MailCheckSleep $profile)
[ -z "$sleep" ] && sleep=30
check_cmd=$(mhdr -h MailCheckCommand $profile)
[ -z "$check_cmd" ] && check_cmd="fdm -q fetch"
check_lockf=$(mhdr -h MailCheckLockFile $profile)
[ -z "$check_lockf" ] && check_lockf=$HOME/.fdm.lock
index_cmd=$(mhdr -h MailCheckIndexCommand $profile)
[ -z "$index_cmd" ] && index_cmd="mairix -p"
[ "$index_cmd" = "-" ] && index_cmd=""
date_fmt=$(mhdr -h MailCheckDateFmt $profile)
[ -z "$date_fmt" ] && date_fmt="%Y-%m-%d %H:%M"

sleeper_pid=0

ts () {
date +"$date_fmt"
}

getmblazeopt () {
[[ -n $1 ]] && mhdr -h $1 $profile | envsubst && return 0
return 1
}

check_cmd=$(getmblazeopt MailCheckCommand)
check_cmd=${check_cmd:-"fdm -q fetch"}

sleep=${1:-$(getmblazeopt MailCheckSleep)}
sleep=${sleep:-30}

check_lockf=$(getmblazeopt MailCheckLockFile)
check_lockf=${check_lockf:-"$HOME/.fdm.lock"}

index_cmd=$(getmblazeopt MailCheckIndexCommand)
index_cmd=${index_cmd:--}
if [[ $index_cmd == "-" ]]; then
index_cmd=""
else
index_cmd=${index_cmd:-"mairix -p"}
fi

date_fmt=$(getmblazeopt MailCheckDateFmt)
date_fmt=${date_fmt:-"%Y-%m-%d %H:%M"}

shleep () {
sleep $1 >/dev/null 2>&1 & sleeper_pid=$!
echo $(ts) sleeping ...
Expand Down
7 changes: 5 additions & 2 deletions mdisplay
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ args=
use_xterm=0
use_tmux=0

[ -n $TMUX ] && use_tmux=1
[ $use_tmux -eq 0 -a -n $DISPLAY ] && use_xterm=1
if [ -n $TMUX ]; then
use_tmux=1
elif [ ${use_tmux} -eq 0 -a -n $DISPLAY ]; then
use_xterm=1
fi

for arg in $*; do
case $arg in
Expand Down