From 064184881a48ac88f63af0723313f09ce7c38d24 Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 3 Feb 2018 00:34:17 -0600 Subject: [PATCH] Initial commit - transitioning from dotfiles --- .bashrc-global | 27 ++ .directory | 2 + bashrc.sh | 84 ++++++ bashrc.sh.bak | 138 +++++++++ bootstrap/replicate.sh | 6 + layout/tungsten.sh | 2 + mklatex | 39 +++ mpc/mpc-i3-consume | 6 + mpc/mpc-i3-playlists | 17 ++ mpc/mpc-i3-repeat | 6 + mpc/mpc-i3-shuffle | 6 + mpv-xwinwrap | 112 +++++++ powerline-shell.py | 650 ++++++++++++++++++++++++++++++++++++++++ tde.bin | Bin 0 -> 5582 bytes test/test-colors | 48 +++ test/test-notifications | 5 + wal-set | 42 +++ xephrice | 35 +++ xrdbupdate | 2 + 19 files changed, 1227 insertions(+) create mode 100644 .bashrc-global create mode 100644 .directory create mode 100755 bashrc.sh create mode 100755 bashrc.sh.bak create mode 100755 bootstrap/replicate.sh create mode 100755 layout/tungsten.sh create mode 100755 mklatex create mode 100755 mpc/mpc-i3-consume create mode 100755 mpc/mpc-i3-playlists create mode 100755 mpc/mpc-i3-repeat create mode 100755 mpc/mpc-i3-shuffle create mode 100755 mpv-xwinwrap create mode 100755 powerline-shell.py create mode 100644 tde.bin create mode 100755 test/test-colors create mode 100755 test/test-notifications create mode 100755 wal-set create mode 100755 xephrice create mode 100755 xrdbupdate diff --git a/.bashrc-global b/.bashrc-global new file mode 100644 index 0000000..95c2593 --- /dev/null +++ b/.bashrc-global @@ -0,0 +1,27 @@ +#!/bin/bash +# +# ~/.bashrc +# + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# Sometimes you can't change your shell. Sometimes you have to implement hacky +# workarounds +if [ -f ~/.bash-to-zsh ]; then + export SHELL=$(which zsh) + exec zsh +fi + +# Source /etc/profile +source /etc/profile + +# Source .profile +if [ -f ~/.profile ]; then + source ~/.profile +fi + +# Source the bash-specific rc +if [ -f ~/.bin/bashrc.sh ]; then + source ~/.bin/bashrc.sh +fi diff --git a/.directory b/.directory new file mode 100644 index 0000000..aa092a8 --- /dev/null +++ b/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=folder-script diff --git a/bashrc.sh b/bashrc.sh new file mode 100755 index 0000000..3f0b78e --- /dev/null +++ b/bashrc.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +PROMPT_COMMAND="__prompt_command; $PROMPT_COMMAND" + +__prompt_command() { + PS1="$(powerline-shell.py --cwd-mode fancy --cwd-max-depth 3 --cwd-max-dir-size 16 --mode patched $? 2> /dev/null)" +} + +# Command to be called every time PS1 is composed +# PROMPT_COMMAND makes this process very easy, it turns out +__prompt_command_old() { + local EXIT="$?" + PS1="\[\e[m\]" + + # Determine which separator we should use + # Namely, don't use the Powerline separator if we know we're in a tty + + local SEPARATOR="" + if [[ "$(tty)" == *"tty"* ]]; then + SEPARATOR=" " + else + SEPARATOR="" + fi + + # Generate the name color based on remote connection and root statuses + if [ "$(id -u)" == "0" ]; then + # We're root, gimme the flashy red prompt + PS1+="\[\e[37;41m\]" + else + # Generate a background based on remote status + if [ -z "${SSH_TTY+x}" ]; then + #Light Grey on Light Blue (BG) + PS1+="\[\e[104m\]" + else + #Light Grey on Magenta (BG) + PS1+="\[\e[45m\]" + fi + # Generate a foreground based on whether or not we're in sudoers or wheel or whatever + # Unfortunately, there's no way for us to *really* check if we can sudo or not + local admgroups=( "wheel" "root" "sudo" ) + PS1+="\[\e[30m\]" + for usergroup in $(groups); do + for admgroup in $admgroups; do + if [ "$usergroup" == "$admgroup" ]; then + PS1+="\[\e[39m\]" + fi + done + done + #if [[ $USERGROUPS == *"wheel"* ]] || [[ $USERGROUPS == *"root"* ]] || [[ $USERGROUPS == *"sudo"* ]]; #then + # PS1+="\[\e[37m\]" + #else + # PS1+="\[\e[30m\]" + #fi + fi + + # Generate a name based on the remote connection and username + PS1+=" " + if [ -z "${SSH_TTY+x}" ]; then + PS1+="$USER" + else + if [ "$USER" != "salt" ]; then + PS1+="$USER@" + fi + PS1+="$HOSTNAME" + fi + + # Transition to PWD + PS1+=" \[\e[7;90m\]$SEPARATOR\[\e[m\e[100m\]" + + # Generate the PWD + PS1+="${PWD/#$HOME/'~'}" + + # Append a neat little arrow suffix + if [ $EXIT == 0 ]; then + #32: Green + PS1+="\[\e[7;32m\]$SEPARATOR\[\e[m\e[32m\]$SEPARATOR" + else + #31: Red + PS1+="\[\e[7;31m\]$SEPARATOR\[\e[0;39;41m\]$EXIT\[\e[m\e[31m\]$SEPARATOR" + fi + + # Cleanup + PS1+="\[\e[m\] " +} diff --git a/bashrc.sh.bak b/bashrc.sh.bak new file mode 100755 index 0000000..66a4f93 --- /dev/null +++ b/bashrc.sh.bak @@ -0,0 +1,138 @@ +#!/bin/bash + +# Setting up defaults just to be on the safe side +PROMPT_COMMAND="__prompt_command; $PROMPT_COMMAND" + +__prompt_command() { + PS1="$(powerline-shell.py --cwd-mode fancy --cwd-max-depth 3 --cwd-max-dir-size 16 --mode patched $? 2> /dev/null)" +} + +# Command to be called every time PS1 is composed +# PROMPT_COMMAND makes this process very easy, it turns out +__prompt_command_old() { + local EXIT="$?" + PS1="\[\e[m\]" + + # Determine which separator we should use + # Namely, don't use the Powerline separator if we know we're in a tty + + local SEPARATOR="" + if [[ "$(tty)" == *"tty"* ]]; then + SEPARATOR=" " + else + SEPARATOR="" + fi + + # Generate the name color based on remote connection and root statuses + if [ "$(id -u)" == "0" ]; then + # We're root, gimme the flashy red prompt + PS1+="\[\e[37;41m\]" + else + # Generate a background based on remote status + if [ -z ${SSH_TTY+x} ]; then + #Light Grey on Light Blue (BG) + PS1+="\[\e[104m\]" + else + #Light Grey on Magenta (BG) + PS1+="\[\e[45m\]" + fi + # Generate a foreground based on whether or not we're in sudoers or wheel or whatever + # Unfortunately, there's no way for us to *really* check if we can sudo or not + local usergroups=($(groups)) + local admgroups=( "wheel" "root" "sudo" ) + PS1+="\[\e[30m\]" + for usergroup in $usergroups; do + for admgroup in $admgroups; do + if [ $usergroup == $admgroup ]; then + PS1+="\[\e[39m\]" + fi + done + done + #if [[ $USERGROUPS == *"wheel"* ]] || [[ $USERGROUPS == *"root"* ]] || [[ $USERGROUPS == *"sudo"* ]]; #then + # PS1+="\[\e[37m\]" + #else + # PS1+="\[\e[30m\]" + #fi + fi + + # Generate a name based on the remote connection and username + PS1+=" " + if [ -z ${SSH_TTY+x} ]; then + PS1+="$USER" + else + if [ "$USER" != "salt" ]; then + PS1+="$USER@" + fi + PS1+="$HOSTNAME" + fi + + # Transition to PWD + PS1+=" \[\e[7;90m\]$SEPARATOR\[\e[m\e[100m\]" + + # Generate the PWD + PS1+="${PWD/#$HOME/'~'}" + + # Append a neat little arrow suffix + if [ $EXIT == 0 ]; then + #32: Green + PS1+="\[\e[7;32m\]$SEPARATOR\[\e[m\e[32m\]$SEPARATOR" + else + #31: Red + PS1+="\[\e[7;31m\]$SEPARATOR\[\e[0;39;41m\]$EXIT\[\e[m\e[31m\]$SEPARATOR" + fi + + # Cleanup + PS1+="\[\e[m\] " +} + +# Common miscellaneous aliases are all defined here for convenience +__define_aliases() { + + # Common Aliases + + alias cp='cp -i' + alias dd=dcfldd + alias ls='ls --color=auto' + alias ll='ls -alF' + alias la='ls -a --color=auto' + alias l='ls -CF' + alias waitwhat='echo $?' + + # Simple history thing + + alias fug='sudo $(history -p !!)' +} + +# Functions to be exported to the shell +# Mostly just helper wrappers and such +__define_functions() { + # Arch-only helper functions + if [[ "$(ls /etc/*release)" == *"arch"* ]]; then + pac_helper="pacaur" + local helpers=( "pacaur" "yaourt" "pacman" ) + for helper in $helpers; do + if [ $(pacman -Qq $helper > /dev/null) ]; then + pac_helper="$helper" + break + fi + done + + alias pac="$pac_helper" + alias pacq="$pac_helper -Qs" + alias pacqi="$pac_helper -Qi" + alias pacs="$pac_helper -S" + alias pacss="$pac_helper -Ss" + alias pacsu="$pac_helper -Syu" + alias pacsyu="$pac_helper -Syyu" + alias pacsr="$pac_helper -Rsnu" + fi +} + +# Call functions that need to be called +__define_aliases +__define_functions + +EDITOR=$(which vim) +PATH=$PATH:~/.bin +export EDITOR +export PATH diff --git a/bootstrap/replicate.sh b/bootstrap/replicate.sh new file mode 100755 index 0000000..c86211c --- /dev/null +++ b/bootstrap/replicate.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +tempfolder="/tmp/dots$(uuidgen)" +git clone --recursive --separate-git-dir="$HOME/.dotfiles" https://github.com/rehashedsalt/home.git $tempfolder +rsync -rvl --exclude ".git" $tempfolder/ $HOME/ +rm -r $tempfolder +git submodule update --init --recursive --git-dir="$HOME/.dotfiles" --work-tree="$HOME" $HOME/ diff --git a/layout/tungsten.sh b/layout/tungsten.sh new file mode 100755 index 0000000..627029a --- /dev/null +++ b/layout/tungsten.sh @@ -0,0 +1,2 @@ +#!/bin/sh +xrandr --output HDMI-0 --mode 1920x1080 --pos 0x360 --rotate normal --output DisplayPort-0 --primary --mode 2560x1440 --rate 143.86 --pos 1920x0 --rotate normal diff --git a/mklatex b/mklatex new file mode 100755 index 0000000..3303dd1 --- /dev/null +++ b/mklatex @@ -0,0 +1,39 @@ +#!/bin/bash + +# Copyright (c) 2017 rehashedsalt/vintagesalt +# +# 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. + +if [ -z "$@" ]; then + printf "mklatex: no files specified\n" + exit 1 +fi +for sourcefile in "$@"; do + if [ ! -f "$sourcefile" ]; then + printf "mklatex: file not found: $sourcefile\n" + else + pdflatex $sourcefile + fi +done +if [ "$(which llpp)" ]; then + killall -SIGHUP llpp +fi +if [ "$(which mupdf)" ]; then + killall -SIGHUP mupdf +fi diff --git a/mpc/mpc-i3-consume b/mpc/mpc-i3-consume new file mode 100755 index 0000000..a7695ce --- /dev/null +++ b/mpc/mpc-i3-consume @@ -0,0 +1,6 @@ +#!/bin/bash +if [[ "$(mpc consume)" == *"consume: on"* ]]; then + notify-send -a "Mopidy" -u low -t 1 "Consume On" "Songs will be removed from the playlist after completion" +else + notify-send -a "Mopidy" -u low -t 1 "Consume Off" "Songs will remain in the playlist after completion" +fi diff --git a/mpc/mpc-i3-playlists b/mpc/mpc-i3-playlists new file mode 100755 index 0000000..b51eecb --- /dev/null +++ b/mpc/mpc-i3-playlists @@ -0,0 +1,17 @@ +#!/bin/bash +MESSAGE='-mesg Append:' +if [ "$1" = "--clear" ]; then + MESSAGE='-mesg Replace:' +fi +PLAYLIST="$(mpc lsplaylists | rofi -lines 10 -dmenu -p 'Play MPD Playlist: ' $MESSAGE)" +if [ "$PLAYLIST" = "" ]; then + exit +fi +if [ "$1" = "--clear" ]; then + mpc clear +fi +mpc load $PLAYLIST +if [[ "$(mpc)" != *"playing"* ]]; then + mpc play +fi +notify-send -u low -t 5 -a 'Mopidy' "$PLAYLIST" "Beginning playback of playlist $PLAYLIST" diff --git a/mpc/mpc-i3-repeat b/mpc/mpc-i3-repeat new file mode 100755 index 0000000..cb9af66 --- /dev/null +++ b/mpc/mpc-i3-repeat @@ -0,0 +1,6 @@ +#!/bin/bash +if [[ "$(mpc repeat)" == *"repeat: on"* ]]; then + notify-send -a "Mopidy" -u low -t 1 "Repeat On" "The playlist will be repeated after it is completed" +else + notify-send -a "Mopidy" -u low -t 1 "Repeat Off" "Playback will stop at the end of the playlist" +fi diff --git a/mpc/mpc-i3-shuffle b/mpc/mpc-i3-shuffle new file mode 100755 index 0000000..68a4f50 --- /dev/null +++ b/mpc/mpc-i3-shuffle @@ -0,0 +1,6 @@ +#!/bin/bash +if [[ "$(mpc random)" == *"random: on"* ]]; then + notify-send -a "Mopidy" -u low -t 1 "Shuffle On" "Songs will be played in random order" +else + notify-send -a "Mopidy" -u low -t 1 "Shuffle Off" "Songs will be played sequentially" +fi diff --git a/mpv-xwinwrap b/mpv-xwinwrap new file mode 100755 index 0000000..a7242f9 --- /dev/null +++ b/mpv-xwinwrap @@ -0,0 +1,112 @@ +#!/bin/bash + +# Copyright (c) 2017 rehashedsalt/vintagesalt +# +# 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. + +if [ "$XDG_DATA_HOME" = "" ]; then + cachefile="$HOME/.local/share/mpv-wrapcache" +else + cachefile="$XDG_DATA_HOME/mpv-wrapcache" +fi + +if ! [ -f "$cachefile" ]; then + touch $cachefile +fi + +cachecontent="$(cat $cachefile)" + +function video-play { + pkill -x xwinwrap + #xwinwrap -g 1920x1048+0+0 -ni -b -nf -o 0.5 -ov -- urxvt -bg rgba:2828/2828/2828/FFFF -embed WID -e cava + xwinwrap -ni -fs -b -nf -ov -- mpv -wid WID --title="Desktop Video" --loop-playlist=inf $1 + return 0 +} + +function video-validate { + if [[ "$(curl -Is $1 | head -1)" = *"200"* ]] && [[ "$1" = *"youtu"* ]]; then + return 0 + fi + return 1 +} + +function cache-add { + if [[ "$cachecontent" == *"$1"* ]]; then + return 1 + fi + name="$(youtube-dl -e $1)" + printf "$name\n$1\n" >> $cachefile + return 0 +} + +function cache-populate { + names="$(awk -F'\n' 'BEGIN{RS="\n\n"} {for (i=1;i<=NF;i+=2) print $i}' $cachefile)" + printf "$names" + return 0 +} + +function cache-lookup-by-name { + url="$(awk -v URL="$1" -F'\n' 'BEGIN{RS="\n\n"} {for (i=1;i<=NF;i++) if (index($i, URL)) print $(i+1)}' $cachefile)" + if [ "$url" = "" ]; then + return 1 + fi + printf "$url\n" + return 0 +} + +function input-get { + cache-populate | rofi -dmenu -p 'Embed video: ' + return 0 +} + +function soft-notify { + notify-send -u low -t 3000 -a 'mpv-xwinwrap' "$1" "$2" + return 0 +} + +function hard-notify { + notify-send -u normal -t 10000 -a 'mpv-xwinwrap' "$1" "$2" + return 0 +} + +input="$(input-get | tr -d '\n')" +if [ "$input" = "" ]; then + exit 1 +fi + +printf "Input: $input\n" + +if cache-lookup-by-name "$input"; then + printf "Lookup successful: \n" + input="$(cache-lookup-by-name "$input")" + printf "\n" +fi + +if ! video-validate $input; then + hard-notify "Unable to Find Video" "Please verify that the URL is a valid YouTube address and try again." + printf "Not a valid stream: $input\n" + exit 1 +fi + +soft-notify "Found Video" "Video $1 has been found and is buffering. It will be embedded in the desktop shortly." + +cache-add $input +video-play $input + +exit 0 diff --git a/powerline-shell.py b/powerline-shell.py new file mode 100755 index 0000000..3d1d011 --- /dev/null +++ b/powerline-shell.py @@ -0,0 +1,650 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from __future__ import print_function + +import argparse +import os +import sys + +py3 = sys.version_info.major == 3 + + +def warn(msg): + print('[powerline-bash] ', msg) + + +if py3: + def unicode(x): + return x + + +class Powerline: + symbols = { + 'compatible': { + 'lock': 'RO', + 'network': 'SSH', + 'separator': u'\u25B6', + 'separator_thin': u'\u276F' + }, + 'patched': { + 'lock': u'\uE0A2', + 'network': u'\uE0A2', + 'separator': u'\uE0B0', + 'separator_thin': u'\uE0B1' + }, + 'flat': { + 'lock': '', + 'network': '', + 'separator': '', + 'separator_thin': '' + }, + } + + color_templates = { + 'bash': '\\[\\e%s\\]', + 'zsh': '%%{%s%%}', + 'bare': '%s', + } + + def __init__(self, args, cwd): + self.args = args + self.cwd = cwd + mode, shell = args.mode, args.shell + self.color_template = self.color_templates[shell] + self.reset = self.color_template % '[0m' + self.lock = Powerline.symbols[mode]['lock'] + self.network = Powerline.symbols[mode]['network'] + self.separator = Powerline.symbols[mode]['separator'] + self.separator_thin = Powerline.symbols[mode]['separator_thin'] + self.segments = [] + + def color(self, prefix, code): + if code is None: + return '' + elif code == Color.RESET: + return self.reset + else: + return self.color_template % ('[%s;5;%sm' % (prefix, code)) + + def fgcolor(self, code): + return self.color('38', code) + + def bgcolor(self, code): + return self.color('48', code) + + def append(self, content, fg, bg, separator=None, separator_fg=None): + self.segments.append((content, fg, bg, + separator if separator is not None else self.separator, + separator_fg if separator_fg is not None else bg)) + + def draw(self): + text = (''.join(self.draw_segment(i) for i in range(len(self.segments))) + + self.reset) + ' ' + if py3: + return text + else: + return text.encode('utf-8') + + def draw_segment(self, idx): + segment = self.segments[idx] + next_segment = self.segments[idx + 1] if idx < len(self.segments)-1 else None + + return ''.join(( + self.fgcolor(segment[1]), + self.bgcolor(segment[2]), + segment[0], + self.bgcolor(next_segment[2]) if next_segment else self.reset, + self.fgcolor(segment[4]), + segment[3])) + + +class RepoStats: + symbols = { + 'detached': u'\u2693', + 'ahead': u'\u2B06', + 'behind': u'\u2B07', + 'staged': u'\u2714', + 'not_staged': u'\u270E', + 'untracked': u'\u2753', + 'conflicted': u'\u273C' + } + + def __init__(self): + self.ahead = 0 + self.behind = 0 + self.untracked = 0 + self.not_staged = 0 + self.staged = 0 + self.conflicted = 0 + + @property + def dirty(self): + qualifiers = [ + self.untracked, + self.not_staged, + self.staged, + self.conflicted, + ] + return sum(qualifiers) > 0 + + def __getitem__(self, _key): + return getattr(self, _key) + + def n_or_empty(self, _key): + """Given a string name of one of the properties of this class, returns + the value of the property as a string when the value is greater than + 1. When it is not greater than one, returns an empty string. + + As an example, if you want to show an icon for untracked files, but you + only want a number to appear next to the icon when there are more than + one untracked files, you can do: + + segment = repo_stats.n_or_empty("untracked") + icon_string + """ + return unicode(self[_key]) if int(self[_key]) > 1 else u'' + + def add_to_powerline(self, powerline, color): + def add(_key, fg, bg): + if self[_key]: + s = u" {}{} ".format(self.n_or_empty(_key), self.symbols[_key]) + powerline.append(s, fg, bg) + add('ahead', color.GIT_AHEAD_FG, color.GIT_AHEAD_BG) + add('behind', color.GIT_BEHIND_FG, color.GIT_BEHIND_BG) + add('staged', color.GIT_STAGED_FG, color.GIT_STAGED_BG) + add('not_staged', color.GIT_NOTSTAGED_FG, color.GIT_NOTSTAGED_BG) + add('untracked', color.GIT_UNTRACKED_FG, color.GIT_UNTRACKED_BG) + add('conflicted', color.GIT_CONFLICTED_FG, color.GIT_CONFLICTED_BG) + + +def get_valid_cwd(): + """ We check if the current working directory is valid or not. Typically + happens when you checkout a different branch on git that doesn't have + this directory. + We return the original cwd because the shell still considers that to be + the working directory, so returning our guess will confuse people + """ + # Prefer the PWD environment variable. Python's os.getcwd function follows + # symbolic links, which is undesirable. But if PWD is not set then fall + # back to this func + try: + cwd = os.getenv('PWD') or os.getcwd() + except: + warn("Your current directory is invalid. If you open a ticket at " + + "https://github.com/milkbikis/powerline-shell/issues/new " + + "we would love to help fix the issue.") + sys.stdout.write("> ") + sys.exit(1) + + parts = cwd.split(os.sep) + up = cwd + while parts and not os.path.exists(up): + parts.pop() + up = os.sep.join(parts) + if cwd != up: + warn("Your current directory is invalid. Lowest valid directory: " + + up) + return cwd + + +if __name__ == "__main__": + arg_parser = argparse.ArgumentParser() + arg_parser.add_argument('--cwd-mode', action='store', + help='How to display the current directory', default='fancy', + choices=['fancy', 'plain', 'dironly']) + arg_parser.add_argument('--cwd-only', action='store_true', + help='Deprecated. Use --cwd-mode=dironly') + arg_parser.add_argument('--cwd-max-depth', action='store', type=int, + default=5, help='Maximum number of directories to show in path') + arg_parser.add_argument('--cwd-max-dir-size', action='store', type=int, + help='Maximum number of letters displayed for each directory in the path') + arg_parser.add_argument('--colorize-hostname', action='store_true', + help='Colorize the hostname based on a hash of itself.') + arg_parser.add_argument('--mode', action='store', default='patched', + help='The characters used to make separators between segments', + choices=['patched', 'compatible', 'flat']) + arg_parser.add_argument('--shell', action='store', default='bash', + help='Set this to your shell type', choices=['bash', 'zsh', 'bare']) + arg_parser.add_argument('prev_error', nargs='?', type=int, default=0, + help='Error code returned by the last command') + args = arg_parser.parse_args() + + powerline = Powerline(args, get_valid_cwd()) + + +class DefaultColor: + """ + This class should have the default colors for every segment. + Please test every new segment with this theme first. + """ + # RESET is not a real color code. It is used as in indicator + # within the code that any foreground / background color should + # be cleared + RESET = -1 + + USERNAME_FG = 250 + USERNAME_BG = 240 + USERNAME_ROOT_BG = 124 + + HOSTNAME_FG = 250 + HOSTNAME_BG = 238 + + HOME_SPECIAL_DISPLAY = True + HOME_BG = 31 # blueish + HOME_FG = 15 # white + PATH_BG = 237 # dark grey + PATH_FG = 250 # light grey + CWD_FG = 254 # nearly-white grey + SEPARATOR_FG = 244 + + READONLY_BG = 124 + READONLY_FG = 254 + + SSH_BG = 166 # medium orange + SSH_FG = 254 + + REPO_CLEAN_BG = 148 # a light green color + REPO_CLEAN_FG = 0 # black + REPO_DIRTY_BG = 161 # pink/red + REPO_DIRTY_FG = 15 # white + + JOBS_FG = 39 + JOBS_BG = 238 + + CMD_PASSED_BG = 236 + CMD_PASSED_FG = 15 + CMD_FAILED_BG = 161 + CMD_FAILED_FG = 15 + + SVN_CHANGES_BG = 148 + SVN_CHANGES_FG = 22 # dark green + + GIT_AHEAD_BG = 240 + GIT_AHEAD_FG = 250 + GIT_BEHIND_BG = 240 + GIT_BEHIND_FG = 250 + GIT_STAGED_BG = 22 + GIT_STAGED_FG = 15 + GIT_NOTSTAGED_BG = 130 + GIT_NOTSTAGED_FG = 15 + GIT_UNTRACKED_BG = 52 + GIT_UNTRACKED_FG = 15 + GIT_CONFLICTED_BG = 9 + GIT_CONFLICTED_FG = 15 + + VIRTUAL_ENV_BG = 35 # a mid-tone green + VIRTUAL_ENV_FG = 00 + +class Color(DefaultColor): + """ + This subclass is required when the user chooses to use 'default' theme. + Because the segments require a 'Color' class for every theme. + """ + pass + + +class DefaultColor: + """ + This class should have the default colors for every segment. + Please test every new segment with this theme first. + """ + # RESET is not a real color code. It is used as in indicator + # within the code that any foreground / background color should + # be cleared + RESET = -1 + + USERNAME_FG = 223 #fg1 + USERNAME_BG = 237 #bg1 + USERNAME_ROOT_BG = 172 #yellow (dark) + + HOSTNAME_FG = 223 #fg1 + HOSTNAME_BG = 235 #bg0 + + HOME_SPECIAL_DISPLAY = False + # HOME_BG = 239 #bg2 + HOME_FG = 223 #fg1 + PATH_BG = 239 #bg2 + PATH_FG = 223 #fg1 + CWD_FG = 223 #fg1 + SEPARATOR_FG = 246 #fg4 + + READONLY_BG = 124 #red (dark) + READONLY_FG = 223 #fg1 + + SSH_BG = 132 #purple (dark) + SSH_FG = 223 #fg1 + + REPO_CLEAN_BG = 106 #green (dark) + REPO_CLEAN_FG = 223 #fg1 + REPO_DIRTY_BG = 124 #red (dark) + REPO_DIRTY_FG = 223 #fg1 + + JOBS_FG = 223 #fg1 + JOBS_BG = 66 #blue (dark) + + CMD_PASSED_BG = 142 #green (light) + CMD_PASSED_FG = 235 #bg0 + CMD_FAILED_BG = 167 #red (light) + CMD_FAILED_FG = 235 #bg0 + + SVN_CHANGES_BG = 245 #gray + SVN_CHANGES_FG = 214 #yellow (light) + + GIT_AHEAD_BG = 241 #bg3 + GIT_AHEAD_FG = 223 #fg1 + GIT_BEHIND_BG = 241 #bg3 + GIT_BEHIND_FG = 223 #fg1 + GIT_STAGED_BG = 142 #green (light) + GIT_STAGED_FG = 235 #bg0 + GIT_NOTSTAGED_BG = 214 #yellow (light) + GIT_NOTSTAGED_FG = 235 #bg0 + GIT_UNTRACKED_BG = 167 #red (light) + GIT_UNTRACKED_FG = 235 #bg0 + GIT_CONFLICTED_BG = 167 #red (light) + GIT_CONFLICTED_FG = 124 #red (dark) + + VIRTUAL_ENV_BG = 106 #green (dark) + VIRTUAL_ENV_FG = 223 #fg1 + +class Color(DefaultColor): + """ + This subclass is required when the user chooses to use 'default' theme. + Because the segments require a 'Color' class for every theme. + """ + pass + + +def add_set_term_title_segment(powerline): + term = os.getenv('TERM') + if not (('xterm' in term) or ('rxvt' in term)): + return + + if powerline.args.shell == 'bash': + set_title = '\\[\\e]0;\\u@\\h: \\w\\a\\]' + elif powerline.args.shell == 'zsh': + set_title = '%{\033]0;%n@%m: %~\007%}' + else: + import socket + set_title = '\033]0;%s@%s: %s\007' % (os.getenv('USER'), socket.gethostname().split('.')[0], powerline.cwd or os.getenv('PWD')) + + powerline.append(set_title, None, None, '') + + + +add_set_term_title_segment(powerline) + +def add_username_segment(powerline): + import os + if powerline.args.shell == 'bash': + user_prompt = ' \\u ' + elif powerline.args.shell == 'zsh': + user_prompt = ' %n ' + else: + user_prompt = ' %s ' % os.getenv('USER') + + if os.getenv('USER') == 'root': + bgcolor = Color.USERNAME_ROOT_BG + else: + bgcolor = Color.USERNAME_BG + + powerline.append(user_prompt, Color.USERNAME_FG, bgcolor) + + +add_username_segment(powerline) +import os + +def add_ssh_segment(powerline): + + if os.getenv('SSH_CLIENT'): + powerline.append(' %s ' % powerline.network, Color.SSH_FG, Color.SSH_BG) + + +add_ssh_segment(powerline) +import os +import re +import subprocess +import platform + +def add_jobs_segment(powerline): + num_jobs = 0 + + if platform.system().startswith('CYGWIN'): + # cygwin ps is a special snowflake... + output_proc = subprocess.Popen(['ps', '-af'], stdout=subprocess.PIPE) + output = map(lambda l: int(l.split()[2].strip()), + output_proc.communicate()[0].decode("utf-8").splitlines()[1:]) + + num_jobs = output.count(os.getppid()) - 1 + + else: + + pppid_proc = subprocess.Popen(['ps', '-p', str(os.getppid()), '-oppid='], + stdout=subprocess.PIPE) + pppid = pppid_proc.communicate()[0].decode("utf-8").strip() + + output_proc = subprocess.Popen(['ps', '-a', '-o', 'ppid'], + stdout=subprocess.PIPE) + output = output_proc.communicate()[0].decode("utf-8") + + num_jobs = len(re.findall(str(pppid), output)) - 1 + + if num_jobs > 0: + powerline.append(' %d ' % num_jobs, Color.JOBS_FG, Color.JOBS_BG) + + +add_jobs_segment(powerline) +import os + +ELLIPSIS = u'\u2026' + + +def replace_home_dir(cwd): + home = os.getenv('HOME') + if cwd.startswith(home): + return '~' + cwd[len(home):] + return cwd + + +def split_path_into_names(cwd): + names = cwd.split(os.sep) + + if names[0] == '': + names = names[1:] + + if not names[0]: + return ['/'] + + return names + + +def requires_special_home_display(name): + """Returns true if the given directory name matches the home indicator and + the chosen theme should use a special home indicator display.""" + return (name == '~' and Color.HOME_SPECIAL_DISPLAY) + + +def maybe_shorten_name(powerline, name): + """If the user has asked for each directory name to be shortened, will + return the name up to their specified length. Otherwise returns the full + name.""" + if powerline.args.cwd_max_dir_size: + return name[:powerline.args.cwd_max_dir_size] + return name + + +def get_fg_bg(name, is_last_dir): + """Returns the foreground and background color to use for the given name. + """ + if requires_special_home_display(name): + return (Color.HOME_FG, Color.HOME_BG,) + + if is_last_dir: + return (Color.CWD_FG, Color.PATH_BG,) + else: + return (Color.PATH_FG, Color.PATH_BG,) + + +def add_cwd_segment(powerline): + cwd = powerline.cwd or os.getenv('PWD') + if not py3: + cwd = cwd.decode("utf-8") + cwd = replace_home_dir(cwd) + + if powerline.args.cwd_mode == 'plain': + powerline.append(' %s ' % (cwd,), Color.CWD_FG, Color.PATH_BG) + return + + names = split_path_into_names(cwd) + + max_depth = powerline.args.cwd_max_depth + if max_depth <= 0: + warn("Ignoring --cwd-max-depth argument since it's not greater than 0") + elif len(names) > max_depth: + # https://github.com/milkbikis/powerline-shell/issues/148 + # n_before is the number is the number of directories to put before the + # ellipsis. So if you are at ~/a/b/c/d/e and max depth is 4, it will + # show `~ a ... d e`. + # + # max_depth must be greater than n_before or else you end up repeating + # parts of the path with the way the splicing is written below. + n_before = 2 if max_depth > 2 else max_depth - 1 + names = names[:n_before] + [ELLIPSIS] + names[n_before - max_depth:] + + if (powerline.args.cwd_mode == 'dironly' or powerline.args.cwd_only): + # The user has indicated they only want the current directory to be + # displayed, so chop everything else off + names = names[-1:] + + for i, name in enumerate(names): + is_last_dir = (i == len(names) - 1) + fg, bg = get_fg_bg(name, is_last_dir) + + separator = powerline.separator_thin + separator_fg = Color.SEPARATOR_FG + if requires_special_home_display(name) or is_last_dir: + separator = None + separator_fg = None + + powerline.append(' %s ' % maybe_shorten_name(powerline, name), fg, bg, + separator, separator_fg) + + +add_cwd_segment(powerline) +import re +import subprocess +import os + +def get_PATH(): + """Normally gets the PATH from the OS. This function exists to enable + easily mocking the PATH in tests. + """ + return os.getenv("PATH") + +def git_subprocess_env(): + return { + # LANG is specified to ensure git always uses a language we are expecting. + # Otherwise we may be unable to parse the output. + "LANG": "C", + + # https://github.com/milkbikis/powerline-shell/pull/126 + "HOME": os.getenv("HOME"), + + # https://github.com/milkbikis/powerline-shell/pull/153 + "PATH": get_PATH(), + } + + +def parse_git_branch_info(status): + info = re.search('^## (?P\S+?)''(\.{3}(?P\S+?)( \[(ahead (?P\d+)(, )?)?(behind (?P\d+))?\])?)?$', status[0]) + return info.groupdict() if info else None + + +def _get_git_detached_branch(): + p = subprocess.Popen(['git', 'describe', '--tags', '--always'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + env=git_subprocess_env()) + detached_ref = p.communicate()[0].decode("utf-8").rstrip('\n') + if p.returncode == 0: + branch = u'{} {}'.format(RepoStats.symbols['detached'], detached_ref) + else: + branch = 'Big Bang' + return branch + + +def parse_git_stats(status): + stats = RepoStats() + for statusline in status[1:]: + code = statusline[:2] + if code == '??': + stats.untracked += 1 + elif code in ('DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU'): + stats.conflicted += 1 + else: + if code[1] != ' ': + stats.not_staged += 1 + if code[0] != ' ': + stats.staged += 1 + + return stats + + +def add_git_segment(powerline): + try: + p = subprocess.Popen(['git', 'status', '--porcelain', '-b'], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + env=git_subprocess_env()) + except OSError: + # Popen will throw an OSError if git is not found + return + + pdata = p.communicate() + if p.returncode != 0: + return + + status = pdata[0].decode("utf-8").splitlines() + stats = parse_git_stats(status) + branch_info = parse_git_branch_info(status) + + if branch_info: + stats.ahead = branch_info["ahead"] + stats.behind = branch_info["behind"] + branch = branch_info['local'] + else: + branch = _get_git_detached_branch() + + bg = Color.REPO_CLEAN_BG + fg = Color.REPO_CLEAN_FG + if stats.dirty: + bg = Color.REPO_DIRTY_BG + fg = Color.REPO_DIRTY_FG + + powerline.append(' %s ' % branch, fg, bg) + stats.add_to_powerline(powerline, Color) + + +add_git_segment(powerline) +import os + +def add_read_only_segment(powerline): + cwd = powerline.cwd or os.getenv('PWD') + + if not os.access(cwd, os.W_OK): + powerline.append(' %s ' % powerline.lock, Color.READONLY_FG, Color.READONLY_BG) + + +add_read_only_segment(powerline) +def add_root_segment(powerline): + root_indicators = { + 'bash': ' \\$ ', + 'zsh': ' %# ', + 'bare': ' $ ', + } + bg = Color.CMD_PASSED_BG + fg = Color.CMD_PASSED_FG + if powerline.args.prev_error != 0: + fg = Color.CMD_FAILED_FG + bg = Color.CMD_FAILED_BG + powerline.append(root_indicators[powerline.args.shell], fg, bg) + + +add_root_segment(powerline) +sys.stdout.write(powerline.draw()) diff --git a/tde.bin b/tde.bin new file mode 100644 index 0000000000000000000000000000000000000000..3720cc09ce5971ce6009068d6e02951df0a3c58d GIT binary patch literal 5582 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 literal 0 HcmV?d00001 diff --git a/test/test-colors b/test/test-colors new file mode 100755 index 0000000..1073449 --- /dev/null +++ b/test/test-colors @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Description: +# +# Prints a color table of 8bg * 8fg * 2 states (regular/bold) +# +# Copyright: +# +# (C) 2009 Wolfgang Frisch +# +# License: +# +# 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, either version 3 of the License, or +# (at your option) any later version. +# +# 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 . + +echo +echo Table for 16-color terminal escape sequences. +echo Replace ESC with \\033 in bash. +echo +echo "Background | Foreground colors" +echo "-----------------------------------------------------------------------------" +for((bg=40;bg<=47;bg++)); do + for((bold=0;bold<=1;bold++)) do + echo -en "\033[0m"" ESC[${bg}m | " + for((fg=30;fg<=37;fg++)); do + if [ $bold == "0" ]; then + echo -en "\033[${bg}m\033[${fg}m █[${fg}m " + else + echo -en "\033[${bg}m\033[1;${fg}m █[1;${fg}m" + fi + done + echo -e "\033[0m" + done + echo "----------------------------------------------------------------------------- " +done + +echo +echo diff --git a/test/test-notifications b/test/test-notifications new file mode 100755 index 0000000..479c9e1 --- /dev/null +++ b/test/test-notifications @@ -0,0 +1,5 @@ +#!/bin/sh +notify-send -u low "Low Urgency Notification" "This is a simple test notification with low urgency. It's okay to ignore me, I guess." +notify-send -u normal "Normal Urgency Notification" "This is another simple test notification with normal urgency. My information will help you work." +notify-send -u critical "High Urgency Notification" "This notification really should grab your attention! It's important!" +notify-send -u normal "Long Notification" "This is a very long notification with a very long, unabridged description. Its sole purpose is to test whether or not your notification handler can properly wrap descriptions and truncate where necessary. This is important as notifications should simply alert the user that something is going on, and should not otherwise impede work." diff --git a/wal-set b/wal-set new file mode 100755 index 0000000..3193e7a --- /dev/null +++ b/wal-set @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright (c) rehashedsalt/vintagesalt +# +# 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. + +# Set a wallpaper +wal -a 80 -i "$HOME/Pictures/Wallpapers/i3" + +# Source its generated colors +source "$HOME/.cache/wal/colors.sh" + +# Restart dunst +pkill dunst +dunst \ + -lb "${color0}" \ + -nb "${color0}" \ + -cb "${color0}" \ + -lfr "${color0}" \ + -nfr "${color0}" \ + -cfr "${color0}" \ + -lf "${color7}" \ + -nf "${color15}" \ + -cf "${color9}" \ + +exit 0 diff --git a/xephrice b/xephrice new file mode 100755 index 0000000..6d6c1b2 --- /dev/null +++ b/xephrice @@ -0,0 +1,35 @@ +#!/bin/bash + +# Copyright (c) 2017 rehashedsalt/vintagesalt +# +# 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. + +xephyrdisplay=":8" + +Xephyr -screen 1920x1080 -title "Xephyr Instance" -br -ac $xephyrdisplay & + +DISPLAY="$xephyrdisplay" +sleep 1 + +urxvt & + +# Disown all of our jobs +printf "\nXephyr session started with urxvt in background. Disowning and closing this terminal may break them!\n" + +exit 0 diff --git a/xrdbupdate b/xrdbupdate new file mode 100755 index 0000000..8c6af0f --- /dev/null +++ b/xrdbupdate @@ -0,0 +1,2 @@ +#!/bin/sh +xrdb ~/.Xresources