Updated with newest versions of all files

This commit is contained in:
Tony Grosinger 2013-03-04 20:59:34 -08:00
parent 643427757e
commit 4f992ad608
57 changed files with 26 additions and 582 deletions

8
.gitconfig Executable file → Normal file
View File

@ -1,8 +1,8 @@
[user]
name = Tony Grosinger
email = tony@grosinger.net
name = Tony Grosinger
email = tony@grosinger.net
[color]
ui = auto
ui = auto
[alias]
co = checkout
ci = commit
@ -12,4 +12,4 @@
type = cat-file -t
dump = cat-file -p
[push]
default = simple
default = simple

3
.gitignore vendored Executable file → Normal file
View File

@ -15,3 +15,6 @@ target/
# Eclipse
.project
.classpath
# Pycharm
.idea/

0
tmux-powerline/LICENSE → .tmux-powerline/LICENSE Executable file → Normal file
View File

0
tmux-powerline/README.md → .tmux-powerline/README.md Executable file → Normal file
View File

0
tmux-powerline/config.sh → .tmux-powerline/config.sh Executable file → Normal file
View File

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

0
tmux-powerline/lib.sh → .tmux-powerline/lib.sh Executable file → Normal file
View File

View File

6
.tmux.conf Executable file → Normal file
View File

@ -4,8 +4,8 @@ set-option -g status-utf8 on
set-option -g status-justify "centre"
set-option -g status-left-length 60
set-option -g status-right-length 90
set-option -g status-left "#(~/Documents/personal/dotfiles/tmux-powerline/status-left.sh)"
set-option -g status-right "#(~/Documents/personal/dotfiles/tmux-powerline/status-right.sh)"
set-option -g status-left "#(~/.tmux-powerline/status-left.sh)"
set-option -g status-right "#(~/.tmux-powerline/status-right.sh)"
### Copy / Paste
set-window-option -g mode-keys vi
@ -42,4 +42,4 @@ set-option -g display-panes-active-colour blue #blue
set-option -g display-panes-colour brightred #orange
# clock
set-window-option -g clock-mode-colour green #green
set-window-option -g clock-mode-colour green #green

12
.vimrc Executable file → Normal file
View File

@ -1,20 +1,23 @@
syntax on
filetype on
filetype plugin on
filetype plugin on
set number
set background=dark
colorscheme solarized
" leader
let mapleader = ","
let g:mapleader = ","
" some shortcuts
:nmap \n :setlocal number!<CR>
:nmap \p :set paste!<CR>
" tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>tm :tabmove
map <leader>tt :tabnext<cr>
" backup
@ -34,6 +37,3 @@ set smartindent
set ignorecase
set smartcase
set incsearch
" plugins
set runtimepath^=~/.vim/bundle/ctrlp.vim

8
.zshrc Executable file → Normal file
View File

@ -28,7 +28,6 @@ alias la="ls -lha"
alias clear="clear & ls"
# Applications
alias mongod="mongod -f /etc/mongodb.conf"
alias tmux="tmux -2"
# Computer control
@ -43,12 +42,9 @@ alias gc="git commit -m "
alias gs="git status"
alias gpp="git push"
# Source local
source ~/.zshrc_local
# Functions
# (f)ind by (n)ame
# usage: fn foo
# usage: fn foo
# to find all files containing 'foo' in the name
function fn() { ls **/*$1* }
function fn() { ls **/*$1* }

View File

@ -16,6 +16,8 @@ case "$choice" in
rm .zshrc;
fi
ln -s $DIR/.zshrc .zshrc;
touch $DIR/.zshrc_local
echo "Linking vim...";
if [ -f .vimrc ];
@ -44,8 +46,13 @@ case "$choice" in
rm .tmux.conf;
fi
ln -s $DIR/.tmux.conf .tmux.conf;
if [ -d .tmux-powerline ];
then
rm -rf .tmux-powerline;
fi
ln -s $DIR/.tmux-powerline .tmux-powerline;
echo "Hotswapping bash...";
echo "Hotswapping zshrc...";
source .zshrc;
echo "Done! Exiting."

