Файловый менеджер - Редактировать - /var/www/html/byobu.zip
Ðазад
PK ! "��� � customnu ȯ�� #!/bin/sh -e # # custom: run the user's custom status scripts # # Copyright (C) 2009 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __custom_detail() { return } __custom() { local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/custom" local i= output= for i in "$BYOBU_CONFIG_DIR/bin/"[0-9]*_*; do # Loop over custom scripts # Ensure executable [ -x "$i" ] || continue # Ignore vim backup files ending in ~ case "$i" in *~) continue ;; esac local now="$(date +%s)" local script=${i##*/} local freq=${script%%_*} freq=${freq#0} local lastrun= [ -r "$cache.$script.last" ] && read lastrun < "$cache.$script.last" || lastrun=0 local expiration=$(($lastrun+$freq)) if [ $now -ge $expiration ]; then "$i" > "$cache.$script" 2>/dev/null printf "%s\n" "${now}" > "$cache.$script.last" fi readfile < "$cache.$script" local str="${_RET}" case "$str" in *"$ESC{"*) # User has formatted the colors output="$output$(printf "$str")" ;; *) # Default coloring output="$output$str " ;; esac done if [ -z "$output" ]; then rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/custom"* return fi printf "$output" | $BYOBU_SED ':a;N;$!ba;s/\n//g' } # vi: syntax=sh ts=4 noexpandtab PK ! �Q��9 9 timenu ȯ�� #!/bin/sh -e # # time: print the time in HH:MM:SS format # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. __time_detail() { date } __time() { local secs=1 [ -n "$TIME_SECONDS" ] && secs=$TIME_SECONDS case "$BYOBU_BACKEND" in screen) format="\0050c" [ "$secs" != "0" ] && format="$format:\005s" printf $format ;; esac } # vi: syntax=sh ts=4 noexpandtab PK ! �?t� wifi_qualitynu ȯ�� #!/bin/sh -e # # wifi_quality: display wifi signal quality # # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ___get_dev_list() { if [ -n "$MONITORED_NETWORK" ]; then echo "$MONITORED_NETWORK" else iw dev | grep Interface | cut -f2 -d\ fi } __wifi_quality_detail() { if eval $BYOBU_TEST iw >/dev/null 2>&1; then local dev for dev in $(___get_dev_list); do iw dev "$dev" info iw dev "$dev" link echo done elif eval $BYOBU_TEST iwconfig >/dev/null 2>&1; then iwconfig 2>/dev/null fi } __wifi_quality() { local out bitrate quality if eval $BYOBU_TEST iwconfig >/dev/null 2>&1; then # iwconfig is expected to output lines like: # Bit Rate=54 Mb/s Tx-Power=15 dBm # Link Quality=60/70 Signal level=-50 dBm # the awk below tokenizes the output and prints shell evalable results out=`iwconfig $MONITORED_NETWORK 2>/dev/null | awk '$0 ~ /[ ]*Link Quality./ { sub(/.*=/,"",$2); split($2,a,"/"); printf "quality=%.0f\n", 100*a[1]/a[2] }; $0 ~ /[ ]*Bit Rate/ { sub(/.*[:=]/,"",$2); printf("bitrate=%s\n", $2); } '` eval "$out" elif eval $BYOBU_TEST iw >/dev/null 2>&1; then local dev for dev in $(___get_dev_list); do # iw is expected to output lines like: # signal: -50 dBm # rx bitrate: 216.0 MBit/s MCS 13 40MHz # signal to quality: https://superuser.com/a/1360447 out=`iw dev "$dev" link 2>/dev/null | awk '$0 ~ /^\s*signal:/ { a = 100 * ($2 + 110) / 70; printf "quality=%.0f\n", (a > 100) ? 100 : ((a < 0) ? 0 : a); } $0 ~ /^\s*rx bitrate:/ { printf "bitrate=%s\n", $3; } '` eval "$out" [ -z "$bitrate" ] || [ -z "$quality" ] || break done fi [ -n "$bitrate" ] || bitrate=0 [ -n "$quality" ] || quality=0 if [ "$bitrate" -gt 0 ] && [ "$quality" -gt 0 ]; then printf "${ICON_WIFI}"; color b C k; printf "%s" "$bitrate"; color -; color C k; printf "%s" "$ICON_MBPS"; color -; color b C k; printf "%s" "$quality"; color -; color C k; printf "%s" "$PCT"; color -- else rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/wifi_quality"* fi } # vi: syntax=sh ts=4 noexpandtab PK ! s(�K� � include/mondriannu ȯ�� #!/bin/bash # N.B.: Use bash for $RANDOM # # mondrian: randomly generate some Modrian art in tmux # # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. trap "tput reset" EXIT HUP INT QUIT TERM KILL ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM # Special mode, argv[1]="color", paint the screen if [ "$1" = "color" ] && [ -n "$2" ]; then i=0 out= sleep 0.2 count=$(stty size | awk '{print $1*$2}') perl -e "print color 'reset'; printf \"\x1b[48;5;${2}m%${count}s\", \" \";"; head -n1 tmux kill-window -t mondrian exit 0 fi get_random_direction() { if [ $((RANDOM % 2)) -eq 0 ]; then echo "-v" else echo "-h" fi } get_random_numbers() { local max="$1" R=0 B=0 Y=0 R=$((RANDOM % max + 1)) B=$((RANDOM % max + 1)) Y=$((RANDOM % max + 1)) while [ "$B" = "$R" ] || [ "$B" = "$Y" ]; do B=$((RANDOM % max + 1)) done while [ "$Y" = "$R" ] || [ "$Y" = "$B" ]; do Y=$((RANDOM % max + 1)) done _RET="$R $B $Y" } red_color=196 yellow_color=226 blue_color=57 white_color=231 tmux kill-window -t mondrian tmux new-window -n mondrian "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ set-option -g pane-active-border-style bg=colour231 \; \ set-option -g pane-active-border-style fg=black \; \ set-option -g pane-border-style bg=colour231 \; \ set-option -g pane-border-style fg=black \; \ split-window $(get_random_direction) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 2)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 3)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 4)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $red_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 5)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 6)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $yellow_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 7)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 8)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $blue_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 9)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 9)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 10)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 11)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 12)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 13)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 14)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 15)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 16)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 17)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 18)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 19)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ split-window $(get_random_direction) -t $((RANDOM % 20)) "$BYOBU_PREFIX/lib/byobu/include/mondrian color $white_color" \; \ exit 0 PK ! ��<`& & include/constantsnu ȯ�� #!/bin/sh # # constants: some constant values needed by all library status scripts # # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. PKG="byobu" . "${BYOBU_PREFIX}/lib/${PKG}/include/icons" . "${BYOBU_PREFIX}/lib/${PKG}/include/colors" PCT="%" # Support two different backends (screen/tmux) if [ -z "$BYOBU_BACKEND" ]; then [ -r "/etc/byobu/backend" ] && . "/etc/byobu/backend" [ -r "$BYOBU_CONFIG_DIR/backend" ] && . "$BYOBU_CONFIG_DIR/backend" fi case "$BYOBU_BACKEND" in tmux) export BYOBU_BACKEND BYOBU_ARG_VERSION="-V" ESC= ;; screen) export BYOBU_BACKEND BYOBU_ARG_VERSION="-v" ESC="\005" ;; esac # MacOS Support eval $BYOBU_TEST gsed >/dev/null 2>&1 && export BYOBU_SED="gsed" || export BYOBU_SED="sed" eval $BYOBU_TEST greadlink >/dev/null 2>&1 && export BYOBU_READLINK="greadlink" || export BYOBU_READLINK="readlink" eval $BYOBU_TEST sensible-pager >/dev/null 2>&1 && export BYOBU_PAGER="sensible-pager" || export BYOBU_PAGER="less" eval $BYOBU_TEST sensible-editor >/dev/null 2>&1 && export BYOBU_EDITOR="sensible-editor" || export BYOBU_EDITOR="$EDITOR" eval $BYOBU_TEST "$BYOBU_EDITOR" >/dev/null 2>&1 || export BYOBU_EDITOR="vim" # Check sed's follow-symlinks feature $BYOBU_SED --follow-symlinks "s///" /dev/null 2>/dev/null && BYOBU_SED_INLINE="$BYOBU_SED -i --follow-symlinks" || BYOBU_SED_INLINE="$BYOBU_SED -i" # Determine if we have ulimit support eval $BYOBU_TEST ulimit >/dev/null 2>&1 && export BYOBU_ULIMIT="ulimit" || export BYOBU_ULIMIT="false" # Find a suitable python interpreter, if undefined if [ -z "$BYOBU_PYTHON" ]; then if python3 -c "import snack" >/dev/null 2>&1; then export BYOBU_PYTHON="python3" elif python2 -c "import snack" >/dev/null 2>&1; then export BYOBU_PYTHON="python2" elif python -c "import snack" >/dev/null 2>&1; then export BYOBU_PYTHON="python" fi fi export BYOBU_WINDOW_NAME="-" export BYOBU_DATE="%Y-%m-%d " export BYOBU_TIME="%H:%M:%S" PK ! ih=; ; * include/tmux-detach-all-but-current-clientnu ȯ�� #!/bin/sh # # tmux-detach-all-but-current-client # Copyright (C) 2013-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. a1= a2= tty1= tty2= # List all clients, ordered by most recent activity descending for c in $(tmux list-clients -F "#{client_activity}___#{client_tty}" | sort -n -r); do if [ -z "$a1" ]; then a1=${c%%___*} tty1=${c##*___} elif [ -z "$a2" ]; then a2=${c%%___*} tty2=${c##*___} fi if [ -n "$a1" ] && [ -n "$a2" ]; then if [ "$a1" = "$a2" ]; then # Activity timestamps match in top 2 attached clients # Let's not detach anyone here! tmux display-message "Multiple active attached clients detected, refusing to detach" >/dev/null 2>&1 elif [ -n "$tty1" ]; then # Detach all but the current client, iterating across each # Tempting to use detach-client -a -t here, but there's a bug # in there, keeping that from working properly tmux detach-client -t "$tty2" >/dev/null 2>&1 a2= fi fi done PK ! �m�B� � include/select-session.pynu ȯ�� #! /usr/bin/python3 # # select-session.py # Copyright (C) 2010 Canonical Ltd. # Copyright (C) 2012-2014 Dustin Kirkland <kirkland@byobu.org> # # Authors: Dustin Kirkland <kirkland@byobu.org> # Ryan C. Thompson <rct@thompsonclan.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import re import sys import subprocess try: # For Python3, try and import input from builtins from builtins import input except Exception: # But fall back to using the default input True PKG = "byobu" SHELL = os.getenv("SHELL", "/bin/bash") HOME = os.getenv("HOME") BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu") BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux") choice = -1 sessions = [] text = [] reuse_sessions = os.path.exists("%s/.reuse-session" % (BYOBU_CONFIG_DIR)) BYOBU_UPDATE_ENVVARS = ["DISPLAY", "DBUS_SESSION_BUS_ADDRESS", "SESSION_MANAGER", "GPG_AGENT_INFO", "XDG_SESSION_COOKIE", "XDG_SESSION_PATH", "GNOME_KEYRING_CONTROL", "GNOME_KEYRING_PID", "GPG_AGENT_INFO", "SSH_ASKPASS", "SSH_AUTH_SOCK", "SSH_AGENT_PID", "WINDOWID", "UPSTART_JOB", "UPSTART_EVENTS", "UPSTART_SESSION", "UPSTART_INSTANCE"] def get_sessions(): sessions = [] i = 0 output = False if BYOBU_BACKEND == "screen": try: output = subprocess.Popen(["screen", "-ls"], stdout=subprocess.PIPE).communicate()[0] except subprocess.CalledProcessError as cpe: # screen -ls seems to always return 1 if cpe.returncode != 1: raise else: output = cpe.output if sys.stdout.encoding is None: output = output.decode("UTF-8") else: output = output.decode(sys.stdout.encoding) if output: for s in output.splitlines(): s = re.sub(r'\s+', ' ', s) # Ignore hidden sessions (named sessions that start with a "." or a "_") if s and s != " " and (s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0 and s.count("._") == 0): text.append("screen: %s" % s.strip()) items = s.split(" ") sessions.append("screen____%s" % items[1]) i += 1 if BYOBU_BACKEND == "tmux": output = subprocess.Popen(["tmux", "list-sessions"], stdout=subprocess.PIPE).communicate()[0] if sys.stdout.encoding is None: output = output.decode("UTF-8") else: output = output.decode(sys.stdout.encoding) if output: for s in output.splitlines(): # Ignore hidden sessions (named sessions that start with a "_") if s and not s.startswith("_") and s.find("-") == -1: text.append("tmux: %s" % s.strip()) sessions.append("tmux____%s" % s.split(":")[0]) i += 1 return sessions def cull_zombies(session_name): # When using tmux session groups, closing a client will leave # unattached "zombie" sessions that will never be reattached. # Search for and kill any unattached hidden sessions in the same group if BYOBU_BACKEND == "tmux": output = subprocess.Popen(["tmux", "list-sessions"], stdout=subprocess.PIPE).communicate()[0] if sys.stdout.encoding is None: output = output.decode("UTF-8") else: output = output.decode(sys.stdout.encoding) if not output: return # Find the master session to extract the group name. We use # the group number to be extra sure the right session is getting # killed. We don't want to accidentally kill the wrong one pattern = "^%s:.+\\((group [^\\)]+)\\).*$" % session_name master = re.search(pattern, output, re.MULTILINE) if not master: return # Kill all the matching hidden & unattached sessions pattern = "^_%s-\\d+:.+\\(%s\\)$" % (session_name, master.group(1)) for s in re.findall(pattern, output, re.MULTILINE): subprocess.Popen(["tmux", "kill-session", "-t", s.split(":")[0]]) def update_environment(session): backend, session_name = session.split("____", 2) for var in BYOBU_UPDATE_ENVVARS: value = os.getenv(var) if value: if backend == "tmux": cmd = ["tmux", "setenv", "-t", session_name, var, value] else: cmd = ["screen", "-S", session_name, "-X", "setenv", var, value] subprocess.call(cmd, stdout=open(os.devnull, "w")) def attach_session(session): update_environment(session) backend, session_name = session.split("____", 2) cull_zombies(session_name) # must use the binary, not the wrapper! if backend == "tmux": if reuse_sessions: os.execvp("tmux", ["tmux", "-u", "new-session", "-t", session_name, ";", "set-option", "destroy-unattached"]) else: os.execvp("tmux", ["tmux", "-u", "attach", "-t", session_name]) else: os.execvp("screen", ["screen", "-AOxRR", session_name]) sessions = get_sessions() show_shell = os.path.exists("%s/.always-select" % (BYOBU_CONFIG_DIR)) if len(sessions) > 1 or show_shell: sessions.append("NEW") text.append("Create a new Byobu session (%s)" % BYOBU_BACKEND) sessions.append("SHELL") text.append("Run a shell without Byobu (%s)" % SHELL) if len(sessions) > 1: sys.stdout.write("\nByobu sessions...\n\n") tries = 0 while tries < 3: i = 1 for s in text: sys.stdout.write(" %d. %s\n" % (i, s)) i += 1 try: try: user_input = input("\nChoose 1-%d [1]: " % (i - 1)) except Exception: user_input = "" if not user_input or user_input == "": choice = 1 break try: choice = int(user_input) except Exception: choice = int(eval(user_input)) if choice >= 1 and choice < i: break else: tries += 1 choice = -1 sys.stderr.write("\nERROR: Invalid input\n") except KeyboardInterrupt: sys.stdout.write("\n") sys.exit(0) except Exception: if choice == "" or choice == -1: choice = 1 break tries += 1 choice = -1 sys.stderr.write("\nERROR: Invalid input\n") elif len(sessions) == 1: # Auto-select the only session choice = 1 if choice >= 1: if sessions[choice - 1] == "NEW": # Create a new session if BYOBU_BACKEND == "tmux": os.execvp("byobu", ["byobu", "new-session", SHELL]) else: os.execvp("byobu", ["byobu", SHELL]) elif sessions[choice - 1] == "SHELL": os.execvp(SHELL, [SHELL]) else: # Attach to the chosen session; must use the binary, not the wrapper! attach_session(sessions[choice - 1]) # No valid selection, default to the youngest session, create if necessary if BYOBU_BACKEND == "tmux": os.execvp("tmux", ["tmux"]) else: os.execvp("screen", ["screen", "-AOxRR"]) PK ! }�n�Q Q include/dirsnu ȯ�� #!/bin/sh # # dirs: some dirs needed by all library status scripts # # Copyright (C) 2011-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. PKG="byobu" # Some users build and install byobu themselves, rather than from a distro [ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" [ -n "$BYOBU_PREFIX" ] || BYOBU_PREFIX="/usr" # Create and export the user configuration directory if [ -d "$BYOBU_CONFIG_DIR" ]; then export BYOBU_CONFIG_DIR="$BYOBU_CONFIG_DIR" elif [ -d "$XDG_CONFIG_HOME" ]; then # Use XDG, as some users insist on such nonsense :-) export BYOBU_CONFIG_DIR="$XDG_CONFIG_HOME/$PKG" elif [ -d "$HOME/.config/$PKG" ]; then # Use XDG config directory, if it exists export BYOBU_CONFIG_DIR="$HOME/.config/$PKG" elif [ -d "$HOME/.local/share/$PKG" ]; then # Use XDG local directory, if it exists export BYOBU_CONFIG_DIR="$HOME/.local/share/$PKG" else # And to default to good old classic config dir location! export BYOBU_CONFIG_DIR="$HOME/.$PKG" fi [ -d "$BYOBU_CONFIG_DIR" ] || mkdir -p "$BYOBU_CONFIG_DIR/bin" # Grab the global, then local socket directory [ -r "/etc/$PKG/socketdir" ] && . "/etc/$PKG/socketdir" [ -r "$BYOBU_CONFIG_DIR/socketdir" ] && . "$BYOBU_CONFIG_DIR/socketdir" # Create and export the runtime cache directory if [ -w /dev/shm ]; then # Use shm for performance, if possible for i in /dev/shm/$PKG-$USER-*; do if [ -d "$i" ] && [ -O "$i" ]; then export BYOBU_RUN_DIR="$i" break fi done # Still empty, make a new one if [ ! -d "$BYOBU_RUN_DIR" ] || [ ! -O "$BYOBU_RUN_DIR" ]; then export BYOBU_RUN_DIR=$(mktemp -d /dev/shm/$PKG-$USER-XXXXXXXX) fi fi if [ ! -d "$BYOBU_RUN_DIR" ] || [ ! -O "$BYOBU_RUN_DIR" ] || [ ! -w "$BYOBU_RUN_DIR" ]; then # For distros that don't have a /dev/shm, use local disk if [ -d "$XDG_CACHE_HOME" ]; then # Use XDG, as some users insist on such nonsense :-) export BYOBU_RUN_DIR="$XDG_CACHE_HOME/$PKG" else # But if not, we'll use a cache directory export BYOBU_RUN_DIR="$HOME/.cache/$PKG" fi fi PK ! �q q ( include/tmux-send-command-to-all-windowsnu ȯ�� #!/bin/sh # # tmux-send-command-to-all-windows # Copyright (C) 2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. for w in $(tmux list-windows | $BYOBU_SED -e "s/:.*//"); do tmux send-keys -t :$w "$@" tmux send-keys -t :$w Enter done PK ! 6�6��) �) include/config.pynu ȯ�� #! /usr/bin/python3 # # config.py # Copyright (C) 2008 Canonical Ltd. # Copyright (C) 2008-2014 Dustin Kirkland <kirkland@byobu.org> # # Authors: Nick Barcet <nick.barcet@ubuntu.com> # Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # If you change any strings, please generate localization information with: # ./debian/rules get-po from __future__ import print_function import sys import os import os.path import time import string import subprocess import gettext import glob def error(msg): print("ERROR: %s" % msg) sys.exit(1) try: import snack from snack import * except Exception: error("Could not import the python snack module") PKG = "byobu" HOME = os.getenv("HOME") USER = os.getenv("USER") BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu") BYOBU_RUN_DIR = os.getenv("BYOBU_RUN_DIR", HOME + "/.cache/byobu") BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux") BYOBU_SOCKETDIR = os.getenv("SOCKETDIR", "/var/run/screen") BYOBU_PREFIX = os.getenv("BYOBU_PREFIX", "/usr") SHARE = BYOBU_PREFIX + '/share/' + PKG DOC = BYOBU_PREFIX + '/share/doc/' + PKG if not os.path.exists(SHARE): SHARE = BYOBU_CONFIG_DIR + "/" + SHARE if not os.path.exists(DOC): DOC = BYOBU_PREFIX + '/share/doc/packages/' + PKG if not os.path.exists(DOC): DOC = BYOBU_CONFIG_DIR + "/" + DOC DEF_ESC = "A" RELOAD = "If you are using the default set of keybindings, press\n<F5> or <ctrl-a-R> to activate these changes.\n\nOtherwise, exit this session and start a new one." RELOAD_FLAG = "%s/reload-required" % (BYOBU_RUN_DIR) ESC = '' snack.hotkeys[ESC] = ord(ESC) snack.hotkeys[ord(ESC)] = ESC gettext.bindtextdomain(PKG, SHARE + '/po') gettext.textdomain(PKG) _ = gettext.gettext def ioctl_GWINSZ(fd): # Discover terminal width try: import fcntl import termios import struct import os cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) except Exception: return None return cr def reload_required(): try: if not os.path.exists(BYOBU_CONFIG_DIR): # 493 (decimal) is 0755 (octal) # Use decimal for portability across all python versions os.makedirs(BYOBU_CONFIG_DIR, 493) f = open(RELOAD_FLAG, 'w') f.close() if BYOBU_BACKEND == "screen": subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR]) except Exception: True def terminal_size(): # decide on some terminal size cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) # try open fds if not cr: # ...then ctty try: fd = os.open(os.ctermid(), os.O_RDONLY) cr = ioctl_GWINSZ(fd) os.close(fd) except Exception: pass if not cr: # env vars or finally defaults try: cr = (env['LINES'], env['COLUMNS']) except Exception: cr = (25, 80) # reverse rows, cols return int(cr[1] - 5), int(cr[0] - 5) def menu(snackScreen, size, isInstalled): if isInstalled: installtext = _("Byobu currently launches at login (toggle off)") else: installtext = _("Byobu currently does not launch at login (toggle on)") li = Listbox(height=6, width=60, returnExit=1) li.append(_("Help -- Quick Start Guide"), 1) li.append(_("Toggle status notifications"), 2) li.append(_("Change escape sequence"), 3) li.append(installtext, 4) bb = ButtonBar(snackScreen, (("Exit", "exit", ESC),), compact=1) g = GridForm(snackScreen, _(" Byobu Configuration Menu"), 1, 2) g.add(li, 0, 0, padding=(4, 2, 4, 2)) g.add(bb, 0, 1, padding=(1, 1, 0, 0)) if bb.buttonPressed(g.runOnce()) == "exit": return 0 else: return li.current() def messagebox(snackScreen, width, height, title, text, scroll=0, buttons=((_("Okay"), "okay"), (_("Cancel"), "cancel", ESC))): t = Textbox(width, height, text, scroll=scroll) bb = ButtonBar(snackScreen, buttons, compact=1) g = GridForm(snackScreen, title, 1, 2) g.add(t, 0, 0, padding=(0, 0, 0, 0)) g.add(bb, 0, 1, padding=(1, 1, 0, 0)) return bb.buttonPressed(g.runOnce()) def help(snackScreen, size): f = open(DOC + '/help.' + BYOBU_BACKEND + '.txt') text = f.read() f.close() text = text.replace("<esckey>", getesckey(), 1) t = Textbox(67, 16, text, scroll=1, wrap=1) bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1) g = GridForm(snackScreen, _("Byobu Help"), 2, 4) g.add(t, 1, 0) g.add(bb, 1, 1, padding=(1, 1, 0, 0)) button = bb.buttonPressed(g.runOnce()) return 100 def readstatus(): status = {} glo = {} loc = {} for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']: if os.path.exists(f): try: exec(open(f).read(), glo, loc) except Exception: error("Invalid configuration [%s]" % f) if BYOBU_BACKEND == "tmux": items = "%s %s" % (loc["tmux_left"], loc["tmux_right"]) else: items = "%s %s %s %s" % (loc["screen_upper_left"], loc["screen_upper_right"], loc["screen_lower_left"], loc["screen_lower_right"]) for i in items.split(): if i.startswith("#"): i = i.replace("#", "") status[i] = "0" else: status[i] = "1" li = [] keys = list(status.keys()) for i in sorted(keys): window = [int(status[i]), i] li.append(window) return li def genstatusstring(s, status): new = "" glo = {} loc = {} exec(open(SHARE + '/status/status').read(), glo, loc) for i in loc[s].split(): if i.startswith("#"): i = i.replace("#", "") if status[i] == 1: new += " " + i else: new += " #" + i return new def writestatus(items): status = {} path = BYOBU_CONFIG_DIR + '/status' for i in items: status[i[1]] = i[0] for key in ["tmux_left", "tmux_right", "screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]: if key.startswith(BYOBU_BACKEND): try: f = open(path, "r") except Exception: f = open(SHARE + '/status/status', "r") lines = f.readlines() f.close() try: f = open(path, "w") except Exception: f = open(path, "a+") for l in lines: if l.startswith("%s=" % key): val = genstatusstring(key, status) f.write("%s=\"%s\"\n" % (key, val)) else: f.write(l) f.close def togglestatus(snackScreen, size): itemlist = readstatus() rl = Label("") r = CheckboxTree(12, scroll=1) count = 0 for item in itemlist: if item[0] != -1: r.append(item[1], count, selected=item[0]) count = count + 1 bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1) g = GridForm(snackScreen, _("Toggle status notifications"), 2, 4) g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4, 0, 0, 1)) g.add(r, 1, 0) g.add(bb, 1, 1, padding=(4, 1, 0, 0)) if bb.buttonPressed(g.runOnce()) != "cancel": count = 0 for item in itemlist: if item[0] != -1: item[0] = r.getEntryValue(count)[1] count = count + 1 writestatus(itemlist) reload_required() return 100 def install(snackScreen, size, isInstalled): out = "" if isInstalled: if subprocess.call(["byobu-launcher-uninstall"]) == 0: out = _("Byobu will not be launched next time you login.") button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), ))) return 101 else: if subprocess.call(["byobu-launcher-install"]) == 0: out = _("Byobu will be launched automatically next time you login.") button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), ))) return 100 def appendtofile(p, s): f = open(p, 'a') try: f.write(s) except IOError: f.close() return f.close() return def getesckey(): line = "" if BYOBU_BACKEND == "tmux": path = BYOBU_CONFIG_DIR + '/keybindings.tmux' if os.path.exists(path): for l in open(path): if l.startswith("set -g prefix "): line = l else: return DEF_ESC else: path = BYOBU_CONFIG_DIR + '/keybindings' if os.path.exists(path): for l in open(path): if l.startswith("escape "): line = l else: return DEF_ESC if line == "": return DEF_ESC esc = line[line.find('^') + 1] if esc == "`": esc = " " return esc def setesckey(key): if key.isalpha(): # throw away outputs in order that the view isn't broken nullf = open(os.devnull, "w") subprocess.call(["byobu-ctrl-a", "screen", key], stdout=nullf) nullf.close() def chgesc(snackScreen, size): esc = Entry(2, text=getesckey(), returnExit=1) escl = Label(_("Escape key: ctrl-")) bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1) g = GridForm(snackScreen, _("Change escape sequence"), 2, 4) g.add(escl, 0, 0, anchorLeft=1, padding=(1, 0, 0, 1)) g.add(esc, 1, 0, anchorLeft=1) g.add(bb, 1, 1) g.setTimer(100) loop = 1 while loop: which = g.run() if which == "TIMER": val = esc.value() if len(val) > 1: esc.set(val[1]) # Ensure that escape sequence is not \ or / if val == '/' or val == '\\': esc.set(DEF_ESC) # Ensure that the escape sequence is not set to a number try: dummy = int(esc.value()) esc.set(DEF_ESC) except Exception: # do nothing dummy = "foo" else: loop = 0 snackScreen.popWindow() button = bb.buttonPressed(which) if button != "cancel": setesckey(esc.value()) reload_required() if button == "exit": return 0 return 100 def autolaunch(): if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"): return 0 try: for line in open("%s/.profile" % HOME): if "byobu-launch" in line: return 1 except Exception: return 0 if os.path.exists("/etc/profile.d/Z97-%s.sh" % PKG): return 1 return 0 def main(): """This is the main loop of our utility""" size = terminal_size() snackScreen = SnackScreen() snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu')) snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits')) isInstalled = autolaunch() tag = 100 while tag > 0: tag = menu(snackScreen, size, isInstalled) if tag == 1: tag = help(snackScreen, size) elif tag == 2: tag = togglestatus(snackScreen, size) elif tag == 3: tag = chgesc(snackScreen, size) elif tag == 4: tag = install(snackScreen, size, isInstalled) isInstalled = autolaunch() snackScreen.finish() sys.exit(0) if __name__ == "__main__": main() PK ! ���� � include/toggle-utf8nu ȯ�� #!/bin/sh -e # # toggle-utf8 # Copyright (C) 2013-2014 Dustin Kirkland # # Authors: Dustin Kirkland <kirkland@byobu.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. PKG="byobu" [ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" [ -r "$BYOBU_CONFIG_DIR/statusrc" ] && . "$BYOBU_CONFIG_DIR/statusrc" if [ "$BYOBU_CHARMAP" = "UTF-8" ]; then if grep -qs "^BYOBU_CHARMAP=" $BYOBU_CONFIG_DIR/statusrc 2>/dev/null; then sed -i -e "s/^BYOBU_CHARMAP=.*/BYOBU_CHARMAP=x/" $BYOBU_CONFIG_DIR/statusrc else echo "BYOBU_CHARMAP=x" >> $BYOBU_CONFIG_DIR/statusrc fi export BYOBU_CHARMAP=x else if grep -qs "^BYOBU_CHARMAP=" $BYOBU_CONFIG_DIR/statusrc 2>/dev/null; then sed -i -e "s/^BYOBU_CHARMAP=.*/BYOBU_CHARMAP=UTF-8/" $BYOBU_CONFIG_DIR/statusrc else echo "BYOBU_CHARMAP=UTF-8" >> $BYOBU_CONFIG_DIR/statusrc fi export BYOBU_CHARMAP=UTF-8 fi if [ -n "$TMUX" ]; then RC_FILE=$(echo "$SHELL" | $BYOBU_SED "s:.*/::") tmux send-keys " export BYOBU_CHARMAP=$BYOBU_CHARMAP ; . ~/.${RC_FILE}rc" \; send-keys Enter fi # vi: syntax=sh ts=4 noexpandtab PK ! ��� � 2 include/__pycache__/select-session.cpython-310.pycnu �[��� o &�J^� � @ s> d dl Z d dlZd dlZd dlZzd dlmZ W n ey! Y nw dZe �dd�Z e �d�Z e �de d �Ze �d d �ZdZ g Zg Ze j�de �Zg d �Zdd� Zdd� Zdd� Zdd� Ze� Ze j�de �Zee�dksrer�e�d� e�de � e�d� e�de � ee�dk�r?ej�d� d Zedk �r>dZeD ]Zej�deef � ed7 Zq�zNz eded �Z W n ey� dZ Y nw e r�e dkr�dZ W njze!e �Z W n ey� e!e"e ��Z Y nw e dkr�e ek r�W nJed7 ZdZ ej#�d � W n8 e$�y ej�d!� e�%d � Y n$ e�y9 e dk�s'e dk�r+dZ Y ned7 ZdZ ej#�d � Y nw edk s�n ee�dk�rHdZ e dk�r�ee d dk�rned k�ree �&ddd"e g� n"e �&dde g� nee d dk�re �&e e g� neee d � ed k�r�e �&d d g� dS e �&d#d#d$g� dS )%� N)�input�byobu�SHELLz /bin/bash�HOME�BYOBU_CONFIG_DIRz/.byobu� BYOBU_BACKEND�tmux���z%s/.reuse-session)�DISPLAY�DBUS_SESSION_BUS_ADDRESS�SESSION_MANAGER�GPG_AGENT_INFO�XDG_SESSION_COOKIE�XDG_SESSION_PATH�GNOME_KEYRING_CONTROL�GNOME_KEYRING_PIDr �SSH_ASKPASS� SSH_AUTH_SOCK� SSH_AGENT_PID�WINDOWID�UPSTART_JOB�UPSTART_EVENTS�UPSTART_SESSION�UPSTART_INSTANCEc C s� g } d}d}t dkr�ztjddgtjd��� d }W n tjy6 } z|jdkr)� |j}W Y d }~nd }~ww tj j d u rC|�d�}n|�tj j �}|r�|�� D ]E}t �dd |�}|r�|d kr�|�d �dkr�t|�dkr�|�d �dkr�|�d�dkr�t�d|�� � |�d �}| �d |d � |d7 }qPt dkr�tjddgtjd��� d }tj j d u r�|�d�}n|�tj j �}|r�|�� D ])}|r�|�d�s�|�d�dkr�t�d|�� � | �d|�d�d � |d7 }q�| S )Nr F�screenz-ls��stdout� �UTF-8z\s+� z..z._z screen: %szscreen____%sr � list-sessions�_�-r ztmux: %sz tmux____%s�:)r � subprocess�Popen�PIPE�communicate�CalledProcessError� returncode�output�sysr �encoding�decode� splitlines�re�sub�find�len�count�text�append�strip�split� startswith)�sessions�ir* �cpe�s�items� r>