Permalink
Browse files

X: fix concurrency issues and unclutter typo

  • Loading branch information...
1 parent 1976c09 commit 91849aa5377fbd02f5fed784dbba50778579bb9e @meh meh committed Nov 13, 2012
Showing with 56 additions and 51 deletions.
  1. +56 −51 X/init.zsh
View
@@ -10,68 +10,73 @@ if [[ -z "$XAUTHORITY" ]]; then
export XAUTHORITY="$HOME/.Xauthority"
fi
-if [[ ! -e "$(path:cache)/X" ]] || \
- [[ "${ZDOTDIR:-$HOME}/.zopporc" -nt "$(path:cache)/X" ]] || \
- [[ '/tmp/.X11-unix/X0' -nt "$(path:cache)/X" ]] \
-then
- touch "$(path:cache)/X"
-else
- return
-fi
-
-if zstyle -t ':zoppo:plugin:X:screen' saver; then
- xscreensaver &> /dev/null &!
-elif zstyle -s ':zoppo:plugin:X:screen' saver saver; then
- case "$saver" in
- *) ;;
- esac
+(function {
+ # this is required so we don't clash with other concurrently opened shells
+ sleep $(( (RANDOM % 10) / 100.0 ))
- unset saver
-fi
+ if [[ ! -e "$(path:cache)/X" ]] || \
+ [[ "${ZDOTDIR:-$HOME}/.zopporc" -nt "$(path:cache)/X" ]] || \
+ [[ '/tmp/.X11-unix/X0' -nt "$(path:cache)/X" ]] \
+ then
+ touch "$(path:cache)/X"
+ else
+ return
+ fi
-if zstyle -s ':zoppo:plugin:X:screen:redshift' location location; then
- redshift -l "$longitude" &> /dev/null &!
-fi
+ if zstyle -t ':zoppo:plugin:X:screen' saver; then
+ xscreensaver &> /dev/null &!
+ elif zstyle -s ':zoppo:plugin:X:screen' saver saver; then
+ case "$saver" in
+ *) ;;
+ esac
-if zstyle -s ':zoppo:plugin:X:keyboard' language language; then
- setxkbmap "$language"
- unset language
-fi
+ unset saver
+ fi
-if zstyle -s ':zoppo:plugin:X:keyboard' input input; then
- case "$input" in
- ibus) ibus-daemon --xim &> /dev/null &! ;;
- esac
+ if zstyle -s ':zoppo:plugin:X:screen:redshift' location location; then
+ redshift -l "$longitude" &> /dev/null &!
@kljohann
kljohann Mar 5, 2013 Contributor

I guess this needs to be $location.

@meh
meh Mar 5, 2013 Contributor

Oh snap, indeed, fixing, thanks.

+ fi
- unset input
-fi
+ if zstyle -s ':zoppo:plugin:X:keyboard' language language; then
+ setxkbmap "$language"
@kljohann
kljohann Mar 6, 2013 Contributor

What do you think about something like setxkbmap ${=language}?
To correctly set my keyboard layout I'd have to use setkbmap de neo so I would be able to use zstyle ':zoppo:plugin:X:keyboard' language "de neo".

@meh
meh Mar 6, 2013 Contributor

Sounds like a good idea, fixing it.

+ unset language
+ fi
-if zstyle -t ':zoppo:plugin:X:keyboard' auto-repeat 'no'; then
- xset r off
-elif zstyle -s ':zoppo:plugin:X:keyboard' auto-repeat rate; then
- xset r rate ${=rate}
- unset rate
-fi
+ if zstyle -s ':zoppo:plugin:X:keyboard' input input; then
+ case "$input" in
+ ibus) ibus-daemon --xim &> /dev/null &! ;;
+ esac
-if [[ -r "$HOME/.Xmodmap" ]]; then
- xmodmap "$HOME/.Xmodmap"
-fi
+ unset input
+ fi
-zstyle -s ':zoppo:plugin:X:mouse' acceleration acceleration
-zstyle -s ':zoppo:plugin:X:mouse' threshold threshold
- if [[ -n "$acceleration" || -n "$threshold" ]]; then
- xset m "${acceleration:-0}" "$threshold"
+ if zstyle -t ':zoppo:plugin:X:keyboard' auto-repeat 'no'; then
+ xset r off
+ elif zstyle -s ':zoppo:plugin:X:keyboard' auto-repeat rate; then
+ xset r rate ${=rate}
+ unset rate
fi
-unset acceleration threshold
-if zstyle -s ':zoppo:plugin:X:mouse' unclutter idle; then
- if [[ "$idle" == <-> ]]; then
- unclutter -root -visibile -idle $idle &> /dev/null &!
- else
- unclutter -root -visible &> /dev/null &!
+ if [[ -r "$HOME/.Xmodmap" ]]; then
+ xmodmap "$HOME/.Xmodmap"
fi
- unset idle
-fi
+ zstyle -s ':zoppo:plugin:X:mouse' acceleration acceleration
+ zstyle -s ':zoppo:plugin:X:mouse' threshold threshold
+ if [[ -n "$acceleration" || -n "$threshold" ]]; then
+ xset m "${acceleration:-0}" "$threshold"
+ fi
+ unset acceleration threshold
+
+ if zstyle -s ':zoppo:plugin:X:mouse' unclutter idle; then
+ if [[ "$idle" == <-> ]]; then
+ unclutter -root -visible -idle "$idle" &> /dev/null &!
+ else
+ unclutter -root -visible &> /dev/null &!
+ fi
+
+ unset idle
+ fi
+}) &!
# vim: ft=zsh sts=2 ts=2 sw=2 et fdm=marker fmr={{{,}}}

0 comments on commit 91849aa

Please sign in to comment.