From: Nick Bowler Date: Sun, 1 Jun 2008 23:42:32 +0000 (-0400) Subject: Merge branch 'master' of atropos:.fvwm X-Git-Url: http://git.draconx.ca/gitweb/fvwmconf.git/commitdiff_plain/f0b5b8ca7eb9a95227c5946f5f7dbfce08b8ef73?hp=95fe4128ce64545a770629a54779de69570cce73 Merge branch 'master' of atropos:.fvwm Conflicts: scripts/mpdmenu.pl --- diff --git a/artemis/config b/artemis/config index 3e69f0c..c0849d9 100644 --- a/artemis/config +++ b/artemis/config @@ -3,10 +3,10 @@ Read common/bindings Read common/nickstheme # Bigger fonts must be set before including rootmenu -Style * Font 'xft:M+1P+IPAG:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' -Style * IconFont 'xft:M+1P+IPAG:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' -MenuStyle * Font 'xft:M+1P+IPAG:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' -MenuStyle * TitleFont 'xft:M+1P+IPAG:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +Style * Font 'xft:Meiryo Short:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +Style * IconFont 'xft:Meiryo Short:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +MenuStyle * Font 'xft:Meiryo Short:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +MenuStyle * TitleFont 'xft:Meiryo Short:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' Read artemis/rootmenu Read common/wallpaper diff --git a/common/bindings b/common/bindings index 4d0ce48..dd9f2e2 100644 --- a/common/bindings +++ b/common/bindings @@ -37,7 +37,8 @@ Mouse 4 T N Windowshade True Mouse 5 T N Windowshade False # Console -Key grave A C Exec exec $[TERMINAL] +Key grave A C Exec exec $[TERMINAL] +Key grave A CM Exec exec $[TERMINAL] -e zsh -f Key F3 A M Module FvwmConsole -terminal $[TERMINAL] Key F3 A M2 Module FvwmConsole -terminal $[TERMINAL] diff --git a/common/modifier b/common/modifier index c7b770d..cbb89b1 100644 --- a/common/modifier +++ b/common/modifier @@ -13,4 +13,4 @@ DestroyFunc Mod_M3Func AddToFunc Mod_M3Func + C Lower + D Maximize 100 0 - + M PipeRead '. $[FVWM_USERDIR]/scripts/resize.sh $[pointer.wx] $[pointer.wy] $[w.width] $[w.height]' + + M PipeRead 'exec $[FVWM_USERDIR]/scripts/resize.sh $[pointer.wx] $[pointer.wy] $[w.width] $[w.height]' diff --git a/common/nickstheme b/common/nickstheme index 817a5a0..25aaf77 100644 --- a/common/nickstheme +++ b/common/nickstheme @@ -54,19 +54,20 @@ Colorset 4 fg white, bg #567ea2 Style * ColorSet 1 Style * HilightColorSet 2 -# Fonts. Probably need to patch FVWM to support proper selection of Japanese -# fonts... -Style * Font 'xft:M+1P+IPAG:Bold:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' -Style * IconFont 'xft:M+1P+IPAG:Bold:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' -MenuStyle * Font 'xft:M+1P+IPAG:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' -MenuStyle * TitleFont 'xft:M+1P+IPAG:Bold:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +# "Meiryo Short" is a modified version of a font from Windows Vista. +# Previous configs used M+1P+IPAG with reasonable results. +# If FVWM supported multiple font selection, this would be nicer. +Style * Font 'xft:Meiryo Short:Bold:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +Style * IconFont 'xft:Meiryo Short:Bold:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +MenuStyle * Font 'xft:Meiryo Short:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +MenuStyle * TitleFont 'xft:Meiryo Short:Bold:size=8:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' MenuStyle * HilightBack, HilightTitleBack, Hilight3DOff MenuStyle * TrianglesSolid, TrianglesUseFore, TitleUnderlines1 MenuStyle * SeparatorsLong, BorderWidth 1 MenuStyle * ItemFormat "%.3s%.2|%2.4i%.5l%.5l%.5r%.5i%2.3>%1|" MenuStyle * MenuColorset 3, ActiveColorset 4, TitleColorset 8 -MenuStyle * VerticalTitleSpacing 3 2, VerticalItemSpacing 2 2 +MenuStyle * VerticalTitleSpacing 1 1, VerticalItemSpacing 1 2 # Buttons: menu iconify maximize --title-- shade close Mouse 1 1 N Menu MenuWindow diff --git a/common/wallpaper b/common/wallpaper index e96f33e..acd270f 100644 --- a/common/wallpaper +++ b/common/wallpaper @@ -15,7 +15,7 @@ DestroyFunc MakeMenuWallpaper AddToFunc MakeMenuWallpaper + I DestroyMenu recreate MenuWallpaper + I AddToMenu MenuWallpaper Wallpaper Title - + I PipeRead '. $[FVWM_USERDIR]/scripts/bgmenu.sh $[BGROOT] MenuWallpaper' + + I PipeRead 'exec $[FVWM_USERDIR]/scripts/bgmenu.zsh $[BGROOT] MenuWallpaper' DestroyFunc SetWallpaper AddToFunc SetWallpaper diff --git a/config b/config index 9a5a447..23c9f31 100644 --- a/config +++ b/config @@ -4,21 +4,33 @@ ImagePath $[FVWM_USERDIR]/icons:$[FVWM_USERDIR]/pixmaps DestroyFunc InitFunction DestroyFunc StartFunction DestroyFunc ExitFunction -SetEnv TERMINAL /home/nick/bin/urxvt.sh + +# Global environment +SetEnv TERMINAL $[HOME]/bin/urxvt.sh PipeRead 'echo SetEnv HOST `hostname`' +SetEnv MUSIC /home/music + +SetEnv XMODIFIERS '@im=uim' +SetEnv GTK_IM_MODULE 'uim' +SetEnv QT_IM_MODULE 'uim' + # Global Features Read global/multiscreen Read global/fullscreen Read global/windowmenu +Read global/appspecific # Machine-specific features -Read $[HOST]/config +PipeRead "[ -f '$[FVWM_USERDIR]/$[HOST]/config' ] \ + && echo Read $[HOST]/config \ + || echo Read default/config" # Virtual Desktops DesktopSize 6x1 EdgeThickness 1 -EdgeResistance 1 0 +EdgeResistance 1 +Style * EdgeMoveDelay 1, EdgeMoveResistance 0 EdgeScroll 0 0 ##### diff --git a/default b/default new file mode 120000 index 0000000..bb48baf --- /dev/null +++ b/default @@ -0,0 +1 @@ +atropos \ No newline at end of file diff --git a/finial/config b/finial/config new file mode 100644 index 0000000..1b32a61 --- /dev/null +++ b/finial/config @@ -0,0 +1,28 @@ +# Global definitions +SetEnv MUSIC /stuff/music + +# Import common features +Read common/bindings +Read common/nickstheme + +# Bigger fonts must be set before including rootmenu +Style * Font 'xft:Meiryo Short:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +Style * IconFont 'xft:Meiryo Short:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +MenuStyle * Font 'xft:Meiryo Short:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' +MenuStyle * TitleFont 'xft:Meiryo Short:Bold:size=9:minspace=true:rgba=rgb:antialias=true:encoding=iso10646-1' + +Read finial/rootmenu +Read common/wallpaper +Read common/panels +Read common/modifier + +# Bindings for the modifier key +Mouse 1 WFT 4 Mod_M1Func +Mouse 2 WFT 4 Mod_M2Func +Mouse 3 WFT 4 Mod_M3Func +Mouse 1 WFT 42 Mod_M1Func +Mouse 2 WFT 42 Mod_M2Func +Mouse 3 WFT 42 Mod_M3Func + +# Struts for the pager. +EwmhBaseStruts 0 0 0 42 diff --git a/finial/rootmenu b/finial/rootmenu new file mode 100644 index 0000000..6d13d18 --- /dev/null +++ b/finial/rootmenu @@ -0,0 +1,43 @@ +MenuStyle * !TitleWarp + +CopyMenuStyle * MenuMPD +MenuStyle MenuMPD ItemFormat "%.2|%3.5l%.5l%2.3>%-65.5r%.5i%1|" + +DestroyMenu MenuFvwmRoot +AddToMenu MenuFvwmRoot ++ DynamicPopupAction MakeMenuFvwmRoot + +DestroyFunc MakeMenuFvwmRoot +AddToFunc MakeMenuFvwmRoot ++ I DestroyMenu recreate MenuFvwmRoot ++ I PipeRead 'echo AddToMenu MenuFvwmRoot "$USER@`hostname`" Title' ++ I AddToMenu MenuFvwmRoot "Terminal%terminal.svg:16x16%" Exec exec $[TERMINAL] ++ I AddToMenu MenuFvwmRoot "Firefox%firefox.png%" Exec exec firefox ++ I PipeRead "xlsclients -a | grep ' gmpc$' >/dev/null || echo\ + AddToMenu MenuFvwmRoot 'GMPC%gmpc.png%' Exec exec gmpc" ++ I AddToMenu MenuFvwmRoot "" Nop ++ I AddToMenu MenuFvwmRoot "Network%network.svg:16x16%" Popup MenuNetwork ++ I AddToMenu MenuFvwmRoot "" Nop ++ I AddToMenu MenuFvwmRoot "Wallpaper%wallpaper.svg:16x16%" Popup MenuWallpaper ++ I AddToMenu MenuFvwmRoot "Music%music.svg:16x16%" Popup MenuMPD ++ I AddToMenu MenuFvwmRoot "" Nop ++ I AddToMenu MenuFvwmRoot "Restart FVWM%reload.svg:16x16%" Restart ++ I AddToMenu MenuFvwmRoot "Exit FVWM%logout.svg:16x16%"\ + Module FvwmForm FvwmForm-QuitVerify + +DestroyMenu MenuNetwork +AddToMenu MenuNetwork ++ "Pan Newsreader%pan.png%" Exec exec env LC_ALL=en_CA.UTF-8 pan + +DestroyMenu MenuMPD +AddToMenu MenuMPD ++ DynamicPopUpAction MakeMenuMPD ++ DynamicPopDownAction KillMenuMPD +ChangeMenuStyle MenuMPD MenuMPD + +DestroyFunc MakeMenuMPD +AddToFunc MakeMenuMPD ++ I DestroyMenu recreate MenuMPD ++ I PipeRead "exec $[FVWM_USERDIR]/scripts/mpdmenu.pl --menu MenuMPD" + +Mouse 3 R A Menu MenuFvwmRoot diff --git a/global/appspecific b/global/appspecific new file mode 100644 index 0000000..c96079b --- /dev/null +++ b/global/appspecific @@ -0,0 +1 @@ +Style "Guild Wars" StaysOnTop diff --git a/global/fullscreen b/global/fullscreen index 42df857..deb5e41 100644 --- a/global/fullscreen +++ b/global/fullscreen @@ -1,4 +1,4 @@ -Key F10 W A DoFullScreen +Key F10 W C DoFullScreen DestroyFunc Fullscreen AddToFunc FullScreen diff --git a/scripts/C/Makefile b/scripts/C/Makefile index 5d61541..ee422c6 100644 --- a/scripts/C/Makefile +++ b/scripts/C/Makefile @@ -1,10 +1,12 @@ -CFLAGS = -O2 -Wall -Wextra -Wno-sign-compare +CFLAGS = -O2 -Wall -Wextra -Wno-sign-compare -Wno-missing-field-initializers LDFLAGS = -CC = c89 +CC = c99 LD = $(CC) all: xaspect +clean: + rm -f *.o xaspect .c.o: $(CC) -c -o $@ $(CFLAGS) $< diff --git a/scripts/C/xaspect.c b/scripts/C/xaspect.c index 0dbc83d..3e07caa 100644 --- a/scripts/C/xaspect.c +++ b/scripts/C/xaspect.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #define MKASPECT(w, h) { (double)w/h, #w ":" #h } @@ -13,7 +14,7 @@ static struct aspect { } aspects[] = { MKASPECT(16, 10), MKASPECT(16, 9), - MKASPECT(8, 5), + MKASPECT(8, 3), MKASPECT(5, 4), MKASPECT(4, 3) }; @@ -57,17 +58,38 @@ char *testaspect(xcb_screen_t *screen) return best; } +struct options { + char *displayname; + int showdimensions; +} *parseoptions(int argc, char **argv) +{ + static struct options opts = { 0 }; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + if (++i < argc) { + opts.displayname = argv[i]; + continue; + } + fprintf(stderr, "-display requires an argument\n"); + } else if (strcmp(argv[i], "-dimensions") == 0) { + opts.showdimensions = 1; + } + } + + return &opts; +} + int main(int argc, char **argv) { xcb_connection_t *display; xcb_screen_t *screen; - char *dpynam = NULL; int screen_num; - if (argc > 2 && strcmp(argv[1], "-display") == 0) - dpynam = argv[2]; + struct options *opts = parseoptions(argc, argv); - display = xcb_connect(dpynam, &screen_num); + display = xcb_connect(opts->displayname, &screen_num); if (xcb_connection_has_error(display)) { fprintf(stderr, "Failed to open display.\n"); xcb_disconnect(display); @@ -81,6 +103,10 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + if (opts->showdimensions) { + printf("%" PRIu16 "x%" PRIu16 "-", + screen->width_in_pixels, screen->height_in_pixels); + } printf("%s\n", testaspect(screen)); xcb_disconnect(display); diff --git a/scripts/bgmenu.sh b/scripts/bgmenu.zsh similarity index 82% rename from scripts/bgmenu.sh rename to scripts/bgmenu.zsh index ec6ae8f..f6ac8ef 100755 --- a/scripts/bgmenu.sh +++ b/scripts/bgmenu.zsh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/zsh # Generates an FVWM menu for selecting the PNG images found in a given # directory. Thumbnails for the images are generated on the fly using convert # from ImageMagick, and stored in the .thumbs subdirectory. The menu items @@ -6,7 +6,7 @@ menu="MenuWallpaper" func="SetWallpaper" -thumber="$HOME/.fvwm/scripts/thumbnail.sh" +thumber="$FVWM_USERDIR/scripts/thumbnail.zsh" if [ ! -d "$1" ]; then echo "usage: $0 [menuname]" 1>&2 @@ -14,7 +14,7 @@ if [ ! -d "$1" ]; then fi [ -n "$2" ] && menu="$2" -for i in "$1"/*.png; do +for i in "$1"/*$($FVWM_USERDIR/scripts/C/xaspect).png; do thumb="`$thumber --size x160 "$i"`" echo "AddToMenu $menu \"`basename "${i%.png}"`*$thumb*\" $func \"$i\"" done diff --git a/scripts/mpdmenu.pl b/scripts/mpdmenu.pl index 4639211..ebd4c31 100755 --- a/scripts/mpdmenu.pl +++ b/scripts/mpdmenu.pl @@ -3,7 +3,7 @@ use strict; use Getopt::Long; -use IO::Socket; +use IO::Socket::INET6; use constant { MPD_MJR_MIN => 0, @@ -46,7 +46,7 @@ $artist = decode_utf8($artist) if defined($artist); $title = decode_utf8($title) if defined($title);; # Connect to MPD. -my $sock = new IO::Socket::INET( +my $sock = new IO::Socket::INET6( PeerAddr => $host, PeerPort => $port, Proto => 'tcp' @@ -138,11 +138,11 @@ if (defined $album) { my $key = $_; my $a_album = sanitise($key); - open THUMB, "-|", "$FVWM/scripts/thumbnail.sh", + open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh", "--small", "--music", $albums{$key}; my $thumb = ; close THUMB; - die("Incompetent use of thumbnail.sh") if ($?); + die("Incompetent use of thumbnail.zsh") if ($?); $thumb =~ s/\n//sg; $thumb = "%$thumb%" if (-f $thumb); @@ -234,11 +234,11 @@ if (defined $album) { $t_artist = sanitise($t_artist); $t_title = sanitise($t_title); - open THUMB, "-|", "$FVWM/scripts/thumbnail.sh", + open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh", "--small", "--music", $t_file; my $thumb = ; close(THUMB); - die("Incompetent use of thumbnail.sh") if ($?); + die("Incompetent use of thumbnail.zsh") if ($?); $thumb =~ s/\n//sg; $thumb = "%$thumb%" if (-f $thumb); @@ -281,7 +281,7 @@ if (defined $album) { } die("Failed data query\n") unless (keys(%entry) > 0); - open THUMB, "-|", "$FVWM/scripts/thumbnail.sh", + open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh", "--image", "--music", $entry{file}; my $thumb = ; my $scan = ; diff --git a/scripts/randombg.pl b/scripts/randombg.pl new file mode 100755 index 0000000..941ebe7 --- /dev/null +++ b/scripts/randombg.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; + +my $FVWM = (defined $ENV{FVWM_USERDIR}) ? $ENV{FVWM_USERDIR} + : $ENV{HOME}."/.fvwm"; + +die ("usage: randombg.pl ") if (! -d $ARGV[0]); + +open XASPECT, "-|", "$FVWM/scripts/C/xaspect", "-dimensions"; +my $aspect = ; +close XASPECT; +die ("Incompetent use of xaspect") if ($?); + +$aspect =~ s/(^\s*)|(\s*$)//g; + +opendir WALLPAPER, $ARGV[0]; +my @dir = grep(/\Q$aspect\E\.png$/, readdir WALLPAPER); +closedir WALLPAPER; + +print $ARGV[0] . "/" . $dir[int(rand(@dir))] . "\n"; diff --git a/scripts/thumbnail.sh b/scripts/thumbnail.sh deleted file mode 100755 index 958092c..0000000 --- a/scripts/thumbnail.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -music=/home/music -thumbs="$HOME/.fvwm/.thumbs" - -if [ ! -d "$thumbs" ]; then - mkdir "$thumbs" || exit 1 -fi - -size="x128" -printimg="" -ismusic="" - -while [ "${1#--}" != "$1" -a "$1" != "-" ]; do - if [ "$1" = "--small" ]; then - size="56" - elif [ "$1" = "--size" ]; then - size="$2" - shift - elif [ "$1" = "--music" ]; then - ismusic="yes" - elif [ "$1" = "--image" ]; then - printimg="yes" - else - echo "unrecognised option: $1" 1>&2 - exit 1 - fi - shift -done -[ "$1" = "-" ] && shift - -if ! expr match "$size" '^\([0-9]*\(x[0-9]\+\)\?\)$' &>/dev/null; then - echo "invalid size specification: $size" 1>&2 - exit 1 -fi - -if [ -z "$1" ]; then - echo "usage: thumbnail.sh [--small|--size ] [--image] [--music] path" 1>&2 - exit 1 -fi - -if [ -n "$ismusic" ]; then - path="$music/`dirname "${1#$music}"`/cover.jpg" - [ ! -f "$path" ] && path="${path%jpg}png" -else - path="$1" -fi - -[ ! -f "$path" ] && exit 0 - -image="`readlink -f -- "$path"`" -[ ! -f "$image" ] && exit 0 - -thumb="$thumbs/`echo -n $image | md5sum - | cut -d ' ' -f 1`_$size.png" -if [ -f "$thumb" ]; then - mtime_s="`stat -c %Y -- "$image"`" - mtime_t="`stat -c %Y -- "$thumb"`" - if [ "$mtime_s" -gt "$mtime_t" ]; then - convert -scale "$size" "$image" "$thumb" - fi -else - convert -scale "$size" "$image" "$thumb" -fi - -echo "$thumb" -[ -n "$printimg" ] && echo "$image" -exit 0 diff --git a/scripts/thumbnail.zsh b/scripts/thumbnail.zsh new file mode 100755 index 0000000..62294b6 --- /dev/null +++ b/scripts/thumbnail.zsh @@ -0,0 +1,70 @@ +#!/bin/zsh + +if [[ -z "$MUSIC" ]]; then + MUSIC=/home/music +fi + +thumbs="$HOME/.fvwm/.thumbs" + +if ! [[ -d "$thumbs" ]]; then + mkdir "$thumbs" || exit 1 +fi + +size="x128" +printimg="" +ismusic="" + +while [[ "${1#--}" != "$1" && "$1" != "-" ]]; do + if [[ "$1" == "--small" ]]; then + size="56" + elif [[ "$1" == "--size" ]]; then + size="$2" + shift + elif [[ "$1" = "--music" ]]; then + ismusic="yes" + elif [[ "$1" = "--image" ]]; then + printimg="yes" + else + echo "unrecognised option: $1" 1>&2 + exit 1 + fi + shift +done +[ "$1" = "-" ] && shift + +if ! [[ "$size" =~ '^([0-9]*(x[0-9]+)?)$' ]]; then + echo "invalid size specification: $size" 1>&2 + exit 1 +fi + +if [[ -z "$1" ]]; then + echo "usage: thumbnail.zsh [--small|--size ] [--image] [--music] path" 1>&2 + exit 1 +fi + +if [[ -n "$ismusic" ]]; then + imgpath="$MUSIC/$(dirname "${1#$MUSIC}")/cover.jpg" + [[ ! -f "$imgpath" ]] && imgpath="${imgpath%jpg}png" +else + imgpath="$1" +fi + +[[ ! -f "$imgpath" ]] && exit 0 + +image="$(readlink -f -- "$imgpath")" +[[ ! -f "$image" ]] && exit 0 + +thumb="$thumbs/$(echo -n $image | md5sum - | cut -d ' ' -f 1)_$size.png" +if [[ -f "$thumb" ]]; then + mtime_s="$(stat -c %Y -- "$image")" + mtime_t="$(stat -c %Y -- "$thumb")" + if [ "$mtime_s" -gt "$mtime_t" ]; then + convert -scale "$size" "$image" "$thumb" + fi +else + convert -scale "$size" "$image" "$thumb" +fi + +echo "$thumb" +[ -n "$printimg" ] && echo "$image" +exit 0