change config

This commit is contained in:
zcake 2021-01-01 21:27:39 +08:00
parent f0536f98f3
commit 111b8b730e
11 changed files with 19 additions and 83 deletions

View File

@ -16,9 +16,9 @@ HAVE_GIFLIB = 1
HAVE_LIBEXIF = 1
cflags = -std=c99 -Wall -pedantic $(CFLAGS)
cppflags = -I. $(CPPFLAGS) -D_XOPEN_SOURCE=700 \
cppflags = -I. $(CPPFLAGS) -D_XOPEN_SOURCE=700 \
-DHAVE_GIFLIB=$(HAVE_GIFLIB) -DHAVE_LIBEXIF=$(HAVE_LIBEXIF) \
-I/usr/include/freetype2 -I$(PREFIX)/include/freetype2
-I/usr/include/freetype2 -I$(PREFIX)/include/freetype2 -DVN=\"${PREFIX}\" -DVERSION=\"${version}\"
lib_exif_0 =
lib_exif_1 = -lexif
@ -42,7 +42,6 @@ sxiv: $(objs)
$(CC) $(LDFLAGS) -o $@ $(objs) $(ldlibs)
$(objs): Makefile sxiv.h commands.lst config.h
options.o: version.h
.c.o:
@echo "CC $@"
@ -52,21 +51,16 @@ config.h:
@echo "GEN $@"
cp $(srcdir)/config.def.h $@
version.h: Makefile .git/index
@echo "GEN $@"
v="$$(cd $(srcdir); git describe 2>/dev/null)"; \
echo "#define VERSION \"$${v:-$(version)}\"" >$@
.git/index:
clean:
rm -f *.o sxiv
install: all
@echo "INSTALL bin/sxiv"
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp sxiv-key /usr/local/bin/
chmod 755 /usr/local/bin/sxiv-key
cp sxiv-key $(DESTDIR)$(PREFIX)/bin/
chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv-key
cp sxiv-bar $(DESTDIR)$(PREFIX)/bin/
chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv-bar
cp sxiv $(DESTDIR)$(PREFIX)/bin/
chmod 755 $(DESTDIR)$(PREFIX)/bin/sxiv
@echo "INSTALL sxiv.1"
@ -76,8 +70,6 @@ install: all
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1
@echo "INSTALL share/sxiv/"
mkdir -p $(DESTDIR)$(PREFIX)/share/sxiv/exec
cp exec/* $(DESTDIR)$(PREFIX)/share/sxiv/exec/
chmod 755 $(DESTDIR)$(PREFIX)/share/sxiv/exec/*
cp sxiv.desktop /usr/share/applications
uninstall:
rm -rf /usr/local/bin/sxiv-key

View File

@ -1,20 +0,0 @@
#!/bin/sh
# Example for $XDG_CONFIG_HOME/sxiv/exec/image-info
# Called by sxiv(1) whenever an image gets loaded.
# The output is displayed in sxiv's status bar.
# Arguments:
# $1: path to image file
# $2: image width
# $3: image height
s=" " # field separator
exec 2>/dev/null
filename=$(basename -- "$1")
filesize=$(du -Hh -- "$1" | cut -f 1)
geometry="${2}x${3}"
echo "${filesize}${s}${geometry}${s}${filename}"

View File

@ -1,35 +0,0 @@
#!/bin/sh
# Example for $XDG_CONFIG_HOME/sxiv/exec/key-handler
# Called by sxiv(1) after the external prefix key (C-x by default) is pressed.
# The next key combo is passed as its first argument. Passed via stdin are the
# images to act upon, one path per line: all marked images, if in thumbnail
# mode and at least one image has been marked, otherwise the current image.
# sxiv(1) blocks until this script terminates. It then checks which images
# have been modified and reloads them.
# The key combo argument has the following form: "[C-][M-][S-]KEY",
# where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X
# keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix.
rotate() {
degree="$1"
tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read file; do
case "$(file -b -i "$file")" in
image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;;
*) mogrify -rotate "$degree" "$file" ;;
esac
done
}
case "$1" in
"C-x") xclip -in -filter | tr '\n' ' ' | xclip -in -selection clipboard ;;
"C-c") while read file; do xclip -selection clipboard -target image/png "$file"; done ;;
"C-e") while read file; do urxvt -bg "#444" -fg "#eee" -sl 0 -title "$file" -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;;
"C-g") tr '\n' '\0' | xargs -0 gimp & ;;
"C-r") while read file; do rawtherapee "$file" & done ;;
"C-comma") rotate 270 ;;
"C-period") rotate 90 ;;
"C-slash") rotate 180 ;;
esac

7
main.c
View File

@ -345,7 +345,7 @@ void bar_put(win_bar_t *bar, const char *fmt, ...)
va_end(ap);
}
#define BAR_SEP " "
#define BAR_SEP " | "
void update_info(void)
{
@ -388,7 +388,6 @@ void update_info(void)
strncpy(l->buf, files[fileidx].name, l->size);
}
}
int ptr_third_x(void)
{
int x, y;
@ -912,12 +911,12 @@ int main(int argc, char **argv)
}
if (homedir != NULL) {
extcmd_t *cmd[] = { &info.f, &keyhandler.f };
const char *name[] = { "image-info", "key-handler" };
const char *name[] = { "sxiv-bar", "sxiv-key" };
for (i = 0; i < ARRLEN(cmd); i++) {
n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12;
cmd[i]->cmd = (char*) emalloc(n);
snprintf(cmd[i]->cmd, n, "/usr/local/bin/sxiv-key", homedir, dsuffix, name[i]);
snprintf(cmd[i]->cmd, n, VN"/bin/%s", name[i]);
if (access(cmd[i]->cmd, X_OK) != 0)
cmd[i]->err = errno;
}

BIN
main.o

Binary file not shown.

View File

@ -19,7 +19,6 @@
#include "sxiv.h"
#define _IMAGE_CONFIG
#include "config.h"
#include "version.h"
#include <stdlib.h>
#include <string.h>

BIN
sxiv

Binary file not shown.

10
sxiv-bar Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
export LANG=C.UTF-8
s=" | "
mediainfo "$1"|grep Format|awk -F: '{ print $2 }'|sed 's/ //g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;1q'>~/p
fileformat=$(cat ~/p)
filename=$(basename -- "$1")
filesize=$(du -Hh -- "$1" | cut -f 1)
geometry="${2}x${3}"
echo "1:$1,2:$2,3:$3,4:$4,5:$5,6:$6,7:$7,8:$8,9:$9,10:$10" > ~/u
echo "${filename}${s}${filesize}${s}${geometry}${s}${fileformat}"

View File

@ -1 +0,0 @@
#define VERSION "26"

View File

@ -92,9 +92,6 @@ void win_init(win_t *win)
{
win_env_t *e;
const char *bg, *fbg, *fg, *f;
char *res_man;
XrmDatabase db;
memset(win, 0, sizeof(win_t));
e = &win->env;
@ -111,10 +108,6 @@ void win_init(win_t *win)
if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0)
error(0, 0, "No locale support");
XrmInitialize();
res_man = XResourceManagerString(e->dpy);
db = res_man != NULL ? XrmGetStringDatabase(res_man) : None;
f = win_res(NULL, RES_CLASS ".font", "FiraCode Nerd Font-8");
win_init_font(e, f);
@ -148,7 +141,6 @@ void win_open(win_t *win)
long parent;
win_env_t *e;
XClassHint classhint;
unsigned long *icon_data;
XColor col;
Cursor *cnone = &cursors[CURSOR_NONE].icon;
char none_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

BIN
window.o

Binary file not shown.