gorn.ch

Tobias Ebnöther's personal blog

Lock screen on osx with screensaver

This is mainly for myself because I search that snipped every time I set up a mac. I place it to /usr/local/bin/lock and then type lock in my shell (or LaunchBar) to fire the screensaver and lock the screen (locking needs to be turned on in the preferences).

#!/bin/bash
SCRS=`ps xcopid,command|grep ScreenSaverEng|cut -b1-5`
if [ -z "$SCRS" ]; then
  /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine
fi

To safe some energy I don't use the screensaver but let blank the screen after a while.

Related Entries:
NetNewsWire Lite vs Vienna memory usage
Living with Terminal.app
Fixing the delete key in Terminal.app
Nice screenrc and common keystokes
tail -f to growl
 Permalink

NetNewsWire Lite vs Vienna memory usage

Today I tried to optimize my memory usage a little since OS X is swapping a lot. I switched from Vienna to NetNewsWire about two months ago because Vienna used to crash a lot, what seems to be fixed now. I decided to test which one uses less memory and just use that.

Both clients are scanning the same ~100 feeds every 30mins. For the test I will mark every entry as read "one by one" (vie space key) and don't use the flag features etc. (not available in NetNewsWire Lite anyways). I started to monitore the memory usage like that:
echo "`date +%s`;`ps cux | egrep 'Vienna|NetNewsWire' |\
awk -v ORS=';' '{print $11 ";" $5 ";" $6}'`"

Soon I realized that output wouldn't be easy to plot, then I decided to write a little script and run it via launchd every 30s. Here is the code:

#!/bin/bash
echo -n "`date +%s`;"

for arg in "$@"; do
MEM=`ps cux | grep $arg | awk '{print $5 ";" $6 ";"}'`;
if [ -z $MEM ]; then
echo -n ";;";
else
echo -n $MEM
fi
done
Use it like that:
memory.sh NetNewsWire Vienna
After 24h of data collection I decided to stop the test and see the result. I like gnuplot to visualize my data so here is the setup:
set terminal png
set output rss_readers.png
set key top left box
set ytics 2.5
set grid y
set ylabel 'MB Memory'
unset xtics
set datafile separator ';'
plot "memorystats.txt" using ($3/1024) title 'NetNewsWire Lite' with lines,\
"memorystats.txt" using ($5/1024) title 'Vienna' with lines

And that's the Result:
Low High Average
NetNewsWire Lite 20.16 68.00 44.59
Vienna 22.96 68.35 41.28
Nearly the same memory usage.
As you can see the memory usage is nearly the same and both are slowly consuming more memory over the time (24h - some hours in hibernate).

Conclusion:
  • Missing data on the time axis (hibernate hours) sucks. I can probably do a little more tuning with gnuplot but didn't try to manipulate axes by now. [Give me a hint if you're good with gnuplot, I'd like to just skip those parts in the axis.]
  • Both RSS Readers are consuming nearly the same amount of memory, growing over time.
  • After having Vienna back for the first couple of hours I already decided to prefer it over NNW Lite. I regularly missed the search and flag functions.
Related Entries:
Nice screenrc and common keystokes
Living with Terminal.app
Fixing the delete key in Terminal.app
tail -f to growl
xchat on OSX / Command as alt
Comments (1)  Permalink

Living with Terminal.app

Ok. My Terminal.app escapade has a bit gone out of hand so I decided to make a new post with all settings I changed.

Open your Terminal.app preferences and set it to xterm (xterm-color doesn't work very well in most places).

Open the window settings and delete all Settings for page up / down, home, end and delete (with all modifier variations).
Now set it up like this:
Home:		   \033[~1
End: \033[~4

Shift + Home: scroll to start of buffer
Shift + End: scroll to end of buffer

Delete: \033[~3

Page Up: \033[~5
Page Down: \033[~6

Shift + Page Up: scroll to previous page in buffer
Shift + Page Down: scroll to next page in buffer

To get a nice behaviour on the shell now edit your ~/.inputrc like this:
# Be 8 bit clean.
set input-meta on
set output-meta on
set convert-meta off

# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert

# mappings for "page up" and "page down"
# to step to the beginning/end of the history
"\e[5~": beginning-of-history
"\e[6~": end-of-history

At last to get Shift+Page working with screen add the following lines to your ~/.screenrc:
termcapinfo xterm ti@:te@
defscrollback 1 #Will be handled localy

I learned a lot from this article but it was a bit imprecise concerning to the page up / down buttons and didn't provide the screenrc options. That's why I decided to make a new post.

Update:
To remove the scrollbar while not losing the buffer in your Terminal.app edit the following lines in your .term or .plist file:

<key>Scrollbar</key>
<string>NO</string>
Related Entries:
Fixing the delete key in Terminal.app
Nice screenrc and common keystokes
NetNewsWire Lite vs Vienna memory usage
tail -f to growl
xchat on OSX / Command as alt
Comments (5)  Permalink

Fixing the delete key in Terminal.app

Well it's quite annoying that the delete (forward-delete) key in default Apples Terminal.app doesn't work correctly but it is when SSHing to another machine. So here is my (quite bad) solution. I configure the Terminal.app to send "\033[3~" for delete. Then I add the following line to my ~/.inputrc:

"\e[3~": delete-char

When SSHing to another machine now the delete key may be broken. Just at the same line on that machine (that's why it is a quite bad solution but I just set my machines consequently to ^? / \e[3~ for backspace / delete).

A solution to nicely forward page up / down will follow as an update to this article.
Related Entries:
Living with Terminal.app
NetNewsWire Lite vs Vienna memory usage
Nice screenrc and common keystokes
tail -f to growl
xchat on OSX / Command as alt
 Permalink

Nice screenrc and common keystokes

I like to work with screen because I can easily switch between different virtual consoles and attach them somewhere else if needed. So here is how I setup my screenrc:

vbell off                  #Don't display the wuff wuff stuff
defutf8 on #Turn on UTF-8 by default
shelltitle "$ |bash" #Standard Shell title will be replaced by bash
caption always #I never use split view but like the caption
caption string "%{= wk}%w" #Show me all opened consoles with white on black

Add this to your .bashrc to get nice console names (usually the runnig programm):

export PROMPT_COMMAND='echo -ne "\ek\e\\"'

Here are the keystokes I use very often:

Create new console:        ^A c
Get to next console: ^A n
Go to last console: ^A a
Go to specific console: ^A <consolenumber>
Deattach screen: ^A d
Related Entries:
NetNewsWire Lite vs Vienna memory usage
Living with Terminal.app
Fixing the delete key in Terminal.app
tail -f to growl
xchat on OSX / Command as alt
Comments (1)  Permalink

tail -f to growl

What I'd like to do is to observe a file with growl (the apache error_log in my case). Getting inspired by this article I wrote a little script called tailf2growl just copy it to /usr/local/bin/tailf2growl or something:

#!/bin/sh
if [ -z "$1" ]; then
echo "Missing filename"
exit 1
fi

tail -n0 -F $1 | while read; do
echo $REPLY | growlnotify -a tailfgrowl -t $1;
done

The usage is simple as hell just do it like this:

tailf2growl /var/log/httpd/error_log 
Related Entries:
NetNewsWire Lite vs Vienna memory usage
Living with Terminal.app
Fixing the delete key in Terminal.app
Nice screenrc and common keystokes
xchat on OSX / Command as alt
Comments (3)  Permalink
1-6/6
Powered by Flux CMS