diff --git a/docker/aliases.zsh b/+docker/aliases.zsh similarity index 100% rename from docker/aliases.zsh rename to +docker/aliases.zsh diff --git a/docker/install b/+docker/install similarity index 100% rename from docker/install rename to +docker/install diff --git a/weechat/bin/wee b/+weechat/bin/wee similarity index 100% rename from weechat/bin/wee rename to +weechat/bin/wee diff --git a/weechat/install b/+weechat/install similarity index 100% rename from weechat/install rename to +weechat/install diff --git a/weechat/plugins.txt b/+weechat/plugins.txt similarity index 100% rename from weechat/plugins.txt rename to +weechat/plugins.txt diff --git a/weechat/scripts/init.sh b/+weechat/scripts/init.sh similarity index 100% rename from weechat/scripts/init.sh rename to +weechat/scripts/init.sh diff --git a/weechat/servers.txt b/+weechat/servers.txt similarity index 100% rename from weechat/servers.txt rename to +weechat/servers.txt diff --git a/weechat/settings.txt b/+weechat/settings.txt similarity index 100% rename from weechat/settings.txt rename to +weechat/settings.txt diff --git a/.gitignore b/.gitignore index eea4015f..d2e07524 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,10 @@ *.pid *.db -shell/tmux/.tmux/plugins/ -shell/tmux/.tmuxifier/ +shell/+tmux/.tmux/plugins/ +shell/+tmux/.tmuxifier/ -shell/mpd/.config/mpd/mpd.* -shell/mpd/.config/mpd/mpdstate +shell/+mpd/.config/mpd/mpd.* +shell/+mpd/.config/mpd/mpdstate -weechat/.weechat/* ++weechat/.weechat/* diff --git a/dev/go/env.zsh b/dev/+go/env.zsh similarity index 100% rename from dev/go/env.zsh rename to dev/+go/env.zsh diff --git a/dev/go/install b/dev/+go/install similarity index 100% rename from dev/go/install rename to dev/+go/install diff --git a/dev/haskell/.ghci b/dev/+haskell/.ghci similarity index 100% rename from dev/haskell/.ghci rename to dev/+haskell/.ghci diff --git a/dev/haskell/install b/dev/+haskell/install similarity index 100% rename from dev/haskell/install rename to dev/+haskell/install diff --git a/dev/js/.eslintrc.json b/dev/+js/.eslintrc.json similarity index 100% rename from dev/js/.eslintrc.json rename to dev/+js/.eslintrc.json diff --git a/dev/js/env.zsh b/dev/+js/env.zsh similarity index 100% rename from dev/js/env.zsh rename to dev/+js/env.zsh diff --git a/dev/js/install b/dev/+js/install similarity index 100% rename from dev/js/install rename to dev/+js/install diff --git a/dev/js/update b/dev/+js/update similarity index 100% rename from dev/js/update rename to dev/+js/update diff --git a/dev/pyenv/.config/flake8 b/dev/+pyenv/.config/flake8 similarity index 100% rename from dev/pyenv/.config/flake8 rename to dev/+pyenv/.config/flake8 diff --git a/dev/pyenv/aliases.zsh b/dev/+pyenv/aliases.zsh similarity index 100% rename from dev/pyenv/aliases.zsh rename to dev/+pyenv/aliases.zsh diff --git a/dev/pyenv/env.zsh b/dev/+pyenv/env.zsh similarity index 100% rename from dev/pyenv/env.zsh rename to dev/+pyenv/env.zsh diff --git a/dev/pyenv/install b/dev/+pyenv/install similarity index 100% rename from dev/pyenv/install rename to dev/+pyenv/install diff --git a/dev/pyenv/update b/dev/+pyenv/update similarity index 100% rename from dev/pyenv/update rename to dev/+pyenv/update diff --git a/dev/rbenv/.irbrc b/dev/+rbenv/.irbrc similarity index 100% rename from dev/rbenv/.irbrc rename to dev/+rbenv/.irbrc diff --git a/dev/rbenv/.pryrc b/dev/+rbenv/.pryrc similarity index 100% rename from dev/rbenv/.pryrc rename to dev/+rbenv/.pryrc diff --git a/dev/rbenv/.rspec b/dev/+rbenv/.rspec similarity index 100% rename from dev/rbenv/.rspec rename to dev/+rbenv/.rspec diff --git a/dev/rbenv/aliases.zsh b/dev/+rbenv/aliases.zsh similarity index 100% rename from dev/rbenv/aliases.zsh rename to dev/+rbenv/aliases.zsh diff --git a/dev/rbenv/env.zsh b/dev/+rbenv/env.zsh similarity index 100% rename from dev/rbenv/env.zsh rename to dev/+rbenv/env.zsh diff --git a/dev/rbenv/install b/dev/+rbenv/install similarity index 100% rename from dev/rbenv/install rename to dev/+rbenv/install diff --git a/dev/rbenv/update b/dev/+rbenv/update similarity index 100% rename from dev/rbenv/update rename to dev/+rbenv/update diff --git a/editor/editorconfig/.editorconfig b/editor/+editorconfig/.editorconfig similarity index 100% rename from editor/editorconfig/.editorconfig rename to editor/+editorconfig/.editorconfig diff --git a/editor/editorconfig/install b/editor/+editorconfig/install similarity index 100% rename from editor/editorconfig/install rename to editor/+editorconfig/install diff --git a/editor/emacs/aliases.zsh b/editor/+emacs/aliases.zsh similarity index 100% rename from editor/emacs/aliases.zsh rename to editor/+emacs/aliases.zsh diff --git a/editor/emacs/env.zsh b/editor/+emacs/env.zsh similarity index 100% rename from editor/emacs/env.zsh rename to editor/+emacs/env.zsh diff --git a/editor/emacs/install b/editor/+emacs/install similarity index 100% rename from editor/emacs/install rename to editor/+emacs/install diff --git a/editor/emacs/update b/editor/+emacs/update similarity index 100% rename from editor/emacs/update rename to editor/+emacs/update diff --git a/editor/neovim/aliases.zsh b/editor/+neovim/aliases.zsh similarity index 100% rename from editor/neovim/aliases.zsh rename to editor/+neovim/aliases.zsh diff --git a/editor/neovim/install b/editor/+neovim/install similarity index 100% rename from editor/neovim/install rename to editor/+neovim/install diff --git a/editor/neovim/update b/editor/+neovim/update similarity index 100% rename from editor/neovim/update rename to editor/+neovim/update diff --git a/editor/vim/aliases.zsh b/editor/+vim/aliases.zsh similarity index 100% rename from editor/vim/aliases.zsh rename to editor/+vim/aliases.zsh diff --git a/editor/vim/install b/editor/+vim/install similarity index 100% rename from editor/vim/install rename to editor/+vim/install diff --git a/editor/vim/update b/editor/+vim/update similarity index 100% rename from editor/vim/update rename to editor/+vim/update diff --git a/editor/vimlite/.vimrc b/editor/+vimlite/.vimrc similarity index 100% rename from editor/vimlite/.vimrc rename to editor/+vimlite/.vimrc diff --git a/editor/vimlite/install b/editor/+vimlite/install similarity index 100% rename from editor/vimlite/install rename to editor/+vimlite/install diff --git a/os/arch/apple-btkbd/README.md b/os/+arch/+apple-btkbd/README.md similarity index 100% rename from os/arch/apple-btkbd/README.md rename to os/+arch/+apple-btkbd/README.md diff --git a/os/arch/apple-btkbd/btkbd.conf b/os/+arch/+apple-btkbd/btkbd.conf similarity index 100% rename from os/arch/apple-btkbd/btkbd.conf rename to os/+arch/+apple-btkbd/btkbd.conf diff --git a/os/arch/apple-btkbd/btkbd.service b/os/+arch/+apple-btkbd/btkbd.service similarity index 100% rename from os/arch/apple-btkbd/btkbd.service rename to os/+arch/+apple-btkbd/btkbd.service diff --git a/os/arch/apple-btkbd/install b/os/+arch/+apple-btkbd/install similarity index 100% rename from os/arch/apple-btkbd/install rename to os/+arch/+apple-btkbd/install diff --git a/os/arch/automount/README.md b/os/+arch/+automount/README.md similarity index 100% rename from os/arch/automount/README.md rename to os/+arch/+automount/README.md diff --git a/os/arch/automount/bin/notify-mount b/os/+arch/+automount/bin/notify-mount similarity index 100% rename from os/arch/automount/bin/notify-mount rename to os/+arch/+automount/bin/notify-mount diff --git a/os/arch/automount/install b/os/+arch/+automount/install similarity index 100% rename from os/arch/automount/install rename to os/+arch/+automount/install diff --git a/os/arch/.Xmodmap b/os/+arch/.Xmodmap similarity index 100% rename from os/arch/.Xmodmap rename to os/+arch/.Xmodmap diff --git a/os/arch/.Xresources b/os/+arch/.Xresources similarity index 100% rename from os/arch/.Xresources rename to os/+arch/.Xresources diff --git a/os/arch/.config/bspwm/bspwmrc b/os/+arch/.config/bspwm/bspwmrc similarity index 100% rename from os/arch/.config/bspwm/bspwmrc rename to os/+arch/.config/bspwm/bspwmrc diff --git a/os/arch/.config/compton.conf b/os/+arch/.config/compton.conf similarity index 100% rename from os/arch/.config/compton.conf rename to os/+arch/.config/compton.conf diff --git a/os/arch/.config/dunst/dunstrc b/os/+arch/.config/dunst/dunstrc similarity index 100% rename from os/arch/.config/dunst/dunstrc rename to os/+arch/.config/dunst/dunstrc diff --git a/os/arch/.config/fontconfig/fonts.conf b/os/+arch/.config/fontconfig/fonts.conf similarity index 100% rename from os/arch/.config/fontconfig/fonts.conf rename to os/+arch/.config/fontconfig/fonts.conf diff --git a/os/arch/.config/gtk-3.0/gtk.css b/os/+arch/.config/gtk-3.0/gtk.css similarity index 100% rename from os/arch/.config/gtk-3.0/gtk.css rename to os/+arch/.config/gtk-3.0/gtk.css diff --git a/os/arch/.config/gtk-3.0/settings.ini b/os/+arch/.config/gtk-3.0/settings.ini similarity index 100% rename from os/arch/.config/gtk-3.0/settings.ini rename to os/+arch/.config/gtk-3.0/settings.ini diff --git a/os/arch/.config/panel/README.md b/os/+arch/.config/panel/README.md similarity index 100% rename from os/arch/.config/panel/README.md rename to os/+arch/.config/panel/README.md diff --git a/os/arch/.config/panel/lemons/battery b/os/+arch/.config/panel/lemons/battery similarity index 100% rename from os/arch/.config/panel/lemons/battery rename to os/+arch/.config/panel/lemons/battery diff --git a/os/+arch/.config/panel/lemons/disabled/music b/os/+arch/.config/panel/lemons/disabled/music new file mode 100755 index 00000000..fa08fd88 --- /dev/null +++ b/os/+arch/.config/panel/lemons/disabled/music @@ -0,0 +1,47 @@ +#!/usr/bin/env dash + +. $(dirname $0)/../panel-config + +progress_bar() { + BAR_SIZE=${2:-26} + C1="%{F${COLOR_6}}-%{F-}" + C2="%{F${COLOR_DIM}}-%{F-}" + DELIM= + + echo "$1" | SIZE=$BAR_SIZE CHAR1="$C1" CHAR2="$C2" SEP='' START="$DELIM" END="$DELIM" mkb +} + +while :; do + if ! pgrep mpd >/dev/null; then + sleep 5 + continue + fi + + output=$(mpc -h $HOME/.config/mpd/mpd.sock --format ";%title%;%artist%;%album%") + if echo $output | grep "^;" 2>&1 >/dev/null; then + # title=$(echo "$output" | head -1 | cut -d';' -f2) + # artist=$(echo "$output" | head -1 | cut -d';' -f3) + # album=$(echo "$output" | head -1 | cut -d';' -f4) + seek=$(echo "$output" | awk 'NR==2 {print $3}') + perc=$(echo "$output" | awk 'NR==2 {print $4}' | tr -d '()') + state=$(echo "$output" | awk 'NR==2 {print $1}') + + case "$state" in + "[playing]") icon="%{F${COLOR_2}}${ICON_PLAY}%{F-}" ;; + "[paused]") icon="%{F${COLOR_4}}${ICON_PAUSE}%{F-}" ;; + *) icon="" ;; + esac + + if [ -n "$icon" ] + then + # song="$title - $artist" + # [ -n "$album" ] && song="$song ($album)" + echo "S%{B${COLOR_ALTBG}} $icon ${seek%/*} $(progress_bar $perc 16) ${seek#*/} %{B-} " + fi + else + echo "S" + fi + sleep 1 +done + +# vim:set ft=sh: diff --git a/os/arch/.config/panel/lemons/mail b/os/+arch/.config/panel/lemons/mail similarity index 100% rename from os/arch/.config/panel/lemons/mail rename to os/+arch/.config/panel/lemons/mail diff --git a/os/arch/.config/panel/lemons/updates b/os/+arch/.config/panel/lemons/updates similarity index 100% rename from os/arch/.config/panel/lemons/updates rename to os/+arch/.config/panel/lemons/updates diff --git a/os/arch/.config/panel/lemons/volume b/os/+arch/.config/panel/lemons/volume similarity index 100% rename from os/arch/.config/panel/lemons/volume rename to os/+arch/.config/panel/lemons/volume diff --git a/os/arch/.config/panel/lemons/wifi b/os/+arch/.config/panel/lemons/wifi similarity index 100% rename from os/arch/.config/panel/lemons/wifi rename to os/+arch/.config/panel/lemons/wifi diff --git a/os/arch/.config/panel/panel b/os/+arch/.config/panel/panel similarity index 100% rename from os/arch/.config/panel/panel rename to os/+arch/.config/panel/panel diff --git a/os/arch/.config/panel/panel-config b/os/+arch/.config/panel/panel-config similarity index 100% rename from os/arch/.config/panel/panel-config rename to os/+arch/.config/panel/panel-config diff --git a/os/arch/.config/panel/panel-notify b/os/+arch/.config/panel/panel-notify similarity index 100% rename from os/arch/.config/panel/panel-notify rename to os/+arch/.config/panel/panel-notify diff --git a/os/arch/.config/panel/panel-pacman-hook b/os/+arch/.config/panel/panel-pacman-hook similarity index 100% rename from os/arch/.config/panel/panel-pacman-hook rename to os/+arch/.config/panel/panel-pacman-hook diff --git a/os/arch/.config/redshift.conf b/os/+arch/.config/redshift.conf similarity index 100% rename from os/arch/.config/redshift.conf rename to os/+arch/.config/redshift.conf diff --git a/os/arch/.config/sxhkd/sxhkdrc b/os/+arch/.config/sxhkd/sxhkdrc similarity index 100% rename from os/arch/.config/sxhkd/sxhkdrc rename to os/+arch/.config/sxhkd/sxhkdrc diff --git a/os/arch/.config/termite/config b/os/+arch/.config/termite/config similarity index 100% rename from os/arch/.config/termite/config rename to os/+arch/.config/termite/config diff --git a/os/arch/.xinitrc b/os/+arch/.xinitrc similarity index 100% rename from os/arch/.xinitrc rename to os/+arch/.xinitrc diff --git a/os/arch/.xprofile b/os/+arch/.xprofile similarity index 100% rename from os/arch/.xprofile rename to os/+arch/.xprofile diff --git a/os/arch/aliases.zsh b/os/+arch/aliases.zsh similarity index 100% rename from os/arch/aliases.zsh rename to os/+arch/aliases.zsh diff --git a/os/arch/bin/bspc.sh b/os/+arch/bin/bspc.sh similarity index 100% rename from os/arch/bin/bspc.sh rename to os/+arch/bin/bspc.sh diff --git a/os/arch/bin/rec b/os/+arch/bin/rec similarity index 100% rename from os/arch/bin/rec rename to os/+arch/bin/rec diff --git a/os/arch/bin/rsl b/os/+arch/bin/rsl similarity index 100% rename from os/arch/bin/rsl rename to os/+arch/bin/rsl diff --git a/os/arch/bin/vol b/os/+arch/bin/vol similarity index 100% rename from os/arch/bin/vol rename to os/+arch/bin/vol diff --git a/os/arch/bootstrap b/os/+arch/bootstrap similarity index 100% rename from os/arch/bootstrap rename to os/+arch/bootstrap diff --git a/os/arch/crontab b/os/+arch/crontab similarity index 100% rename from os/arch/crontab rename to os/+arch/crontab diff --git a/os/arch/env.zsh b/os/+arch/env.zsh similarity index 100% rename from os/arch/env.zsh rename to os/+arch/env.zsh diff --git a/os/arch/install b/os/+arch/install similarity index 100% rename from os/arch/install rename to os/+arch/install diff --git a/os/arch/pacman.d/hooks/lemonbar.hook b/os/+arch/pacman.d/hooks/lemonbar.hook similarity index 100% rename from os/arch/pacman.d/hooks/lemonbar.hook rename to os/+arch/pacman.d/hooks/lemonbar.hook diff --git a/os/arch/pacman.d/hooks/nvidia.hook b/os/+arch/pacman.d/hooks/nvidia.hook similarity index 100% rename from os/arch/pacman.d/hooks/nvidia.hook rename to os/+arch/pacman.d/hooks/nvidia.hook diff --git a/os/arch/update b/os/+arch/update similarity index 100% rename from os/arch/update rename to os/+arch/update diff --git a/os/macos/.hushlogin b/os/+macos/.hushlogin similarity index 100% rename from os/macos/.hushlogin rename to os/+macos/.hushlogin diff --git a/os/macos/aliases.zsh b/os/+macos/aliases.zsh similarity index 100% rename from os/macos/aliases.zsh rename to os/+macos/aliases.zsh diff --git a/os/macos/bin/html2pdf b/os/+macos/bin/html2pdf similarity index 100% rename from os/macos/bin/html2pdf rename to os/+macos/bin/html2pdf diff --git a/os/macos/bin/run-boris b/os/+macos/bin/run-boris similarity index 100% rename from os/macos/bin/run-boris rename to os/+macos/bin/run-boris diff --git a/os/macos/bin/timelapse b/os/+macos/bin/timelapse similarity index 100% rename from os/macos/bin/timelapse rename to os/+macos/bin/timelapse diff --git a/os/macos/bin/timelapse2mov b/os/+macos/bin/timelapse2mov similarity index 100% rename from os/macos/bin/timelapse2mov rename to os/+macos/bin/timelapse2mov diff --git a/os/macos/env.zsh b/os/+macos/env.zsh similarity index 100% rename from os/macos/env.zsh rename to os/+macos/env.zsh diff --git a/os/macos/install b/os/+macos/install similarity index 100% rename from os/macos/install rename to os/+macos/install diff --git a/os/macos/update b/os/+macos/update similarity index 100% rename from os/macos/update rename to os/+macos/update diff --git a/recipes/triton b/recipes/triton index 35fdb3e2..98e92466 100755 --- a/recipes/triton +++ b/recipes/triton @@ -1,13 +1,13 @@ -os/arch -os/arch/automount -docker -dev/* -editor/emacs -editor/neovim -shell/zsh -shell/ssh -shell/fzf -shell/tmux -shell/mu -shell/mpd -vcs/* +os/+arch +os/+arch/+automount ++docker +dev/+* +editor/+emacs +editor/+neovim +shell/+zsh +shell/+ssh +shell/+fzf +shell/+tmux +shell/+mu +shell/+mpd +vcs/+* diff --git a/shell/bash/.bash_profile b/shell/+bash/.bash_profile similarity index 100% rename from shell/bash/.bash_profile rename to shell/+bash/.bash_profile diff --git a/shell/bash/.bashrc b/shell/+bash/.bashrc similarity index 100% rename from shell/bash/.bashrc rename to shell/+bash/.bashrc diff --git a/shell/bash/README.md b/shell/+bash/README.md similarity index 100% rename from shell/bash/README.md rename to shell/+bash/README.md diff --git a/shell/bash/aliases.bash b/shell/+bash/aliases.bash similarity index 100% rename from shell/bash/aliases.bash rename to shell/+bash/aliases.bash diff --git a/shell/bash/config.bash b/shell/+bash/config.bash similarity index 100% rename from shell/bash/config.bash rename to shell/+bash/config.bash diff --git a/shell/bash/prompt.bash b/shell/+bash/prompt.bash similarity index 100% rename from shell/bash/prompt.bash rename to shell/+bash/prompt.bash diff --git a/shell/fzf/aliases.zsh b/shell/+fzf/aliases.zsh similarity index 100% rename from shell/fzf/aliases.zsh rename to shell/+fzf/aliases.zsh diff --git a/shell/fzf/bin/fzf-apps b/shell/+fzf/bin/fzf-apps similarity index 100% rename from shell/fzf/bin/fzf-apps rename to shell/+fzf/bin/fzf-apps diff --git a/shell/fzf/bin/fzf-bookmarks b/shell/+fzf/bin/fzf-bookmarks similarity index 100% rename from shell/fzf/bin/fzf-bookmarks rename to shell/+fzf/bin/fzf-bookmarks diff --git a/shell/fzf/bin/fzf-git-log b/shell/+fzf/bin/fzf-git-log similarity index 100% rename from shell/fzf/bin/fzf-git-log rename to shell/+fzf/bin/fzf-git-log diff --git a/shell/fzf/bin/fzf-git-sha b/shell/+fzf/bin/fzf-git-sha similarity index 100% rename from shell/fzf/bin/fzf-git-sha rename to shell/+fzf/bin/fzf-git-sha diff --git a/shell/fzf/bin/fzf-history b/shell/+fzf/bin/fzf-history similarity index 100% rename from shell/fzf/bin/fzf-history rename to shell/+fzf/bin/fzf-history diff --git a/shell/fzf/bin/fzf-kill b/shell/+fzf/bin/fzf-kill similarity index 100% rename from shell/fzf/bin/fzf-kill rename to shell/+fzf/bin/fzf-kill diff --git a/shell/fzf/bin/fzf-mpc b/shell/+fzf/bin/fzf-mpc similarity index 100% rename from shell/fzf/bin/fzf-mpc rename to shell/+fzf/bin/fzf-mpc diff --git a/shell/fzf/bin/fzf-pass b/shell/+fzf/bin/fzf-pass similarity index 100% rename from shell/fzf/bin/fzf-pass rename to shell/+fzf/bin/fzf-pass diff --git a/shell/fzf/bin/gui-fzf b/shell/+fzf/bin/gui-fzf similarity index 100% rename from shell/fzf/bin/gui-fzf rename to shell/+fzf/bin/gui-fzf diff --git a/shell/fzf/install b/shell/+fzf/install similarity index 100% rename from shell/fzf/install rename to shell/+fzf/install diff --git a/shell/mpd/.config/mpd/mpd-linux.conf b/shell/+mpd/.config/mpd/mpd-linux.conf similarity index 100% rename from shell/mpd/.config/mpd/mpd-linux.conf rename to shell/+mpd/.config/mpd/mpd-linux.conf diff --git a/shell/mpd/.config/mpd/mpd-osx.conf b/shell/+mpd/.config/mpd/mpd-osx.conf similarity index 100% rename from shell/mpd/.config/mpd/mpd-osx.conf rename to shell/+mpd/.config/mpd/mpd-osx.conf diff --git a/shell/mpd/.ncmpcpp/bindings b/shell/+mpd/.ncmpcpp/bindings similarity index 100% rename from shell/mpd/.ncmpcpp/bindings rename to shell/+mpd/.ncmpcpp/bindings diff --git a/shell/mpd/.ncmpcpp/config b/shell/+mpd/.ncmpcpp/config similarity index 100% rename from shell/mpd/.ncmpcpp/config rename to shell/+mpd/.ncmpcpp/config diff --git a/shell/mpd/README.md b/shell/+mpd/README.md similarity index 100% rename from shell/mpd/README.md rename to shell/+mpd/README.md diff --git a/shell/mpd/aliases.zsh b/shell/+mpd/aliases.zsh similarity index 100% rename from shell/mpd/aliases.zsh rename to shell/+mpd/aliases.zsh diff --git a/shell/mpd/bin/cleanup-music b/shell/+mpd/bin/cleanup-music similarity index 100% rename from shell/mpd/bin/cleanup-music rename to shell/+mpd/bin/cleanup-music diff --git a/shell/mpd/bin/notify-song.sh b/shell/+mpd/bin/notify-song.sh similarity index 100% rename from shell/mpd/bin/notify-song.sh rename to shell/+mpd/bin/notify-song.sh diff --git a/shell/mpd/bin/rate b/shell/+mpd/bin/rate similarity index 100% rename from shell/mpd/bin/rate rename to shell/+mpd/bin/rate diff --git a/shell/mpd/install b/shell/+mpd/install similarity index 100% rename from shell/mpd/install rename to shell/+mpd/install diff --git a/shell/mu/.offlineimaprc b/shell/+mu/.offlineimaprc similarity index 100% rename from shell/mu/.offlineimaprc rename to shell/+mu/.offlineimaprc diff --git a/shell/mu/bin/update-mail b/shell/+mu/bin/update-mail similarity index 100% rename from shell/mu/bin/update-mail rename to shell/+mu/bin/update-mail diff --git a/shell/mu/install b/shell/+mu/install similarity index 100% rename from shell/mu/install rename to shell/+mu/install diff --git a/shell/mu/lib.py b/shell/+mu/lib.py similarity index 100% rename from shell/mu/lib.py rename to shell/+mu/lib.py diff --git a/shell/mu/mbsyncrc b/shell/+mu/mbsyncrc similarity index 100% rename from shell/mu/mbsyncrc rename to shell/+mu/mbsyncrc diff --git a/shell/ssh/install b/shell/+ssh/install similarity index 100% rename from shell/ssh/install rename to shell/+ssh/install diff --git a/shell/tmux/.tmux.conf b/shell/+tmux/.tmux.conf similarity index 100% rename from shell/tmux/.tmux.conf rename to shell/+tmux/.tmux.conf diff --git a/shell/tmux/.tmux/osx.conf b/shell/+tmux/.tmux/osx.conf similarity index 100% rename from shell/tmux/.tmux/osx.conf rename to shell/+tmux/.tmux/osx.conf diff --git a/shell/tmux/.tmux/scripts/swap-pane.sh b/shell/+tmux/.tmux/scripts/swap-pane.sh similarity index 100% rename from shell/tmux/.tmux/scripts/swap-pane.sh rename to shell/+tmux/.tmux/scripts/swap-pane.sh diff --git a/shell/tmux/aliases.zsh b/shell/+tmux/aliases.zsh similarity index 100% rename from shell/tmux/aliases.zsh rename to shell/+tmux/aliases.zsh diff --git a/shell/tmux/bin/tmux-session-name b/shell/+tmux/bin/tmux-session-name similarity index 100% rename from shell/tmux/bin/tmux-session-name rename to shell/+tmux/bin/tmux-session-name diff --git a/shell/tmux/env.zsh b/shell/+tmux/env.zsh similarity index 100% rename from shell/tmux/env.zsh rename to shell/+tmux/env.zsh diff --git a/shell/tmux/install b/shell/+tmux/install similarity index 100% rename from shell/tmux/install rename to shell/+tmux/install diff --git a/shell/tmux/update b/shell/+tmux/update similarity index 100% rename from shell/tmux/update rename to shell/+tmux/update diff --git a/shell/zsh/.zshenv b/shell/+zsh/.zshenv similarity index 85% rename from shell/zsh/.zshenv rename to shell/+zsh/.zshenv index 2068bcc0..fd04b67e 100644 --- a/shell/zsh/.zshenv +++ b/shell/+zsh/.zshenv @@ -5,11 +5,11 @@ source "$HOME/.dotfiles/shell/common.sh" typeset -gU cdpath fpath mailpath path path=( $DOTFILES/bin "$ENABLED_DIR"/*/bin /usr/local/{,s}bin $path ) -load shell/zsh/config.zsh +load shell/+zsh/config.zsh loadall env.zsh fpath=( - $DOTFILES/shell/zsh/completions + $DOTFILES/shell/+zsh/completions $fpath ) diff --git a/shell/zsh/.zshrc b/shell/+zsh/.zshrc similarity index 86% rename from shell/zsh/.zshrc rename to shell/+zsh/.zshrc index 123897af..345a8e40 100644 --- a/shell/zsh/.zshrc +++ b/shell/+zsh/.zshrc @@ -20,9 +20,9 @@ if ! zgen saved; then fi if is-interactive; then - load shell/zsh/completion.zsh - load shell/zsh/keybinds.zsh - load shell/zsh/prompt.zsh + load shell/+zsh/completion.zsh + load shell/+zsh/keybinds.zsh + load shell/+zsh/prompt.zsh cache fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install fi diff --git a/shell/zsh/README.md b/shell/+zsh/README.md similarity index 100% rename from shell/zsh/README.md rename to shell/+zsh/README.md diff --git a/shell/zsh/aliases.zsh b/shell/+zsh/aliases.zsh similarity index 100% rename from shell/zsh/aliases.zsh rename to shell/+zsh/aliases.zsh diff --git a/shell/zsh/completion.zsh b/shell/+zsh/completion.zsh similarity index 100% rename from shell/zsh/completion.zsh rename to shell/+zsh/completion.zsh diff --git a/shell/zsh/completions/_lsarchive b/shell/+zsh/completions/_lsarchive similarity index 100% rename from shell/zsh/completions/_lsarchive rename to shell/+zsh/completions/_lsarchive diff --git a/shell/zsh/completions/_unarchive b/shell/+zsh/completions/_unarchive similarity index 100% rename from shell/zsh/completions/_unarchive rename to shell/+zsh/completions/_unarchive diff --git a/shell/zsh/config.zsh b/shell/+zsh/config.zsh similarity index 100% rename from shell/zsh/config.zsh rename to shell/+zsh/config.zsh diff --git a/shell/zsh/install b/shell/+zsh/install similarity index 100% rename from shell/zsh/install rename to shell/+zsh/install diff --git a/shell/zsh/keybinds.zsh b/shell/+zsh/keybinds.zsh similarity index 100% rename from shell/zsh/keybinds.zsh rename to shell/+zsh/keybinds.zsh diff --git a/shell/zsh/prompt.zsh b/shell/+zsh/prompt.zsh similarity index 100% rename from shell/zsh/prompt.zsh rename to shell/+zsh/prompt.zsh diff --git a/shell/zsh/update b/shell/+zsh/update similarity index 100% rename from shell/zsh/update rename to shell/+zsh/update diff --git a/shell/tmux/.tmux/plugins/.git-keep b/shell/tmux/.tmux/plugins/.git-keep deleted file mode 100644 index e69de29b..00000000 diff --git a/vcs/git/.gitconfig b/vcs/+git/.gitconfig similarity index 100% rename from vcs/git/.gitconfig rename to vcs/+git/.gitconfig diff --git a/vcs/git/.gitignore b/vcs/+git/.gitignore similarity index 100% rename from vcs/git/.gitignore rename to vcs/+git/.gitignore diff --git a/vcs/git/aliases.zsh b/vcs/+git/aliases.zsh similarity index 100% rename from vcs/git/aliases.zsh rename to vcs/+git/aliases.zsh diff --git a/vcs/git/bin/git-move-root-to b/vcs/+git/bin/git-move-root-to similarity index 100% rename from vcs/git/bin/git-move-root-to rename to vcs/+git/bin/git-move-root-to diff --git a/vcs/git/bin/git-old-commit b/vcs/+git/bin/git-old-commit similarity index 100% rename from vcs/git/bin/git-old-commit rename to vcs/+git/bin/git-old-commit diff --git a/vcs/git/bin/git-stats b/vcs/+git/bin/git-stats similarity index 100% rename from vcs/git/bin/git-stats rename to vcs/+git/bin/git-stats diff --git a/vcs/git/install b/vcs/+git/install similarity index 100% rename from vcs/git/install rename to vcs/+git/install diff --git a/vcs/hg/.hgignore b/vcs/+hg/.hgignore similarity index 100% rename from vcs/hg/.hgignore rename to vcs/+hg/.hgignore diff --git a/vcs/hg/.hgrc b/vcs/+hg/.hgrc similarity index 100% rename from vcs/hg/.hgrc rename to vcs/+hg/.hgrc diff --git a/vcs/hg/install b/vcs/+hg/install similarity index 100% rename from vcs/hg/install rename to vcs/+hg/install diff --git a/weechat/.weechat/plugins.conf b/weechat/.weechat/plugins.conf deleted file mode 100644 index ea154336..00000000 --- a/weechat/.weechat/plugins.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# weechat -- plugins.conf -# - -[var] -fifo.fifo = "on" - -[desc] diff --git a/weechat/.weechat/python/autoload/notify_send.py b/weechat/.weechat/python/autoload/notify_send.py deleted file mode 120000 index deeb9a78..00000000 --- a/weechat/.weechat/python/autoload/notify_send.py +++ /dev/null @@ -1 +0,0 @@ -../notify_send.py \ No newline at end of file diff --git a/weechat/.weechat/python/notify_send.py b/weechat/.weechat/python/notify_send.py deleted file mode 100644 index e126e40c..00000000 --- a/weechat/.weechat/python/notify_send.py +++ /dev/null @@ -1,639 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Project: weechat-notify-send -# Homepage: https://github.com/s3rvac/weechat-notify-send -# Description: Sends highlight and message notifications through notify-send. -# Requires libnotify. -# License: MIT (see below) -# -# Copyright (c) 2015-2016 by Petr Zemek and contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -import os -import subprocess -import sys -import time - - -# Ensure that we are running under WeeChat. -try: - import weechat -except ImportError: - print('This script has to run under WeeChat (https://weechat.org/).') - sys.exit(1) - - -# Name of the script. -SCRIPT_NAME = 'notify_send' - -# Author of the script. -SCRIPT_AUTHOR = 's3rvac' - -# Version of the script. -SCRIPT_VERSION = '0.7 (dev)' - -# License under which the script is distributed. -SCRIPT_LICENSE = 'MIT' - -# Description of the script. -SCRIPT_DESC = 'Sends highlight and message notifications through notify-send.' - -# Name of a function to be called when the script is unloaded. -SCRIPT_SHUTDOWN_FUNC = '' - -# Used character set (utf-8 by default). -SCRIPT_CHARSET = '' - -# Script options. -OPTIONS = { - 'notify_on_highlights': ( - 'on', - 'Send notifications on highlights.' - ), - 'notify_on_privmsgs': ( - 'on', - 'Send notifications on private messages.' - ), - 'notify_on_filtered_messages': ( - 'off', - 'Send notifications also on filtered (hidden) messages.' - ), - 'notify_when_away': ( - 'on', - 'Send also notifications when away.' - ), - 'notify_for_current_buffer': ( - 'on', - 'Send also notifications for the currently active buffer.' - ), - 'notify_on_all_messages_in_buffers': ( - '', - 'A comma-separated list of buffers for which you want to receive ' - 'notifications on all messages that appear in them.' - ), - 'min_notification_delay': ( - '500', - 'A minimal delay between successive notifications from the same ' - 'buffer (in milliseconds; set to 0 to show all notifications).' - ), - 'ignore_messages_tagged_with': ( - # irc_join: Joined IRC - # irc_quit: Quit IRC - # irc_part: Parted a channel - # irc_status: Status messages - # irc_nick_back: A nick is back on server - # irc_401: No such nick/channel - # irc_402: No such server - 'irc_join,irc_quit,irc_part,irc_status,irc_nick_back,irc_401,irc_402', - 'A comma-separated list of message tags for which no notifications ' - 'should be shown.' - ), - 'ignore_buffers': ( - '', - 'A comma-separated list of buffers from which no notifications should ' - 'be shown.' - ), - 'ignore_buffers_starting_with': ( - '', - 'A comma-separated list of buffer prefixes from which no ' - 'notifications should be shown.' - ), - 'ignore_nicks': ( - '', - 'A comma-separated list of nicks from which no notifications should ' - 'be shown.' - ), - 'ignore_nicks_starting_with': ( - '', - 'A comma-separated list of nick prefixes from which no ' - 'notifications should be shown.' - ), - 'nick_separator': ( - ': ', - 'A separator between a nick and a message.' - ), - 'escape_html': ( - 'on', - "Escapes the '<', '>', and '&' characters in notification messages." - ), - 'max_length': ( - '72', - 'Maximal length of a notification (0 means no limit).' - ), - 'ellipsis': ( - '[..]', - 'Ellipsis to be used for notifications that are too long.' - ), - 'icon': ( - '/usr/share/icons/hicolor/32x32/apps/weechat.png', - 'Path to an icon to be shown in notifications.' - ), - 'timeout': ( - '5000', - 'Time after which the notification disappears (in milliseconds; ' - 'set to 0 to disable).' - ), - 'urgency': ( - 'normal', - 'Urgency (low, normal, critical).' - ) -} - - -class Notification(object): - """A representation of a notification.""" - - def __init__(self, source, message, icon, timeout, urgency): - self.source = source - self.message = message - self.icon = icon - self.timeout = timeout - self.urgency = urgency - - -def default_value_of(option): - """Returns the default value of the given option.""" - return OPTIONS[option][0] - - -def add_default_value_to(description, default_value): - """Adds the given default value to the given option description.""" - # All descriptions end with a period, so do not add another period. - return '{} Default: {}.'.format( - description, - default_value if default_value else '""' - ) - - -def nick_that_sent_message(tags, prefix): - """Returns a nick that sent the message based on the given data passed to - the callback. - """ - # 'tags' is a comma-separated list of tags that WeeChat passed to the - # callback. It should contain a tag of the following form: nick_XYZ, where - # XYZ is the nick that sent the message. - for tag in tags: - if tag.startswith('nick_'): - return tag[5:] - - # There is no nick in the tags, so check the prefix as a fallback. - # 'prefix' (str) is the prefix of the printed line with the message. - # Usually (but not always), it is a nick with an optional mode (e.g. on - # IRC, @ denotes an operator and + denotes a user with voice). We have to - # remove the mode (if any) before returning the nick. - # Strip also a space as some protocols (e.g. Matrix) may start prefixes - # with a space. It probably means that the nick has no mode set. - if prefix.startswith(('~', '&', '@', '%', '+', '-', ' ')): - return prefix[1:] - - return prefix - - -def parse_tags(tags): - """Parses the given "list" of tags (str) from WeeChat into a list. - """ - return tags.split(',') - - -def message_printed_callback(data, buffer, date, tags, is_displayed, - is_highlight, prefix, message): - """A callback when a message is printed.""" - is_displayed = int(is_displayed) - is_highlight = int(is_highlight) - tags = parse_tags(tags) - nick = nick_that_sent_message(tags, prefix) - - if notification_should_be_sent(buffer, tags, nick, is_displayed, is_highlight): - notification = prepare_notification( - buffer, is_highlight, nick, message - ) - send_notification(notification) - - return weechat.WEECHAT_RC_OK - - -def notification_should_be_sent(buffer, tags, nick, is_displayed, is_highlight): - """Should a notification be sent?""" - if notification_should_be_sent_disregarding_time(buffer, tags, nick, - is_displayed, is_highlight): - # The following function should be called only when the notification - # should be sent (it updates the last notification time). - if not is_below_min_notification_delay(buffer): - return True - return False - - -def notification_should_be_sent_disregarding_time(buffer, tags, nick, - is_displayed, is_highlight): - """Should a notification be sent when not considering time?""" - if i_am_author_of_message(buffer, nick): - return False - - if not is_displayed: - if not notify_on_filtered_messages(): - return False - - if buffer == weechat.current_buffer(): - if not notify_for_current_buffer(): - return False - - if is_away(buffer): - if not notify_when_away(): - return False - - if ignore_notifications_from_messages_tagged_with(tags): - return False - - if ignore_notifications_from_nick(nick): - return False - - if ignore_notifications_from_buffer(buffer): - return False - - if is_private_message(buffer): - return notify_on_private_messages() - - if is_highlight: - return notify_on_highlights() - - if notify_on_all_messages_in_buffer(buffer): - return True - - return False - - -def is_below_min_notification_delay(buffer): - """Is a notification in the given buffer below the minimal delay between - successive notifications from the same buffer? - - When called, this function updates the time of the last notification. - """ - # We store the time of the last notification in a buffer-local variable to - # make it persistent over the lifetime of this plugin. - LAST_NOTIFICATION_TIME_VAR = 'notify_send_last_notification_time' - last_notification_time = buffer_get_float( - buffer, - 'localvar_' + LAST_NOTIFICATION_TIME_VAR - ) - - min_notification_delay = weechat.config_get_plugin('min_notification_delay') - # min_notification_delay is in milliseconds (str). To compare it with - # last_notification_time (float in seconds), we have to convert it to - # seconds (float). - min_notification_delay = float(min_notification_delay) / 1000 - - current_time = time.time() - - # We have to update the last notification time before returning the result. - buffer_set_float( - buffer, - 'localvar_set_' + LAST_NOTIFICATION_TIME_VAR, - current_time - ) - - return (min_notification_delay > 0 and - current_time - last_notification_time < min_notification_delay) - - -def buffer_get_float(buffer, property): - """A variant of weechat.buffer_get_x() for floats. - - This variant is needed because WeeChat supports only buffer_get_string() - and buffer_get_int(). - """ - value = weechat.buffer_get_string(buffer, property) - return float(value) if value else 0.0 - - -def buffer_set_float(buffer, property, value): - """A variant of weechat.buffer_set() for floats. - - This variant is needed because WeeChat supports only integers and strings. - """ - weechat.buffer_set(buffer, property, str(value)) - - -def names_for_buffer(buffer): - """Returns a list of all names for the given buffer.""" - # The 'buffer' parameter passed to our callback is actually the buffer's ID - # (e.g. '0x2719cf0'). We have to check its name (e.g. 'freenode.#weechat') - # and short name (e.g. '#weechat') because these are what users specify in - # their configs. - buffer_names = [] - - full_name = weechat.buffer_get_string(buffer, 'name') - if full_name: - buffer_names.append(full_name) - - short_name = weechat.buffer_get_string(buffer, 'short_name') - if short_name: - buffer_names.append(short_name) - # Consider >channel and #channel to be equal buffer names. The reason - # is that the https://github.com/rawdigits/wee-slack plugin replaces - # '#' with '>' to indicate that someone in the buffer is typing. This - # fixes the behavior of several configuration options (e.g. - # 'notify_on_all_messages_in_buffers') when weechat_notify_send is used - # together with the wee_slack plugin. - # - # Note that this is only needed to be done for the short name. Indeed, - # the full name always stays unchanged. - if short_name.startswith('>'): - buffer_names.append('#' + short_name[1:]) - - return buffer_names - - -def notify_for_current_buffer(): - """Should we also send notifications for the current buffer?""" - return weechat.config_get_plugin('notify_for_current_buffer') == 'on' - - -def notify_on_highlights(): - """Should we send notifications on highlights?""" - return weechat.config_get_plugin('notify_on_highlights') == 'on' - - -def notify_on_private_messages(): - """Should we send notifications on private messages?""" - return weechat.config_get_plugin('notify_on_privmsgs') == 'on' - - -def notify_on_filtered_messages(): - """Should we also send notifications for filtered (hidden) messages?""" - return weechat.config_get_plugin('notify_on_filtered_messages') == 'on' - - -def notify_when_away(): - """Should we also send notifications when away?""" - return weechat.config_get_plugin('notify_when_away') == 'on' - - -def is_away(buffer): - """Is the user away?""" - return weechat.buffer_get_string(buffer, 'localvar_away') != '' - - -def is_private_message(buffer): - """Has a private message been sent?""" - return weechat.buffer_get_string(buffer, 'localvar_type') == 'private' - - -def i_am_author_of_message(buffer, nick): - """Am I (the current WeeChat user) the author of the message?""" - return weechat.buffer_get_string(buffer, 'localvar_nick') == nick - - -def split_option_value(option, separator=','): - """Splits the value of the given plugin option by the given separator and - returns the result in a list. - """ - values = weechat.config_get_plugin(option) - return [value.strip() for value in values.split(separator)] - - -def ignore_notifications_from_messages_tagged_with(tags): - """Should notifications be ignored for a message tagged with the given - tags? - """ - ignored_tags = split_option_value('ignore_messages_tagged_with') - for ignored_tag in ignored_tags: - for tag in tags: - if tag == ignored_tag: - return True - return False - - -def ignore_notifications_from_buffer(buffer): - """Should notifications from the given buffer be ignored?""" - buffer_names = names_for_buffer(buffer) - - for buffer_name in buffer_names: - if buffer_name and buffer_name in ignored_buffers(): - return True - - for buffer_name in buffer_names: - for prefix in ignored_buffer_prefixes(): - if prefix and buffer_name and buffer_name.startswith(prefix): - return True - - return False - - -def ignored_buffers(): - """A generator of buffers from which notifications should be ignored.""" - for buffer in split_option_value('ignore_buffers'): - yield buffer - - -def ignored_buffer_prefixes(): - """A generator of buffer prefixes from which notifications should be - ignored. - """ - for prefix in split_option_value('ignore_buffers_starting_with'): - yield prefix - - -def ignore_notifications_from_nick(nick): - """Should notifications from the given nick be ignored?""" - if nick in ignored_nicks(): - return True - - for prefix in ignored_nick_prefixes(): - if prefix and nick.startswith(prefix): - return True - - return False - - -def ignored_nicks(): - """A generator of nicks from which notifications should be ignored.""" - for nick in split_option_value('ignore_nicks'): - yield nick - - -def ignored_nick_prefixes(): - """A generator of nick prefixes from which notifications should be - ignored. - """ - for prefix in split_option_value('ignore_nicks_starting_with'): - yield prefix - - -def buffers_to_notify_on_all_messages(): - """A generator of buffer names in which the user wants to be notified for - all messages. - """ - for buffer in split_option_value('notify_on_all_messages_in_buffers'): - yield buffer - - -def notify_on_all_messages_in_buffer(buffer): - """Does the user want to be notified for all messages in the given buffer? - """ - buffer_names = names_for_buffer(buffer) - for buf in buffers_to_notify_on_all_messages(): - if buf in buffer_names: - return True - return False - - -def prepare_notification(buffer, is_highlight, nick, message): - """Prepares a notification from the given data.""" - if is_highlight: - source = (weechat.buffer_get_string(buffer, 'short_name') or - weechat.buffer_get_string(buffer, 'name')) - message = nick + nick_separator() + message - else: - # A private message. - source = nick - - max_length = int(weechat.config_get_plugin('max_length')) - if max_length > 0: - ellipsis = weechat.config_get_plugin('ellipsis') - message = shorten_message(message, max_length, ellipsis) - - if weechat.config_get_plugin('escape_html') == 'on': - message = escape_html(message) - - message = escape_slashes(message) - - icon = weechat.config_get_plugin('icon') - timeout = weechat.config_get_plugin('timeout') - urgency = weechat.config_get_plugin('urgency') - - return Notification(source, message, icon, timeout, urgency) - - -def nick_separator(): - """Returns a nick separator to be used.""" - separator = weechat.config_get_plugin('nick_separator') - return separator if separator else default_value_of('nick_separator') - - -def shorten_message(message, max_length, ellipsis): - """Shortens the message to at most max_length characters by using the given - ellipsis. - """ - # In Python 2, we need to decode the message and ellipsis into Unicode to - # correctly (1) detect their length and (2) shorten the message. Failing to - # do that could make the shortened message invalid and cause notify-send to - # fail. For example, when we have bytes, we cannot guarantee that we do not - # split the message inside of a multibyte character. - if sys.version_info.major == 2: - try: - message = message.decode('utf-8') - ellipsis = ellipsis.decode('utf-8') - except UnicodeDecodeError: - # Either (or both) of the two cannot be decoded. Continue in a - # best-effort manner. - pass - - message = shorten_unicode_message(message, max_length, ellipsis) - - if sys.version_info.major == 2: - if not isinstance(message, str): - message = message.encode('utf-8') - - return message - - -def shorten_unicode_message(message, max_length, ellipsis): - """An internal specialized version of shorten_message() when the both the - message and ellipsis are str (in Python 3) or unicode (in Python 2). - """ - if max_length <= 0 or len(message) <= max_length: - # Nothing to shorten. - return message - - if len(ellipsis) >= max_length: - # We cannot include any part of the message. - return ellipsis[:max_length] - - return message[:max_length - len(ellipsis)] + ellipsis - - -def escape_html(message): - """Escapes HTML characters in the given message.""" - # Only the following characters need to be escaped - # (https://wiki.ubuntu.com/NotificationDevelopmentGuidelines). - message = message.replace('&', '&') - message = message.replace('<', '<') - message = message.replace('>', '>') - return message - - -def escape_slashes(message): - """Escapes slashes in the given message.""" - # We need to escape backslashes to prevent notify-send from interpreting - # them, e.g. we do not want to print a newline when the message contains - # '\n'. - return message.replace('\\', r'\\') - - -def send_notification(notification): - """Sends the given notification to the user.""" - notify_cmd = ['notify-send', '--app-name', 'weechat'] - if notification.icon: - notify_cmd += ['--icon', notification.icon] - if notification.timeout: - notify_cmd += ['--expire-time', str(notification.timeout)] - if notification.urgency: - notify_cmd += ['--urgency', notification.urgency] - # We need to add '--' before the source and message to ensure that - # notify-send considers the remaining parameters as the source and the - # message. This prevents errors when a source or message starts with '--'. - notify_cmd += ['--', notification.source, notification.message] - - # Prevent notify-send from messing up the WeeChat screen when occasionally - # emitting assertion messages by redirecting the output to /dev/null (you - # would need to run /redraw to fix the screen). - # In Python < 3.3, there is no subprocess.DEVNULL, so we have to use a - # workaround. - with open(os.devnull, 'wb') as devnull: - subprocess.check_call( - notify_cmd, - stderr=subprocess.STDOUT, - stdout=devnull, - ) - - -if __name__ == '__main__': - # Registration. - weechat.register( - SCRIPT_NAME, - SCRIPT_AUTHOR, - SCRIPT_VERSION, - SCRIPT_LICENSE, - SCRIPT_DESC, - SCRIPT_SHUTDOWN_FUNC, - SCRIPT_CHARSET - ) - - # Initialization. - for option, (default_value, description) in OPTIONS.items(): - description = add_default_value_to(description, default_value) - weechat.config_set_desc_plugin(option, description) - if not weechat.config_is_set_plugin(option): - weechat.config_set_plugin(option, default_value) - - # Catch all messages on all buffers and strip colors from them before - # passing them into the callback. - weechat.hook_print('', '', '', 1, 'message_printed_callback', '')