View File

@ -1,21 +0,0 @@
Please append you name/nick here when you have contributed with something!
Erik Westrup <erik.westrup@gmail.com>
Suvash Thapaliya <suvash@gmail.com>
Erik Jansson <erikjansson90@gmail.com>
Yuku Takahashi <taka84u9@gmail.com>
Oscar Olsson <osse.olsson@gmail.com>
Ryo Katsuma
negipo
Sina Siadat
Vivien Leroy <fantattitude@me.com>
Gino Lucero
Derek Ashley Thomas <derekathomas@gmail.com>
LuRsT
Tomokazu Hirai <tomokazu.hirai@gmail.com>
Matt Black
krieiter
Viktor Jackson
flytreeleft <flytreeleft@126.com>
Conner McDaniel
David Francos <me@davidfrancos.net>

View File

@ -1,37 +0,0 @@
#!/usr/bin/env bash
HEART_CONNECTED=
HEART_DISCONNECTED=
case $(uname -s) in
"Darwin")
ioreg -c AppleSmartBattery -w0 | \
grep -o '"[^"]*" = [^ ]*' | \
sed -e 's/= //g' -e 's/"//g' | \
sort | \
while read key value; do
case $key in
"MaxCapacity")
export maxcap=$value;;
"CurrentCapacity")
export curcap=$value;;
"ExternalConnected")
export extconnect=$value;;
esac
if [[ -n $maxcap && -n $curcap && -n $extconnect ]]; then
if [[ "$curcap" == "$maxcap" ]]; then
exit
fi
charge=$(( 100 * $curcap / $maxcap ))
if [[ "$extconnect" == "Yes" ]]; then
echo $HEART_CONNECTED "$charge%"
else
if [[ $charge -lt 50 ]]; then
echo -n "#[fg=red]"
fi
echo $HEART_DISCONNECTED "$charge%"
fi
break
fi
done
esac

View File

@ -1,14 +0,0 @@
#!/usr/bin/env osascript
# Returns the number of unread mails in the INBOX of Apple Mail.
tell application "System Events"
set process_list to (name of every process)
end tell
if process_list contains "Mail" then
tell application "Mail"
if unread count of inbox > 0 then
set a to " " & unread count of inbox
end if
end tell
end if

View File

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Return the number of new mails in a maildir.
inbox="$HOME/.mail/inbox/new"
cd "$(dirname $0)"
if [ ! -d "$inbox" ]; then
exit 1
fi
nbr_new=$(ls "$inbox" | wc -l)
if [ "$nbr_new" -gt "0" ]; then
echo "${nbr_new}"
fi
exit 0;

View File

@ -1,26 +0,0 @@
#!/usr/bin/env bash
# Print Audacious now playing.
trim_method="trim" # Can be {trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
# Check if audacious is playing and print that song.
audacious_pid=$(pidof audacious)
if [ -n "$audacious_pid" ]; then
if $(audtool playback-playing); then
np=$(audtool current-song)
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}"
fi
fi

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# Prints now playing in Banshee.
trim_method="trim" # Can be {trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
# Check if banshee is playing and print that song.
banshee_pid=$(pidof banshee)
if [ -n "$banshee_pid" ]; then
banshee_status=$(banshee --query-current-state 2> /dev/null)
if [[ "$banshee_status" == "current-state: playing" ]]; then
np=$(banshee --query-artist --query-title | cut -d ":" -f2 | sed -e 's/ *$//g' -e 's/^ *//g'| sed -e ':a;N;$!ba;s/\n/ - /g' )
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}" | cut -c1-"$max_len"
fi
fi

View File

