Skip to content

Instantly share code, notes, and snippets.

@medwards
Last active May 12, 2022 22:14
Show Gist options
  • Save medwards/6438014 to your computer and use it in GitHub Desktop.
Save medwards/6438014 to your computer and use it in GitHub Desktop.
Things to do at setup
clean_pyc() {
find . -name \*.pyc -delete
find . -name __pycache__ -exec rm -rf "{}" \; 2> /dev/null
}
on_write() {
while inotifywait --exclude .git -qre modify .
do
#eval "$@"
eval "${@/&&/&& ogg123 --quiet /usr/share/sounds/freedesktop/stereo/bell.oga &&}"
RETURN_VALUE=$?
ogg123 --quiet /usr/share/sounds/freedesktop/stereo/complete.oga
done
return $RETURN_VALUE
}
webdav_curl() {
curl --digest "$@"
}
fake_cam() {
VIDEO="$@"
if [[ -z "$VIDEO" ]]; then
VIDEO="/home/medwards/Videos/skilift_hd.mp4"
fi
modprobe v4l2loopback
ffmpeg -f concat -safe 0 -i <(for i in {1..100}; do printf "file '%s'\n" $VIDEO ; done) -f v4l2 /dev/video0
}
alias vim="vim -p"
export HOSTALIASES=/etc/host.aliases
export REPO_URL=ssh://[email protected]:29418/external/git-repo
servers = (
{ address = "irc.ubuntu.com"; chatnet = "Ubuntu"; port = "8001"; },
{ address = "eu.irc6.net"; chatnet = "IRCnet"; port = "6667"; },
{ address = "open.ircnet.net"; chatnet = "IRCnet"; port = "6667"; },
{ address = "irc.efnet.org"; chatnet = "EFNet"; port = "6667"; },
{
address = "irc.undernet.org";
chatnet = "Undernet";
port = "6667";
},
{ address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
{
address = "irc.quakenet.org";
chatnet = "QuakeNet";
port = "6667";
},
{ address = "irc.oftc.net"; chatnet = "OFTC"; port = "6667"; },
{
address = "irc.gamesurge.net";
chatnet = "GameSurge";
port = "6667";
},
{ address = "irc.webchat.org"; chatnet = "WebChat"; port = "6667"; },
{ address = "irc.rizon.net"; chatnet = "Rizon"; port = "6667"; },
{ address = "irc.link-net.org"; chatnet = "LinkNet"; port = "6667"; },
{ address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
{
address = "irc.freenode.net";
chatnet = "freenode";
port = "7000";
password = "*********";
use_ssl = "yes";
ssl_verify = "no";
autoconnect = "yes";
},
{
address = "irc.tool.in.here.com";
chatnet = "HERE";
port = "6697";
password = "*********";
use_ssl = "yes";
ssl_verify = "no";
autoconnect = "yes";
}
);
chatnets = {
IRCnet = {
type = "IRC";
max_kicks = "4";
max_msgs = "5";
max_whois = "4";
max_query_chans = "5";
};
EFNet = {
type = "IRC";
max_kicks = "4";
max_msgs = "3";
max_whois = "1";
};
Undernet = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
DALnet = {
type = "IRC";
max_kicks = "4";
max_msgs = "3";
max_whois = "30";
};
QuakeNet = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
OFTC = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
GameSurge = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
WebChat = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
Rizon = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
LinkNet = {
type = "IRC";
max_kicks = "1";
max_msgs = "3";
max_whois = "30";
};
SILC = { type = "SILC"; };
Ubuntu = { type = "IRC"; };
freenode = { type = "IRC"; };
HERE = {
type = "IRC";
nick = "medwards";
username = "micedwar";
realname = "Michael Edwards";
};
};
channels = (
{ name = "#irssi"; chatnet = "ircnet"; autojoin = "No"; },
{ name = "silc"; chatnet = "silc"; autojoin = "No"; },
{ name = "#python"; chatnet = "freenode"; autojoin = "yes"; },
{ name = "#linux"; chatnet = "HERE"; autojoin = "yes"; },
{ name = "#publictransit"; chatnet = "HERE"; autojoin = "yes"; },
{ name = "#iww"; chatnet = "freenode"; autojoin = "yes"; }
);
aliases = {
J = "join";
WJOIN = "join -window";
WQUERY = "query -window";
LEAVE = "part";
BYE = "quit";
EXIT = "quit";
SIGNOFF = "quit";
DESCRIBE = "action";
DATE = "time";
HOST = "userhost";
LAST = "lastlog";
SAY = "msg *";
WI = "whois";
WII = "whois $0 $0";
WW = "whowas";
W = "who";
N = "names";
M = "msg";
T = "topic";
C = "clear";
CL = "clear";
K = "kick";
KB = "kickban";
KN = "knockout";
BANS = "ban";
B = "ban";
MUB = "unban *";
UB = "unban";
IG = "ignore";
UNIG = "unignore";
SB = "scrollback";
UMODE = "mode $N";
WC = "window close";
WN = "window new hide";
SV = "say Irssi $J ($V) - http://irssi.org/";
GOTO = "sb goto";
CHAT = "dcc chat";
RUN = "SCRIPT LOAD";
CALC = "exec - if command -v bc >/dev/null 2>&1\\; then printf '%s=' '$*'\\; echo '$*' | bc -l\\; else echo bc was not found\\; fi";
SBAR = "STATUSBAR";
INVITELIST = "mode $C +I";
Q = "QUERY";
"MANUAL-WINDOWS" = "set use_status_window off;set autocreate_windows off;set autocreate_query_level none;set autoclose_windows off;set reuse_unused_windows on;save";
EXEMPTLIST = "mode $C +e";
ATAG = "WINDOW SERVER";
UNSET = "set -clear";
RESET = "set -default";
};
statusbar = {
# formats:
# when using {templates}, the template is shown only if it's argument isn't
# empty unless no argument is given. for example {sb} is printed always,
# but {sb $T} is printed only if $T isn't empty.
items = {
# start/end text in statusbars
barstart = "{sbstart}";
barend = "{sbend}";
topicbarstart = "{topicsbstart}";
topicbarend = "{topicsbend}";
# treated "normally", you could change the time/user name to whatever
time = "{sb $Z}";
user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}";
# treated specially .. window is printed with non-empty windows,
# window_empty is printed with empty windows
window = "{sb $winref:$tag/$itemname{sbmode $M}}";
window_empty = "{sb $winref{sbservertag $tag}}";
prompt = "{prompt $[.15]itemname}";
prompt_empty = "{prompt $winname}";
topic = " $topic";
topic_empty = " Irssi v$J - http://www.irssi.org";
# all of these treated specially, they're only displayed when needed
lag = "{sb Lag: $0-}";
act = "{sb Act: $0-}";
more = "-- more --";
};
# there's two type of statusbars. root statusbars are either at the top
# of the screen or at the bottom of the screen. window statusbars are at
# the top/bottom of each split window in screen.
default = {
# the "default statusbar" to be displayed at the bottom of the window.
# contains all the normal items.
window = {
disabled = "no";
# window, root
type = "window";
# top, bottom
placement = "bottom";
# number
position = "1";
# active, inactive, always
visible = "active";
# list of items in statusbar in the display order
items = {
barstart = { priority = "100"; };
time = { };
user = { };
window = { };
window_empty = { };
lag = { priority = "-1"; };
act = { priority = "10"; };
more = { priority = "-1"; alignment = "right"; };
barend = { priority = "100"; alignment = "right"; };
};
};
# statusbar to use in inactive split windows
window_inact = {
type = "window";
placement = "bottom";
position = "1";
visible = "inactive";
items = {
barstart = { priority = "100"; };
window = { };
window_empty = { };
more = { priority = "-1"; alignment = "right"; };
barend = { priority = "100"; alignment = "right"; };
};
};
# we treat input line as yet another statusbar :) It's possible to
# add other items before or after the input line item.
prompt = {
type = "root";
placement = "bottom";
# we want to be at the bottom always
position = "100";
visible = "always";
items = {
prompt = { priority = "-1"; };
prompt_empty = { priority = "-1"; };
# treated specially, this is the real input line.
input = { priority = "10"; };
};
};
# topicbar
topic = {
type = "root";
placement = "top";
position = "1";
visible = "always";
items = {
topicbarstart = { priority = "100"; };
topic = { };
topic_empty = { };
topicbarend = { priority = "100"; alignment = "right"; };
};
};
};
};
settings = {
core = {
real_name = "Michael Edwards";
user_name = "medwards";
nick = "medwards";
};
"fe-text" = { actlist_sort = "refnum"; };
"perl/core/scripts" = { splitlong_max_length = "300"; };
};
ignores = ( { level = "PARTS QUITS"; } );
logs = {
"~/irc.log.Window5" = {
level = "ALL";
items = ( { type = "window"; name = "5"; } );
};
};
# thanks to: http://blog.blindgaenger.net/colorize_maven_output.html
# and: http://johannes.jakeapp.com/blog/category/fun-with-linux/200901/maven-colorized
# Colorize Maven Output
alias maven="command mvn"
color_maven() {
maven $* | sed -e 's/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/^[[1;32mTests run: \1^[[0m, Failures: ^[[1;31m\2^[[0m, Errors: ^[[1;33m\3^[[0m, Skipped: ^[[1;34m\4^[[0m/g' \
-e 's/\(\[WARN\].*\)/^[[1;33m\1^[[0m/g' \
-e 's/\(WARN.*\)/^[[0;33m\1^[[0m/g' \
-e 's/\(\[INFO\].*\)/^[[1;32m\1^[[0m/g' \
-e 's/\(\[ERROR\].*\)/^[[1;31m\1^[[0m/g' \
-e 's/\(BUILD FAILURE.*\)/^[[1;31m\1^[[0m/g' \
-e 's/\(FAILURE!.*\)/^[[1;31m\1^[[0m/g' \
-e 's/\(BUILD SUCCESS.*\)/^[[1;37m\1^[[0m/g' \
-e 's/\(SUCCESS.*\)/^[[1;37m\1^[[0m/g'
}

TODOs for the TODO

  • setting up gnome panel correctly
  • irssi config
  • AWS stuff?
  • media keys still need to be disabled?
  • setup keys
  • full screen support in xmonad
  • watch for errors and actually nail them down this time
  1. Install debian-based distro
  2. apt-get install xmonad gnome-panel dconf-tools inotify-tools vim git-core gitk gitg ctags dmenu gmrun irssi
    Ubuntu will come with working XSession/Gnome-Session files, you just need the gnome-panel dependency
  3. Download John Yates config and copy to .xmonad/xmonad.hs
  4. in .xmonad/xmonad.hs comment out the keys in toRemove and toAdd (except for "don't strand naive users")
    in toAdd add ((modMask x .|. shiftMask, xK_l ), spawn "gnome-screensaver-command -l"), ((modMask x .|. shiftMask, xK_p ), spawn "gmrun")
  5. Fix /usr/share/xsessions/gnome-flashback-xmonad.desktop and
  6. dconf-editor
    Disable media keys in org.gnome.settings-daemon.plugins.media-keys
  7. echo "set noswapfile" >> ~/.vimrc
  8. while inotifywait -e close_write -r . ; do $TEST_RUNNER; done
  9. git config --global user.name "Michael Edwards" && git config --global user.email "[email protected]" && git config --global core.editor vim && git config --global color.ui true && git config --global alias.stat 'status -sb'
  10. Gnome terminal: preferences -> turn off menu bar, profile preferences -> green on black text, tango colours
  11. ssh-keygen, post to github.com + AWS?
  12. Grab .bash_aliases from gist
  13. copy .irsssi_config to .irssi/config, place the notify script (see http://lewk.org/blog/tags/irssi ) and https://scripts.irssi.org/scripts/splitlong.pl in .irssi/scripts/autorun

Other .vimrc stuff: http://vim.wikia.com/wiki/Highlight_unwanted_spaces

highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

ctags stuff:

noremap <silent><Leader><C-]> <C-w><C-]><C-w>T

