Difference between revisions of "Xmonad/Config archive/leedo's xmonad.hs"
< Xmonad | Config archive
Jump to navigation
Jump to search
m |
|||
Line 1: | Line 1: | ||
+ | ==xmonad.hs == |
||
<haskell>-- xmonad.hs |
<haskell>-- xmonad.hs |
||
import XMonad |
import XMonad |
||
Line 41: | Line 42: | ||
, ((modm, xK_a), sendMessage MirrorExpand) |
, ((modm, xK_a), sendMessage MirrorExpand) |
||
, ((modm, xK_g), withFocused toggleBorder) ] |
, ((modm, xK_g), withFocused toggleBorder) ] |
||
+ | </haskell> |
||
+ | |||
+ | ==.Xsession == |
||
+ | <haskell> |
||
+ | xrandr -s 0 |
||
+ | xrdb $HOME/.Xresources |
||
+ | xsetroot -cursor_name left_ptr |
||
+ | xsetroot -solid '#a9badd' |
||
+ | |||
+ | FG='#a9badd' |
||
+ | BG='#324c80' |
||
+ | $HOME/bin/xmonad-clock | dzen2 -e '' -x 400 -w 880 -ta r -fg $FG -bg $BG -fn '-misc-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*' & |
||
+ | |||
+ | $HOME/bin/xmonad |
||
+ | |||
+ | wait $! |
||
+ | pkill -HUP dzen2 |
||
+ | wait |
||
+ | </haskell> |
||
+ | |||
+ | ==xmonad-clock == |
||
+ | <haskell> |
||
+ | #!/usr/bin/perl |
||
+ | |||
+ | use warnings; |
||
+ | |||
+ | use DateTime; |
||
+ | use LWP::UserAgent; |
||
+ | |||
+ | |||
+ | $|--; |
||
+ | my $ua = LWP::UserAgent->new; |
||
+ | my $tz = DateTime::Duration->new(hours => 6); |
||
+ | my @format = qw/playing inbox datetime/; |
||
+ | |||
+ | while (1) { |
||
+ | print build_bar(); |
||
+ | sleep 60; |
||
+ | } |
||
+ | |||
+ | sub build_bar { |
||
+ | return join(" │ ", map { &$_} @format) . " \n"; |
||
+ | } |
||
+ | |||
+ | sub datetime { |
||
+ | my $dt = DateTime->now - $tz; |
||
+ | return sprintf("%s %02d:%02d",$dt->dmy, $dt->hour, $dt->minute); |
||
+ | } |
||
+ | |||
+ | sub inbox { |
||
+ | if (my $res = $ua->get('http://manimal.prettybrd.com/~leedo/inbox')) { |
||
+ | return "INBOX(".$res->content.")"; |
||
+ | } |
||
+ | else { |
||
+ | return "mail error"; |
||
+ | } |
||
+ | } |
||
+ | |||
+ | sub playing { |
||
+ | if (chomp( my $song = `rhythmbox-client --no-start --print-playing`)) { |
||
+ | return $song; |
||
+ | } |
||
+ | else { |
||
+ | return "Not playing"; |
||
+ | } |
||
+ | } |
||
</haskell> |
</haskell> |
Revision as of 01:51, 13 January 2008
xmonad.hs
-- xmonad.hs
import XMonad
import XMonad.Operations
import XMonad.Layout
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
import XMonad.Actions.NoBorders
import XMonad.Config
import XMonad.Hooks.DynamicLog
import XMonad.Util.Run
import System.IO
import qualified Data.Map as M
import Data.Ratio ((%))
statusBarCmd= "dzen2 -bg '#324c80' -fg '#adbadd' -e '' -ta l -w 400 -fn '-misc-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*'"
rb_pause = "rhythmbox-client --no-start --play-pause"
rb_volup = "rhythmbox-client --no-start --volume-up"
rb_voldown = "rhythmbox-client --no-start --volume-down"
main = do din <- spawnPipe statusBarCmd
xmonad $ defaultConfig
{ borderWidth = 2
, defaultGaps = [(16,0,0,0)]
, modMask = mod4Mask
, normalBorderColor = "#cccccc"
, layoutHook = resizetall ||| Mirror resizetall ||| noBorders Full
, focusedBorderColor = "#cd8b00"
, terminal = "urxvt"
, logHook = dynamicLogWithPP $ dzenPP
{ ppOutput = hPutStrLn din }
, keys = \c -> mykeys c `M.union` keys defaultConfig c
}
where
resizetall = ResizableTall 1 (3/100) (1/2) []
mykeys (XConfig {modMask = modm}) = M.fromList $
[ ((modm .|. shiftMask, xK_p), spawn rb_pause)
, ((modm .|. shiftMask, xK_equal), spawn rb_volup)
, ((modm .|. shiftMask, xK_minus), spawn rb_voldown)
, ((modm, xK_z), sendMessage MirrorShrink)
, ((modm, xK_a), sendMessage MirrorExpand)
, ((modm, xK_g), withFocused toggleBorder) ]
.Xsession
xrandr -s 0
xrdb $HOME/.Xresources
xsetroot -cursor_name left_ptr
xsetroot -solid '#a9badd'
FG='#a9badd'
BG='#324c80'
$HOME/bin/xmonad-clock | dzen2 -e '' -x 400 -w 880 -ta r -fg $FG -bg $BG -fn '-misc-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*' &
$HOME/bin/xmonad
wait $!
pkill -HUP dzen2
wait
xmonad-clock
#!/usr/bin/perl
use warnings;
use DateTime;
use LWP::UserAgent;
$|--;
my $ua = LWP::UserAgent->new;
my $tz = DateTime::Duration->new(hours => 6);
my @format = qw/playing inbox datetime/;
while (1) {
print build_bar();
sleep 60;
}
sub build_bar {
return join(" │ ", map { &$_} @format) . " \n";
}
sub datetime {
my $dt = DateTime->now - $tz;
return sprintf("%s %02d:%02d",$dt->dmy, $dt->hour, $dt->minute);
}
sub inbox {
if (my $res = $ua->get('http://manimal.prettybrd.com/~leedo/inbox')) {
return "INBOX(".$res->content.")";
}
else {
return "mail error";
}
}
sub playing {
if (chomp( my $song = `rhythmbox-client --no-start --print-playing`)) {
return $song;
}
else {
return "Not playing";
}
}