@ -1,23 +0,0 @@
#!/usr/bin/env osascript
# Returns the current playing song in iTunes for OSX
tell application "System Events"
set process_list to (name of every process)
end tell
if process_list contains "iTunes" then
tell application "iTunes"
if player state is playing then
set track_name to name of current track
set artist_name to artist of current track
# set album_name to album of current track
set trim_length to 40
set now_playing to "♫ " & artist_name & " - " & track_name
if length of now_playing is less than trim_length then
set now_playing_trim to now_playing
else
set now_playing_trim to characters 1 thru trim_length of now_playing as string
end if
end if
end tell
end if

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# Prints now playing in Mocp. If the output is too long it will scroll like a marquee tag.
trim_method="roll" # Can be {trim or roll).
max_len=20 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
# Check if rhythmbox is playing and print that song.
mocp_pid=$(pidof mocp)
if [ -n "$mocp_pid" ]; then
np=$(mocp -i | grep ^Title | sed "s/^Title://")
mocp_paused=$(mocp -i | grep ^State | sed "s/^State: //")
if [[ $np ]]; then
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
if [[ "$mocp_paused" != "PAUSE" ]]; then
echo "♫ ⮀ ${np}"
elif [[ "$mocp_paused" == "PAUSE" ]]; then
echo "♫ || ${np}"
fi
fi
fi

View File

@ -1,179 +0,0 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mpd/client.h>
#ifdef DEBUG
#define DO_DEBUG DEBUG
#else
#define DO_DEBUG 0
#endif
#define DEBUG_PRINTF(...) do{ if (DO_DEBUG) { printf(__VA_ARGS__);} } while(0)
/* Output the current song if MPD is in a playing state. The connection password, host and port is
* specified like for mpc with environment variables
* MPD_HOST=[password@]host
* MPD_PORT=port
* If they are empty they defaults to localhost on port 6600.
*/
int main(int argc, const char *argv[])
{
char *mpd_host = NULL;
char *mpd_password = NULL;
unsigned int mpd_port = 0;
char *mpd_host_m = NULL;
char *mpd_password_m = NULL;
const char *mpd_host_str = getenv("MPD_HOST");
if (mpd_host_str == NULL || strlen(mpd_host_str) == 0) {
DEBUG_PRINTF("No envvar MPD_HOST set or empty. Using default value (localhost).\n");
mpd_host = "localhost";
} else {
size_t mpd_host_len = strlen(mpd_host_str);
char mpd_host_env[mpd_host_len + 1];
strncpy(mpd_host_env, mpd_host_str, mpd_host_len);
mpd_host_env[mpd_host_len] = '\0';
char *pch = strtok(mpd_host_env, "@");
char *first = NULL;
char *second = NULL;
if (pch != NULL) {
first = pch;
}
pch = strtok(NULL, "@");
if (pch != NULL) {
second = pch;
}
if (first != NULL && second != NULL) {
DEBUG_PRINTF("%s - %s\n", first, second);
size_t first_len = strlen(first);
size_t second_len = strlen(second);
mpd_password_m = (char *) malloc(first_len + 1);
mpd_host_m= (char *) malloc(second_len + 1);
if (mpd_password_m == NULL || mpd_host_m == NULL) {
DEBUG_PRINTF("Failed alloc password/host.\n");
return EXIT_FAILURE;
}
strncpy(mpd_password_m, first, first_len);
mpd_password_m[first_len] = '\0';
strncpy(mpd_host_m, second, second_len);
mpd_host_m[second_len] = '\0';
} else if (first != NULL) {
DEBUG_PRINTF("%s\n", first);
size_t first_len = strlen(first);
mpd_host_m = (char *) malloc(first_len + 1);
if (mpd_host_m == NULL ) {
DEBUG_PRINTF("Failed alloc host.\n");
return EXIT_FAILURE;
}
strncpy(mpd_host_m, first, first_len);
mpd_host_m[first_len] = '\0';
}
}
if (mpd_host_m != NULL) {
mpd_host = mpd_host_m;
}
if (mpd_password_m != NULL) {
mpd_password = mpd_password_m;
}
const char *mpd_port_env = getenv("MPD_PORT");
if (mpd_port_env == NULL || strlen(mpd_port_env) == 0) {
DEBUG_PRINTF("No envvar MPD_PORT set or empty. Using default value (6600).\n");
mpd_port = 6600;
} else {
int mpd_port_m = atoi(mpd_port_env);
if (mpd_port_m == 0) {
DEBUG_PRINTF("Could not convert MPD_PORT to int.\n");
return EXIT_FAILURE;
} else if (mpd_port_m < 0) {
DEBUG_PRINTF("Negative port?!\n");
return EXIT_FAILURE;
} else {
mpd_port = mpd_port_m;
DEBUG_PRINTF("Using port %i\n", mpd_port);
}
}
struct mpd_connection *mpd_connection = mpd_connection_new(mpd_host, mpd_port, 1000);
if (mpd_connection == NULL) {
DEBUG_PRINTF("%s\n", "Could Not connect");
return EXIT_FAILURE;
}
if (mpd_password != NULL) {
bool authenticated = mpd_run_password(mpd_connection, mpd_password);
if (!authenticated) {
DEBUG_PRINTF("Failed to authenticate.\n");
return EXIT_FAILURE;
}
}
free(mpd_host_m);
free(mpd_password_m);
bool sent_status = mpd_send_status(mpd_connection);
if (!sent_status) {
DEBUG_PRINTF("Could not send status request.");
return EXIT_FAILURE;
}
struct mpd_status *mpd_status = mpd_recv_status(mpd_connection);
if (mpd_status == NULL) {
DEBUG_PRINTF("Could not get mpd status.\n");
return EXIT_FAILURE;
}
enum mpd_state mpd_state = mpd_status_get_state(mpd_status);
DEBUG_PRINTF("State: ");
if (mpd_state == MPD_STATE_PLAY) {
DEBUG_PRINTF("Playing.");
} else if (mpd_state == MPD_STATE_PAUSE) {
DEBUG_PRINTF("Paused.");
} else if (mpd_state == MPD_STATE_UNKNOWN) {
DEBUG_PRINTF("Unknown state.");
} else if (mpd_state == MPD_STATE_STOP) {
DEBUG_PRINTF("Stopped.");
}
DEBUG_PRINTF("\n");
if (mpd_state != MPD_STATE_PLAY) {
// Nothing to do.
mpd_status_free(mpd_status);
mpd_connection_free(mpd_connection);
return EXIT_SUCCESS;
}
int song_id = mpd_status_get_song_id(mpd_status);
DEBUG_PRINTF("songid = %i\n", song_id);
mpd_status_free(mpd_status);
struct mpd_song *song = mpd_run_get_queue_song_id(mpd_connection, song_id);
if (song == NULL) {
DEBUG_PRINTF("Could not get song.\n");
return EXIT_FAILURE;
}
const char *song_artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
if (song_artist == NULL) {
DEBUG_PRINTF("Could not get song artist.");
return EXIT_FAILURE;
}
const char *song_title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
if (song_title == NULL) {
DEBUG_PRINTF("Could not get song title.");
return EXIT_FAILURE;
}
printf("%s - %s\n", song_artist, song_title);
mpd_song_free(song);
mpd_connection_free(mpd_connection);
return EXIT_SUCCESS;
}