mkdir -p .vim/ftplugin then in .vim/ftplugin/python.vim

set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4

syntax on
filetype indent on
import XMonad
import XMonad.Config.Gnome
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Util.Run(spawnPipe)
import System.IO
import XMonad.Hooks.ManageHelpers
import qualified XMonad.StackSet as W
import Control.Monad
import Data.Monoid (All (All))
import qualified Data.Map as M
-- colors match Ubuntu Human theme and Gnome panels
selected = "'#fad184'"
background = "'#efebe7'"
foreground = "'#000000'"
-- height matches Ubuntu top Gnome panel
barHeight = "24"
-- font intended to match Ubuntu default application font
appFontXft = "'xft\
\:Sans\
\:pixelsize=14\
\:weight=regular\
\:width=semicondensed\
\:dpi=96\
\:hinting=true\
\:hintstyle=hintslight\
\:antialias=true\
\:rgba=rgb\
\:lcdfilter=lcdlight\
\'"
-- currently dzen2 compiled locally to get xft support
-- (-e prevents loss of title if naive user clicks on dzen2)
myDzenTitleBar =
"dzen2\
\ -ta l\
\ -x 400 -w 900 -y 0\
\ -e 'entertitle=uncollapse'\
\ -h " ++ barHeight ++ "\
\ -bg " ++ background ++ "\
\ -fg " ++ foreground ++ "\
\ -fn " ++ appFontXft
-- dmenu patched and compiled locally to add xft support
--myDmenuTitleBar =
-- "exec `dmenu_path | dmenu\
-- \ -p 'Run:'\
-- \ -i\
-- \ -bh " ++ barHeight ++ "\
-- \ -nb " ++ background ++ "\
-- \ -nf " ++ foreground ++ "\
-- \ -sb " ++ selected ++ "\
-- \ -fn " ++ appFontXft ++ "\
-- \`"
myDmenuTitleBar = "dmenu"
main = do
xmproc <- spawnPipe myDzenTitleBar
xmonad $ gnomeConfig
{ modMask = mod4Mask -- Rebind Mod to Windows key
-- , terminal = "cool-retro-term"
, logHook = myLogHookWithPP $ defaultPP
{ ppOutput = hPutStrLn xmproc
, ppOrder = take 1 . drop 2
}
, keys = myKeys
, handleEventHook = evHook
}
where
myLogHookWithPP :: PP -> X ()
myLogHookWithPP pp = do
ewmhDesktopsLogHook
dynamicLogWithPP pp
defKeys = keys defaultConfig
delKeys x = foldr M.delete (defKeys x) (toRemove x)
myKeys x = foldr (uncurry M.insert) (delKeys x) (toAdd x)
-- remove some of the default key bindings
toRemove x =
[ --(modMask x , xK_p ),
(modMask x .|. shiftMask, xK_q ) -- don't strand naive users
]
toAdd x =
[ --((modMask x , xK_p ), spawn myDmenuTitleBar)
((modMask x .|. shiftMask, xK_l ), spawn "gnome-screensaver-command -l"),
((modMask x .|. shiftMask, xK_p ), spawn "gmrun")
]
-- Helper functions to fullscreen the window
fullFloat, tileWin :: Window -> X ()
fullFloat w = windows $ W.float w r
where r = W.RationalRect 0 0 1 1
tileWin w = windows $ W.sink w
evHook :: Event -> X All
evHook (ClientMessageEvent _ _ _ dpy win typ dat) = do
state <- getAtom "_NET_WM_STATE"
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
isFull <- runQuery isFullscreen win
-- Constants for the _NET_WM_STATE protocol
let remove = 0
add = 1
toggle = 2
-- The ATOM property type for changeProperty
ptype = 4
action = head dat
when (typ == state && (fromIntegral fullsc) `elem` tail dat) $ do
when (action == add || (action == toggle && not isFull)) $ do
io $ changeProperty32 dpy win state ptype propModeReplace [fromIntegral fullsc]
fullFloat win
when (head dat == remove || (action == toggle && isFull)) $ do
io $ changeProperty32 dpy win state ptype propModeReplace []
tileWin win
-- It shouldn't be necessary for xmonad to do anything more with this event
return $ All False
evHook _ = return $ All True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment