1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-31 19:12:32 +01:00

aded new stuffs

This commit is contained in:
kojima
2001-02-09 16:05:49 +00:00
parent 05f2a74ef5
commit 543a46659b
3 changed files with 254 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ AC_INIT(src/WindowMaker.h)
AM_INIT_AUTOMAKE(WindowMaker, 0.63.1)
AM_INIT_AUTOMAKE(WindowMaker, 0.64.0)
AM_PROG_LIBTOOL

131
util/wdread.c Normal file
View File

@@ -0,0 +1,131 @@
/* wdread.c - read value from defaults database
*
* WindowMaker window manager
*
* Copyright (c) 1997, 1998 Alfredo K. Kojima
* (cowardly remade from wdwrite.c; by judas@hell on Jan 26 2001)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#define PROG_VERSION "wdread (Window Maker) 0.2"
/*
* WindowMaker defaults DB reader
*/
#include "../src/wconfig.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <proplist.h>
#include <pwd.h>
char *ProgName;
char*
gethomedir()
{
char *home = getenv("HOME");
struct passwd *user;
if (home)
return home;
user = getpwuid(getuid());
if (!user) {
perror(ProgName);
return "/";
}
if (!user->pw_dir) {
return "/";
} else {
return user->pw_dir;
}
}
void wAbort()
{
exit(0);
}
void help()
{
printf("Syntax:\n%s [OPTIONS] <domain> <option>\n", ProgName);
puts("");
puts(" --help display this help message");
puts(" --version output version information and exit");
exit(1);
}
int main(int argc, char **argv)
{
char path[256];
proplist_t key, value, dict;
char *gsdir;
int i;
ProgName = argv[0];
for (i = 1; i < argc; i++) {
if (strcmp("--help", argv[i])==0) {
help();
exit(0);
} else if (strcmp("--version", argv[i])==0) {
puts(PROG_VERSION);
exit(0);
}
}
if (argc<3) {
printf("%s: invalid argument format\n", ProgName);
printf("Try '%s --help' for more information\n", ProgName);
exit(1);
}
key = PLMakeString(argv[2]);
gsdir = getenv("GNUSTEP_USER_ROOT");
if (gsdir) {
strcpy(path, gsdir);
} else {
strcpy(path, gethomedir());
strcat(path, "/GNUstep");
}
strcat(path, "/");
strcat(path, DEFAULTS_DIR);
strcat(path, "/");
strcat(path, argv[1]);
if ((dict = PLGetProplistWithPath(path)) == NULL)
return 1; // bad domain
if ((value = PLGetDictionaryEntry(dict, key)) == NULL)
return 2; // bad key
printf("%s\n", PLGetString(value));
return 0;
}

122
util/wmchlocale.in Normal file
View File

@@ -0,0 +1,122 @@
#!/bin/sh
#
# Change locale-dependent settings of WindowMaker.
#
# v0.1 by judas@hell <tomka@oalevice.sk> on Jan 28 2001
#
#
PROGRAM=`basename $0`
VERSION="0.1"
if [ "x$GNUSTEP_USER_ROOT" == "x" ]; then
GSDIR="$HOME/GNUstep"
else
GSDIR="$GNUSTEP_USER_ROOT"
if [ ! -d "GSDIR" ]; then
echo "GNUSTEP_USER_ROOT variable does not contain path to valid directory..." >/dev/stderr
exit 1
fi
fi
GLOBALDIR="#pkgdatadir#"
LOCALDIR="$GSDIR/Library/WindowMaker"
help_msg() {
echo -e "\n"\
"$PROGRAM, v$VERSION by judas@hell\n"\
"Syntax:\n"\
" $PROGRAM [--auto] [--nodef] [<new-locale> | default]\n"\
"\n"\
"<new-locale> locale you want WindowMaker to move to (e.g. ja or default)\n"\
"--auto use current locale\n"\
"--nodef try to change only codings of fonts\n"
exit 0
}
if (( $# == 0 )); then
help_msg
fi
for i in $*; do
case $i in
--auto)
auto="YES";;
--nodef)
nodef="--nodef";;
*)
if [ -z "$new_locale" ]; then
new_locale="$i"
else
echo -e "\nUnrecognized command line argument, run without arguments to see help.\n"
exit 1
fi;;
esac
done
if [ "$new_locale" == "default" ]; then
new_locale=""
fi
if [ -n "$auto" ] && [ -z "$new_locale" ]; then
new_locale=$LANG
if [ -z "$new_locale" ]; then
new_locale="${LC_ALL%_*}"
fi
fi
if [ -z "$new_locale" ]; then
echo -e "\nNo locale is set, using default...\n" >/dev/stderr
elif ! (locale -a |grep "^$new_locale$" &>/dev/null); then
echo -e "\n"\
"Locale $new_locale currently set is not supported on your system...\n"\
"Check your LANG and LC_ALL variables or install your locale support\n"\
"\n" >/dev/stderr
exit 1
fi
echo -n "Setting Window Maker root menu... "
if [ -z "$new_locale" ] || [ "$new_locale" == "en" ]; then
menu_list="plmenu menu"
else
menu_list="plmenu.$new_locale menu.$new_locale plmenu menu"
fi
for new_menu in $menu_list; do
for wm_dir in $LOCALDIR $GLOBALDIR; do
if [ -f "$wm_dir/$new_menu" ]; then
if [ -n "$new_locale" ] && echo "$new_menu" |grep "menu.$new_locale" &>/dev/null; then
echo "success"
else
echo "fail (copying default)"
fi
if [ "${new_menu:0:4}" == "menu" ]; then # plain
echo "\"$wm_dir/$new_menu\"" >"$GSDIR/Defaults/WMRootMenu"
else # proplist
cp -f "$wm_dir/$new_menu" "$GSDIR/Defaults/WMRootMenu"
fi
any_found="YES"
break 2
fi
done
done
if [ -z "$any_found" ]; then
echo "fail (no menu found)"
fi
echo -n "Setting Window Maker fonts... "
if [ -z "$new_locale" ] || [ "$new_locale" == "en" ]; then
args="default $nodef"
else
args="--locale=$new_locale $nodef"
fi
if wsetfont "$args" &>/dev/null; then
echo "success"
else
echo -n "fail"
if wsetfont default &>/dev/null; then
echo " (setting default)"
else
echo " (totally)"
fi
fi