View File

@ -1,43 +0,0 @@
#!/usr/bin/env bash
# Print a simple line of NP in mpd.
#
# Previously I used something as simple as
#mpc --format "%artist%\n%title%" | grep -Pzo '^(.|\n)*?(?=\[)' | sed ':a;N;$!ba;s/\n/ - /g' | sed 's/\s*-\s$//' | cut -c1-50
# But I decided that I don't want any info about songs if there is nothing playing. Unfortunately I did not find a way of expressing this with mpc (I'm sure there is with idle/idleloop) but I did found a useful library: libmpdclient. I've used version 2.7 when developing my small program. Download the latest version here: http://sourceforge.net/projects/musicpd/files/libmpdclient/
trim_method="trim" # Can be {trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
# Source MPD environment variables (MPD_HOST and MPD_PORT). I refactored out this from ~/.bashrc and source this file there as well. This is not needed if you run your MPD server at localhost, no password and on the standard port.
if [ -f $HOME/.mpd_env ]; then
source $HOME/.mpd_env
fi
cd "$(dirname $0)"
if [ ! -x "np_mpd" ]; then
make clean np_mpd &>/dev/null
fi
if [ -x "np_mpd" ]; then
np=$(./np_mpd)
if [ -n "$np" ]; then
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}"
fi
exit 0
else
exit 1
fi

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# Simple np script for mpd. Works with streams!
# Only tested on OS X... should work the same way on other platforms though.
trim_method="trim" # Can be {Trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
np=$(mpc current 2>&1)
if [ $? -eq 0 ] && [ -n "$np" ]; then
mpc | grep "paused" > /dev/null
if [ $? -eq 0 ]; then
exit 1
fi
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} 2)
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}"
exit 0
fi
exit 1

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# Prints now playing in Rhytmbox.
trim_method="trim" # Can be {trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
# Check if rhythmbox is playing and print that song.
rhythmbox_pid=$(pidof rhythmbox)
if [ -n "$rhythmbox_pid" ]; then
np=$(rhythmbox-client --no-start --print-playing) # Does not tell if the music is playing or paused.
rhythmbox_paused=$(xwininfo -root -tree | grep "$np" | sed "s/${np}//;s/ //g" | cut -f2 -d '"')
# TODO I cant produce the output "Not playing", using rhythmbox 2.97.
#STATUS=$(rhythmbox-client --no-start --print-playing)
if [[ "$rhythmbox_paused" != "(Paused)" ]]; then
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}"
fi
fi

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# Print Spotify now playing for GNU/Linux running the native client.
# List functions and properties with
#$ mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer
trim_method="trim" # Can be {trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
metadata=$(dbus-send --reply-timeout=42 --print-reply --dest=org.mpris.MediaPlayer2.spotify / org.freedesktop.MediaPlayer2.GetMetadata 2>/dev/null)
if [ "$?" -eq 0 ] && [ -n "$metadata" ]; then
# TODO how do one express this with dbus-send? It works with qdbus but the problem is that it's probably not as common as dbus-send.
state=$(qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus)
if [[ $state == "Playing" ]]; then
artist=$(echo "$metadata" | grep -PA2 "string\s\"xesam:artist\"" | tail -1 | grep -Po "(?<=\").*(?=\")")
track=$(echo "$metadata" | grep -PA1 "string\s\"xesam:title\"" | tail -1 | grep -Po "(?<=\").*(?=\")")
np=$(echo "${artist} - ${track}")
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}"
fi
fi

View File

@ -1,28 +0,0 @@
#!/usr/bin/env bash
# Print Spotify now playing for GNU/Linux running in wine.
trim_method="trim" # Can be {trim or roll).
max_len=40 # Trim output to this length.
roll_speed=2 # Roll speed in chraacters per second.
segment_path=$(dirname $0)
source "$segment_path/../lib.sh"
## Check if Spotify is playing and print that song.
spotify_id=$(xwininfo -root -tree | grep '("spotify' | cut -f1 -d'"' | sed 's/ //g')
echo $spotify_id
if [ -n "$spotify_id" ]; then
np=$(xwininfo -id "$spotify_id" | grep "xwininfo.*Spotify -" | grep -Po "(?<=\"Spotify - ).*(?=\"$)")
if [ -n "$np" ]; then
case "$trim_method" in
"roll")
np=$(roll_stuff "${np}" ${max_len} ${roll_speed})
;;
"trim")
np=$(echo "${np}" | cut -c1-"$max_len")
;;
esac
echo "${np}"
fi
fi

View File

@ -1,24 +0,0 @@
#!/usr/bin/env osascript
# Returns the current playing song in Spotify for OSX
tell application "System Events"
set process_list to (name of every process)
end tell
if process_list contains "Spotify" then
tell application "Spotify"
if player state is playing then
set track_name to name of current track
set artist_name to artist of current track
#set album_name to album of current track
set trim_length to 40
set now_playing to "♫ " & artist_name & " - " & track_name
if length of now_playing is less than trim_length then
set now_playing_trim to now_playing
else
set now_playing_trim to characters 1 thru trim_length of now_playing as string
end if
end if
end tell
end if