From 3b852e0f10892789210fd8e3fdd8415faf3cf2d8 Mon Sep 17 00:00:00 2001 From: stkhan Date: Sun, 17 Oct 2021 18:43:19 -0500 Subject: 3.0 --- PKGBUILD | 55 - README.md | 15 +- bin/brighter | 4 - bin/darker | 7 - bin/fehbg | 3 - bin/fs | 2 - bin/mute | 4 - bin/picom_run | 3 - bin/rs | 4 - bin/sarc_compile | 43 - bin/sarc_install | 25 - bin/surf_run | 3 - bin/update-grub | 3 - bin/vol_down | 4 - bin/vol_up | 5 - build.sh | 30 + dmenu-5.0/config.def.h | 11 - dmenu-5.0/config.def.h.orig | 31 + dmenu-5.0/config.h | 9 - dmenu-5.0/config.mk | 2 +- dmenu-5.0/dmenu | Bin 43792 -> 43416 bytes dmenu-5.0/dmenu-alpha-20210605-1a13d04.diff | 267 +++ dmenu-5.0/dmenu.1 | 24 - dmenu-5.0/dmenu.c | 83 +- dmenu-5.0/dmenu.c.orig | 821 ++++++++ dmenu-5.0/dmenu.o | Bin 34104 -> 32096 bytes dmenu-5.0/dmenu_run | 2 +- dmenu-5.0/drw.c | 26 +- dmenu-5.0/drw.c.orig | 438 ++++ dmenu-5.0/drw.h | 9 +- dmenu-5.0/drw.h.orig | 60 + dmenu-5.0/drw.o | Bin 10600 -> 10584 bytes .../patches/dmenu-alpha-20210605-1a13d04.diff | 267 --- dmenu-5.0/patches/dmenu-border-4.9.diff | 25 - dmenu-5.0/patches/dmenu-xyw-5.0.diff | 116 -- dmenu-5.0/stest | Bin 17096 -> 17080 bytes dwm-6.2/Makefile | 1 + dwm-6.2/TODO | 1 - dwm-6.2/autostart.h | 8 - dwm-6.2/colors.h | 40 + dwm-6.2/config.def.h | 90 +- dwm-6.2/config.h | 112 +- dwm-6.2/config.mk | 2 +- dwm-6.2/drw.c | 27 +- dwm-6.2/drw.h | 9 +- dwm-6.2/drw.o | Bin 0 -> 10528 bytes dwm-6.2/dwm | Bin 0 -> 80352 bytes dwm-6.2/dwm.c | 264 +-- dwm-6.2/dwm.o | Bin 0 -> 72496 bytes dwm-6.2/keys.h | 1 - dwm-6.2/patches/dwm-attachabove-6.2-20200421.diff | 60 - dwm-6.2/patches/dwm-centerfirstwindow-6.2.diff | 67 - dwm-6.2/patches/dwm-fixborders-6.2.diff | 27 - dwm-6.2/patches/dwm-scratchpad-6.2.diff | 90 - dwm-6.2/patches/dwm-vanitygaps-20190508-6.2.diff | 259 --- dwm-6.2/patches/dwm-vanitygaps-6.2.diff | 971 +++++++++ dwm-6.2/patches/sarc-autostart.diff | 179 -- dwm-6.2/util.o | Bin 0 -> 2256 bytes dwm-6.2/vanitygaps.c | 809 ++++++++ dwm-6.2/wmbar | 9 + dwmblocks/.gitignore | 56 - dwmblocks/LICENSE | 7 - dwmblocks/Makefile | 17 - dwmblocks/README.md | 15 - dwmblocks/blocks.def.h | 11 - dwmblocks/dwmblocks.c | 213 -- etc/.xinitrc | 1 - etc/clean | 9 - etc/ns.conf | 15 - etc/screenshots/blue.png | Bin 2343625 -> 0 bytes etc/screenshots/green.png | Bin 2250037 -> 0 bytes etc/screenshots/red.png | Bin 1707338 -> 0 bytes etc/wallpaper/blend.wallpaper.jpg | Bin 2345506 -> 0 bytes etc/wallpaper/blue.wallpaper.jpg | Bin 3000322 -> 0 bytes etc/wallpaper/default.wallpaper.jpg | Bin 1069893 -> 0 bytes etc/wallpaper/dracula.wallpaper.jpg | Bin 348137 -> 0 bytes etc/wallpaper/green.wallpaper.jpg | Bin 2806111 -> 0 bytes etc/wallpaper/liquid_blue.wallpaper.jpg | Bin 1772524 -> 0 bytes etc/wallpaper/liquid_red.wallpaper.jpg | Bin 2525535 -> 0 bytes etc/wallpaper/nord.wallpaper.jpg | Bin 1124827 -> 0 bytes etc/wallpaper/purple.wallpaper.jpg | Bin 1570213 -> 0 bytes etc/wallpaper/red.wallpaper.jpg | Bin 1744142 -> 0 bytes install.sh | 14 + scripts/brighter | 4 + scripts/darker | 7 + scripts/fehbg | 1 + scripts/mic_toggle | 3 + scripts/mute | 4 + scripts/rs | 4 + scripts/screenshot | 6 + scripts/vol_down | 4 + scripts/vol_up | 5 + st-0.8.4/config.h | 2 +- st-0.8.4/patches/st-rightclickpaste-0.8.2.diff | 28 + .../st-scrollback-mouse-increment-0.8.2.diff | 34 + st-0.8.4/st | Bin 0 -> 106440 bytes st-0.8.4/st.o | Bin 0 -> 77144 bytes st-0.8.4/x.o | Bin 0 -> 75712 bytes surf-2.1/LICENSE | 48 - surf-2.1/Makefile | 76 - surf-2.1/README | 40 - surf-2.1/TODO.md | 10 - surf-2.1/arg.h | 48 - surf-2.1/common.h | 1 - surf-2.1/config.def.h | 207 -- surf-2.1/config.def.h.orig | 194 -- surf-2.1/config.h | 208 -- surf-2.1/config.mk | 32 - surf-2.1/surf | Bin 71936 -> 0 bytes surf-2.1/surf-0.7-webkit2-searchengines.diff | 63 - surf-2.1/surf-2.0-homepage.diff | 24 - surf-2.1/surf-bookmarks-20170722-723ff26.diff | 42 - surf-2.1/surf-cachedir-20200831-2188894.diff | 36 - surf-2.1/surf-open.sh | 32 - surf-2.1/surf.1 | 305 --- surf-2.1/surf.c | 2141 -------------------- surf-2.1/surf.c.orig | 2137 ------------------- surf-2.1/surf.o | Bin 70864 -> 0 bytes surf-2.1/surf.png | Bin 240 -> 0 bytes surf-2.1/webext-surf.c | 106 - surf-2.1/webext-surf.o | Bin 4272 -> 0 bytes surf-2.1/webext-surf.so | Bin 16568 -> 0 bytes tabbed-0.6/LICENSE | 23 - tabbed-0.6/Makefile | 60 - tabbed-0.6/README | 22 - tabbed-0.6/TODO | 4 - tabbed-0.6/arg.h | 52 - tabbed-0.6/config.def.h | 58 - tabbed-0.6/config.h | 58 - tabbed-0.6/config.mk | 25 - tabbed-0.6/config.old | 58 - tabbed-0.6/tabbed | Bin 36664 -> 0 bytes tabbed-0.6/tabbed.1 | 144 -- tabbed-0.6/tabbed.c | 1297 ------------ tabbed-0.6/tabbed.o | Bin 48024 -> 0 bytes theme/blue/blue.png | Bin 0 -> 3000322 bytes theme/blue/colors.h | 51 + theme/dracula/colors.h | 53 + theme/dracula/dracula.png | Bin 0 -> 348137 bytes theme/green/colors.h | 50 + theme/green/green.png | Bin 0 -> 2806111 bytes theme/purple/colors.h | 51 + theme/purple/purple.png | Bin 0 -> 1570213 bytes theme/purple_mountain/colors.h | 40 + theme/purple_mountain/purple_mountain.png | Bin 0 -> 4401519 bytes theme/purple_mountain/screenshot.png | Bin 0 -> 2603 bytes theme/red/colors.h | 50 + theme/red/red.png | Bin 0 -> 1744142 bytes themes/blend | 39 - themes/blue | 51 - themes/default | 50 - themes/dracula | 53 - themes/green | 50 - themes/liquid_blue | 44 - themes/nord | 54 - themes/purple | 51 - themes/red | 50 - tools/sarc-1.0.2.tar.xz | Bin 16721920 -> 0 bytes 158 files changed, 4049 insertions(+), 10126 deletions(-) delete mode 100644 PKGBUILD delete mode 100755 bin/brighter delete mode 100755 bin/darker delete mode 100755 bin/fehbg delete mode 100755 bin/fs delete mode 100755 bin/mute delete mode 100755 bin/picom_run delete mode 100755 bin/rs delete mode 100755 bin/sarc_compile delete mode 100755 bin/sarc_install delete mode 100755 bin/surf_run delete mode 100755 bin/update-grub delete mode 100755 bin/vol_down delete mode 100755 bin/vol_up create mode 100755 build.sh create mode 100644 dmenu-5.0/config.def.h.orig create mode 100644 dmenu-5.0/dmenu-alpha-20210605-1a13d04.diff create mode 100644 dmenu-5.0/dmenu.c.orig create mode 100644 dmenu-5.0/drw.c.orig create mode 100644 dmenu-5.0/drw.h.orig delete mode 100644 dmenu-5.0/patches/dmenu-alpha-20210605-1a13d04.diff delete mode 100644 dmenu-5.0/patches/dmenu-border-4.9.diff delete mode 100644 dmenu-5.0/patches/dmenu-xyw-5.0.diff delete mode 100644 dwm-6.2/TODO delete mode 100644 dwm-6.2/autostart.h create mode 100644 dwm-6.2/colors.h create mode 100644 dwm-6.2/drw.o create mode 100755 dwm-6.2/dwm create mode 100644 dwm-6.2/dwm.o delete mode 100644 dwm-6.2/keys.h delete mode 100644 dwm-6.2/patches/dwm-attachabove-6.2-20200421.diff delete mode 100644 dwm-6.2/patches/dwm-centerfirstwindow-6.2.diff delete mode 100644 dwm-6.2/patches/dwm-fixborders-6.2.diff delete mode 100644 dwm-6.2/patches/dwm-scratchpad-6.2.diff delete mode 100644 dwm-6.2/patches/dwm-vanitygaps-20190508-6.2.diff create mode 100644 dwm-6.2/patches/dwm-vanitygaps-6.2.diff delete mode 100644 dwm-6.2/patches/sarc-autostart.diff create mode 100644 dwm-6.2/util.o create mode 100644 dwm-6.2/vanitygaps.c create mode 100755 dwm-6.2/wmbar delete mode 100644 dwmblocks/.gitignore delete mode 100644 dwmblocks/LICENSE delete mode 100644 dwmblocks/Makefile delete mode 100644 dwmblocks/README.md delete mode 100644 dwmblocks/blocks.def.h delete mode 100644 dwmblocks/dwmblocks.c delete mode 100644 etc/.xinitrc delete mode 100755 etc/clean delete mode 100644 etc/ns.conf delete mode 100644 etc/screenshots/blue.png delete mode 100644 etc/screenshots/green.png delete mode 100644 etc/screenshots/red.png delete mode 100644 etc/wallpaper/blend.wallpaper.jpg delete mode 100644 etc/wallpaper/blue.wallpaper.jpg delete mode 100644 etc/wallpaper/default.wallpaper.jpg delete mode 100644 etc/wallpaper/dracula.wallpaper.jpg delete mode 100644 etc/wallpaper/green.wallpaper.jpg delete mode 100644 etc/wallpaper/liquid_blue.wallpaper.jpg delete mode 100644 etc/wallpaper/liquid_red.wallpaper.jpg delete mode 100644 etc/wallpaper/nord.wallpaper.jpg delete mode 100644 etc/wallpaper/purple.wallpaper.jpg delete mode 100644 etc/wallpaper/red.wallpaper.jpg create mode 100755 install.sh create mode 100755 scripts/brighter create mode 100755 scripts/darker create mode 100755 scripts/fehbg create mode 100755 scripts/mic_toggle create mode 100755 scripts/mute create mode 100755 scripts/rs create mode 100755 scripts/screenshot create mode 100755 scripts/vol_down create mode 100755 scripts/vol_up create mode 100644 st-0.8.4/patches/st-rightclickpaste-0.8.2.diff create mode 100644 st-0.8.4/patches/st-scrollback-mouse-increment-0.8.2.diff create mode 100755 st-0.8.4/st create mode 100644 st-0.8.4/st.o create mode 100644 st-0.8.4/x.o delete mode 100644 surf-2.1/LICENSE delete mode 100644 surf-2.1/Makefile delete mode 100644 surf-2.1/README delete mode 100644 surf-2.1/TODO.md delete mode 100644 surf-2.1/arg.h delete mode 100644 surf-2.1/common.h delete mode 100644 surf-2.1/config.def.h delete mode 100644 surf-2.1/config.def.h.orig delete mode 100644 surf-2.1/config.h delete mode 100644 surf-2.1/config.mk delete mode 100755 surf-2.1/surf delete mode 100644 surf-2.1/surf-0.7-webkit2-searchengines.diff delete mode 100644 surf-2.1/surf-2.0-homepage.diff delete mode 100644 surf-2.1/surf-bookmarks-20170722-723ff26.diff delete mode 100644 surf-2.1/surf-cachedir-20200831-2188894.diff delete mode 100755 surf-2.1/surf-open.sh delete mode 100644 surf-2.1/surf.1 delete mode 100644 surf-2.1/surf.c delete mode 100644 surf-2.1/surf.c.orig delete mode 100644 surf-2.1/surf.o delete mode 100644 surf-2.1/surf.png delete mode 100644 surf-2.1/webext-surf.c delete mode 100644 surf-2.1/webext-surf.o delete mode 100755 surf-2.1/webext-surf.so delete mode 100644 tabbed-0.6/LICENSE delete mode 100644 tabbed-0.6/Makefile delete mode 100644 tabbed-0.6/README delete mode 100644 tabbed-0.6/TODO delete mode 100644 tabbed-0.6/arg.h delete mode 100644 tabbed-0.6/config.def.h delete mode 100644 tabbed-0.6/config.h delete mode 100644 tabbed-0.6/config.mk delete mode 100644 tabbed-0.6/config.old delete mode 100755 tabbed-0.6/tabbed delete mode 100644 tabbed-0.6/tabbed.1 delete mode 100644 tabbed-0.6/tabbed.c delete mode 100644 tabbed-0.6/tabbed.o create mode 100644 theme/blue/blue.png create mode 100644 theme/blue/colors.h create mode 100644 theme/dracula/colors.h create mode 100644 theme/dracula/dracula.png create mode 100644 theme/green/colors.h create mode 100644 theme/green/green.png create mode 100644 theme/purple/colors.h create mode 100644 theme/purple/purple.png create mode 100644 theme/purple_mountain/colors.h create mode 100644 theme/purple_mountain/purple_mountain.png create mode 100644 theme/purple_mountain/screenshot.png create mode 100644 theme/red/colors.h create mode 100644 theme/red/red.png delete mode 100644 themes/blend delete mode 100644 themes/blue delete mode 100644 themes/default delete mode 100644 themes/dracula delete mode 100644 themes/green delete mode 100644 themes/liquid_blue delete mode 100644 themes/nord delete mode 100644 themes/purple delete mode 100644 themes/red delete mode 100644 tools/sarc-1.0.2.tar.xz diff --git a/PKGBUILD b/PKGBUILD deleted file mode 100644 index eed4384..0000000 --- a/PKGBUILD +++ /dev/null @@ -1,55 +0,0 @@ -# Maintainer: SkywalkerSW5 -pkgname=sarc -pkgver=1.0.2 -pkgrel=1 -pkgdesc="My suckless setup" -arch=('any') -url="https://github.com/SkywalkerSW5/sarc" -license=('MIT') -depends=('adobe-source-code-pro-fonts' 'libnotify' 'dunst' 'picom' 'light' 'feh' 'xorg-server' 'sx' 'pulseaudio') -provides=('dwm' 'st' 'vim' 'dmenu') -source=("https://github.com/SkywalkerSW5/sarc/raw/master/tools/$pkgname-$pkgver.tar.xz") -#source=("$pkgname-$pkgver.tar.xz") -md5sums=("82511c740baba46bd8c4ebac40f39b67") - -build() { - - cd dwm-6.2 - make clean - make - cd ../st-0.8.4 - make - cd ../dmenu-5.0 - make - cd ../dwmblocks - make - cd .. -} - - -package() { - - cd dwm-6.2 - make PREFIX=/usr DESTDIR="$pkgdir" install - cd ../st-0.8.4 - make PREFIX=/usr DESTDIR="$pkgdir" install - cd ../dmenu-5.0 - make PREFIX=/usr DESTDIR="$pkgdir" install - cd ../dwmblocks - make PREFIX=/usr DESTDIR="$pkgdir" install - cd ../etc/wallpaper/ - ls - pwd - mkdir $pkgdir/etc - cp blue.wallpaper.jpg $pkgdir/etc/ - cd ../../bin - mkdir -p "$pkgdir/usr/local/bin" - cp * "$pkgdir/usr/local/bin" - cd .. - cp $srcdir/etc/wallpaper/blue.wallpaper.jpg $pkgdir/etc/wallpaper.jpg - mkdir -p "$pkgdir/usr/src/sarc" - cp -r $srcdir/* "$pkgdir/usr/src/sarc/" - echo - echo "Run ss to start sarc" -} - diff --git a/README.md b/README.md index df622bd..88a5aa3 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,14 @@ -# sarc +# sarc 3.0 - - - + ## About -This is the setup I use on Linux. I use my own versions of dwm, dmenu, dwmblocks, and st. +My patches dwm, st, dmenu, and more ## Installation -### Arch (or Arch based distros) - ``` -wget https://raw.githubusercontent.com/SkywalkerSW5/sarc/master/PKGBUILD -makepkg -si +git clone https://github.com/SkywalkerSW5/sarc +./build.sh +sudo ./install.sh ``` diff --git a/bin/brighter b/bin/brighter deleted file mode 100755 index b495a84..0000000 --- a/bin/brighter +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - - -sudo light -A 6 diff --git a/bin/darker b/bin/darker deleted file mode 100755 index f7530e7..0000000 --- a/bin/darker +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# -# A script that lowers and ups the brightness -# - -sudo light -U 6 diff --git a/bin/fehbg b/bin/fehbg deleted file mode 100755 index 71860f0..0000000 --- a/bin/fehbg +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -feh --bg-fill /etc/wallpaper.jpg diff --git a/bin/fs b/bin/fs deleted file mode 100755 index 4790a90..0000000 --- a/bin/fs +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -du -h $@ diff --git a/bin/mute b/bin/mute deleted file mode 100755 index 7941e5d..0000000 --- a/bin/mute +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -pactl set-sink-mute @DEFAULT_SINK@ toggle & -dunstify "Toggled mute" & diff --git a/bin/picom_run b/bin/picom_run deleted file mode 100755 index e2fb4d7..0000000 --- a/bin/picom_run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# This script will have more options later on -picom --experimental-backends diff --git a/bin/rs b/bin/rs deleted file mode 100755 index f8f1468..0000000 --- a/bin/rs +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# A script to start sarc -sx dwm -# That's it diff --git a/bin/sarc_compile b/bin/sarc_compile deleted file mode 100755 index ebbc0f0..0000000 --- a/bin/sarc_compile +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# A script to compile sarc - -dwm="dwm-6.2" -st="st" -dmenu="dmenu-5.0" - -echo "Welcome to the sarc installation!" -echo - -echo "What theme do you want to use?" -echo -ls themes/ -echo -echo "Enter what theme you would like to use:" && read theme -echo -echo "Theme is $theme" -echo -echo $theme >> /tmp/theme -pwd - -cp themes/$theme theme.h - -cd $dwm -make clean -make -s - -cd ../dwmblocks -make clean -make -s - -cd ../st-0.8.4 -make clean -make -s - -cd ../$dmenu -make clean -make -s - -cd .. - -cp etc/wallpaper/$theme.wallpaper.jpg ./wallpaper.jpg -echo "Compilation is complete! Run sarc_install to install it" diff --git a/bin/sarc_install b/bin/sarc_install deleted file mode 100755 index 7c2ec3e..0000000 --- a/bin/sarc_install +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# A script that installs sarc. Run this as root - -dwm="dwm-6.2" -dmenu="dmenu-5.0" -st="st" - -cd $dwm -make install - -cd ../$dmenu -make install - -cd ../st-0.8.4 -make install - -cd ../dwmblocks -make install - -cd .. -cp bin/* /usr/local/bin -cp wallpaper.jpg /etc/wallpaper.jpg - -rm theme.h -rm wallpaper.jpg diff --git a/bin/surf_run b/bin/surf_run deleted file mode 100755 index 29c7b02..0000000 --- a/bin/surf_run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -tabbed surf -e diff --git a/bin/update-grub b/bin/update-grub deleted file mode 100755 index 0c43327..0000000 --- a/bin/update-grub +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -set -e -exec grub-mkconfig -o /boot/grub/grub.cfg "$@" diff --git a/bin/vol_down b/bin/vol_down deleted file mode 100755 index 9a01c42..0000000 --- a/bin/vol_down +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -pactl set-sink-volume @DEFAULT_SINK@ -5% & -dunstify "Turned the volume down 5%" diff --git a/bin/vol_up b/bin/vol_up deleted file mode 100755 index 5107cd5..0000000 --- a/bin/vol_up +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -pactl set-sink-volume @DEFAULT_SINK@ +5% & -dunstify "Turned the volume up +5" & - diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b9962c4 --- /dev/null +++ b/build.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# A script to build sarc + +# Sets theme configuration +# To see available themes, do "ls theme/" + +echo "Welcome to the sarc installation!" +echo +echo "Choose a theme:" && ls theme/ +read theme + +cp theme/$theme/colors.h dwm-6.2/ +cp theme/$theme/$theme.png $HOME/.config/wallpaper.png + +# Compiles dwm, st, etc + +cd dwm-6.2 +make clean +make + +cd ../st-0.8.4/ +make clean +make + +cd ../dmenu-5.0/ +make clean +make +cd ../ + + diff --git a/dmenu-5.0/config.def.h b/dmenu-5.0/config.def.h index 2fd7347..1edb647 100644 --- a/dmenu-5.0/config.def.h +++ b/dmenu-5.0/config.def.h @@ -2,7 +2,6 @@ /* Default settings; can be overriden by command line. */ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -static const unsigned int alpha = 0xf0; /* -fn option overrides fonts[0]; default X11 font or font set */ static const char *fonts[] = { "monospace:size=10" @@ -14,13 +13,6 @@ static const char *colors[SchemeLast][2] = { [SchemeSel] = { "#eeeeee", "#005577" }, [SchemeOut] = { "#000000", "#00ffff" }, }; - -static const unsigned int alphas[SchemeLast][2] = { - [SchemeNorm] = { OPAQUE, alpha }, - [SchemeSel] = { OPAQUE, alpha }, - [SchemeOut] = { OPAQUE, alpha }, -}; - /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ static unsigned int lines = 0; @@ -29,6 +21,3 @@ static unsigned int lines = 0; * for example: " /?\"&[]" */ static const char worddelimiters[] = " "; - -/* Size of the window border */ -static const unsigned int border_width = 5; diff --git a/dmenu-5.0/config.def.h.orig b/dmenu-5.0/config.def.h.orig new file mode 100644 index 0000000..697d511 --- /dev/null +++ b/dmenu-5.0/config.def.h.orig @@ -0,0 +1,31 @@ +/* See LICENSE file for copyright and license details. */ +/* Default settings; can be overriden by command line. */ + +static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ +static const unsigned int alpha = 0xf0; +/* -fn option overrides fonts[0]; default X11 font or font set */ +static const char *fonts[] = { + "monospace:size=10" +}; +static const char *prompt = NULL; /* -p option; prompt to the left of input field */ +static const char *colors[SchemeLast][2] = { + /* fg bg */ + [SchemeNorm] = { "#bbbbbb", "#222222" }, + [SchemeSel] = { "#eeeeee", "#005577" }, + [SchemeOut] = { "#000000", "#00ffff" }, +}; + +static const unsigned int alphas[SchemeLast][2] = { + [SchemeNorm] = { OPAQUE, alpha }, + [SchemeSel] = { OPAQUE, alpha }, + [SchemeOut] = { OPAQUE, alpha }, +}; + +/* -l option; if nonzero, dmenu uses vertical list with given number of lines */ +static unsigned int lines = 0; + +/* + * Characters not considered part of a word while deleting words + * for example: " /?\"&[]" + */ +static const char worddelimiters[] = " "; diff --git a/dmenu-5.0/config.h b/dmenu-5.0/config.h index 1b90822..1edb647 100644 --- a/dmenu-5.0/config.h +++ b/dmenu-5.0/config.h @@ -2,7 +2,6 @@ /* Default settings; can be overriden by command line. */ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -static const unsigned int alpha = 0xf0; /* -fn option overrides fonts[0]; default X11 font or font set */ static const char *fonts[] = { "monospace:size=10" @@ -14,13 +13,6 @@ static const char *colors[SchemeLast][2] = { [SchemeSel] = { "#eeeeee", "#005577" }, [SchemeOut] = { "#000000", "#00ffff" }, }; - -static const unsigned int alphas[SchemeLast][2] = { - [SchemeNorm] = { OPAQUE, alpha }, - [SchemeSel] = { OPAQUE, alpha }, - [SchemeOut] = { OPAQUE, alpha }, -}; - /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ static unsigned int lines = 0; @@ -29,4 +21,3 @@ static unsigned int lines = 0; * for example: " /?\"&[]" */ static const char worddelimiters[] = " "; -static unsigned int border_width = 3; diff --git a/dmenu-5.0/config.mk b/dmenu-5.0/config.mk index 46e980b..05d5a3e 100644 --- a/dmenu-5.0/config.mk +++ b/dmenu-5.0/config.mk @@ -20,7 +20,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I$(X11INC) -I$(FREETYPEINC) -LIBS = -lXrender -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) +LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS) diff --git a/dmenu-5.0/dmenu b/dmenu-5.0/dmenu index 1fcb65c..3ceec6c 100755 Binary files a/dmenu-5.0/dmenu and b/dmenu-5.0/dmenu differ diff --git a/dmenu-5.0/dmenu-alpha-20210605-1a13d04.diff b/dmenu-5.0/dmenu-alpha-20210605-1a13d04.diff new file mode 100644 index 0000000..51679f7 --- /dev/null +++ b/dmenu-5.0/dmenu-alpha-20210605-1a13d04.diff @@ -0,0 +1,267 @@ +diff --git a/config.def.h b/config.def.h +index 1edb647..697d511 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,7 @@ + /* Default settings; can be overriden by command line. */ + + static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ ++static const unsigned int alpha = 0xf0; + /* -fn option overrides fonts[0]; default X11 font or font set */ + static const char *fonts[] = { + "monospace:size=10" +@@ -13,6 +14,13 @@ static const char *colors[SchemeLast][2] = { + [SchemeSel] = { "#eeeeee", "#005577" }, + [SchemeOut] = { "#000000", "#00ffff" }, + }; ++ ++static const unsigned int alphas[SchemeLast][2] = { ++ [SchemeNorm] = { OPAQUE, alpha }, ++ [SchemeSel] = { OPAQUE, alpha }, ++ [SchemeOut] = { OPAQUE, alpha }, ++}; ++ + /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ + static unsigned int lines = 0; + +diff --git a/dmenu.c b/dmenu.c +index 65f25ce..3e56e1a 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -10,6 +10,7 @@ + + #include + #include ++#include + #include + #ifdef XINERAMA + #include +@@ -25,6 +26,8 @@ + #define LENGTH(X) (sizeof X / sizeof X[0]) + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) + ++#define OPAQUE 0xffU ++ + /* enums */ + enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ + +@@ -53,10 +56,16 @@ static XIC xic; + static Drw *drw; + static Clr *scheme[SchemeLast]; + ++static int useargb = 0; ++static Visual *visual; ++static int depth; ++static Colormap cmap; ++ + #include "config.h" + + static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; + static char *(*fstrstr)(const char *, const char *) = strstr; ++static void xinitvisual(); + + static void + appenditem(struct item *item, struct item **list, struct item **last) +@@ -602,7 +611,7 @@ setup(void) + #endif + /* init appearance */ + for (j = 0; j < SchemeLast; j++) +- scheme[j] = drw_scm_create(drw, colors[j], 2); ++ scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2); + + clip = XInternAtom(dpy, "CLIPBOARD", False); + utf8 = XInternAtom(dpy, "UTF8_STRING", False); +@@ -640,6 +649,7 @@ setup(void) + x = info[i].x_org; + y = info[i].y_org + (topbar ? 0 : info[i].height - mh); + mw = info[i].width; ++ + XFree(info); + } else + #endif +@@ -657,11 +667,13 @@ setup(void) + + /* create menu window */ + swa.override_redirect = True; +- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; ++ swa.background_pixel = 0; ++ swa.border_pixel = 0; ++ swa.colormap = cmap; + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; +- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, +- CopyFromParent, CopyFromParent, CopyFromParent, +- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); ++ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, ++ depth, CopyFromParent, visual, ++ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa); + XSetClassHint(dpy, win, &ch); + + +@@ -747,7 +759,8 @@ main(int argc, char *argv[]) + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); +- drw = drw_create(dpy, screen, root, wa.width, wa.height); ++ xinitvisual(); ++ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); + if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) + die("no fonts could be loaded."); + lrpad = drw->fonts->h; +@@ -769,3 +782,40 @@ main(int argc, char *argv[]) + + return 1; /* unreachable */ + } ++ ++ void ++xinitvisual() ++{ ++ XVisualInfo *infos; ++ XRenderPictFormat *fmt; ++ int nitems; ++ int i; ++ ++ XVisualInfo tpl = { ++ .screen = screen, ++ .depth = 32, ++ .class = TrueColor ++ }; ++ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; ++ ++ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); ++ visual = NULL; ++ for(i = 0; i < nitems; i ++) { ++ fmt = XRenderFindVisualFormat(dpy, infos[i].visual); ++ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { ++ visual = infos[i].visual; ++ depth = infos[i].depth; ++ cmap = XCreateColormap(dpy, root, visual, AllocNone); ++ useargb = 1; ++ break; ++ } ++ } ++ ++ XFree(infos); ++ ++ if (! visual) { ++ visual = DefaultVisual(dpy, screen); ++ depth = DefaultDepth(dpy, screen); ++ cmap = DefaultColormap(dpy, screen); ++ } ++} +diff --git a/drw.c b/drw.c +index 4cdbcbe..fe3aadd 100644 +--- a/drw.c ++++ b/drw.c +@@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen) + } + + Drw * +-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) ++drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) + { + Drw *drw = ecalloc(1, sizeof(Drw)); + +@@ -70,8 +70,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h + drw->root = root; + drw->w = w; + drw->h = h; +- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); +- drw->gc = XCreateGC(dpy, root, 0, NULL); ++ drw->visual = visual; ++ drw->depth = depth; ++ drw->cmap = cmap; ++ drw->drawable = XCreatePixmap(dpy, root, w, h, depth); ++ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); + XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); + + return drw; +@@ -87,7 +90,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) + drw->h = h; + if (drw->drawable) + XFreePixmap(drw->dpy, drw->drawable); +- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); ++ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); + } + + void +@@ -194,21 +197,22 @@ drw_fontset_free(Fnt *font) + } + + void +-drw_clr_create(Drw *drw, Clr *dest, const char *clrname) ++drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha) + { + if (!drw || !dest || !clrname) + return; + +- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), +- DefaultColormap(drw->dpy, drw->screen), ++ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, + clrname, dest)) + die("error, cannot allocate color '%s'", clrname); ++ ++ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); + } + + /* Wrapper to create color schemes. The caller has to call free(3) on the + * returned color scheme when done using it. */ + Clr * +-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) ++drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) + { + size_t i; + Clr *ret; +@@ -218,7 +222,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) + return NULL; + + for (i = 0; i < clrcount; i++) +- drw_clr_create(drw, &ret[i], clrnames[i]); ++ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); + return ret; + } + +@@ -274,9 +278,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp + } else { + XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); +- d = XftDrawCreate(drw->dpy, drw->drawable, +- DefaultVisual(drw->dpy, drw->screen), +- DefaultColormap(drw->dpy, drw->screen)); ++ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); + x += lpad; + w -= lpad; + } +diff --git a/drw.h b/drw.h +index 4c67419..f6fa5cd 100644 +--- a/drw.h ++++ b/drw.h +@@ -20,6 +20,9 @@ typedef struct { + Display *dpy; + int screen; + Window root; ++ Visual *visual; ++ unsigned int depth; ++ Colormap cmap; + Drawable drawable; + GC gc; + Clr *scheme; +@@ -27,7 +30,7 @@ typedef struct { + } Drw; + + /* Drawable abstraction */ +-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); ++Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap); + void drw_resize(Drw *drw, unsigned int w, unsigned int h); + void drw_free(Drw *drw); + +@@ -38,8 +41,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text); + void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); + + /* Colorscheme abstraction */ +-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); ++void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); ++Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); + + /* Cursor abstraction */ + Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dmenu-5.0/dmenu.1 b/dmenu-5.0/dmenu.1 index a4ecbbb..323f93c 100644 --- a/dmenu-5.0/dmenu.1 +++ b/dmenu-5.0/dmenu.1 @@ -8,12 +8,6 @@ dmenu \- dynamic menu .IR lines ] .RB [ \-m .IR monitor ] -.RB [ \-x -.IR xoffset ] -.RB [ \-y -.IR yoffset ] -.RB [ \-z -.IR width ] .RB [ \-p .IR prompt ] .RB [ \-fn @@ -60,24 +54,6 @@ dmenu lists items vertically, with the given number of lines. dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. .TP -.BI \-x " xoffset" -dmenu is placed at this offset measured from the left side of the monitor. -Can be negative. -If option -.B \-m -is present, the measurement will use the given monitor. -.TP -.BI \-y " yoffset" -dmenu is placed at this offset measured from the top of the monitor. If the -.B \-b -option is used, the offset is measured from the bottom. Can be negative. -If option -.B \-m -is present, the measurement will use the given monitor. -.TP -.BI \-z " width" -sets the width of the dmenu window. -.TP .BI \-p " prompt" defines the prompt to be displayed to the left of the input field. .TP diff --git a/dmenu-5.0/dmenu.c b/dmenu-5.0/dmenu.c index 018b382..65f25ce 100644 --- a/dmenu-5.0/dmenu.c +++ b/dmenu-5.0/dmenu.c @@ -10,7 +10,6 @@ #include #include -#include #include #ifdef XINERAMA #include @@ -26,8 +25,6 @@ #define LENGTH(X) (sizeof X / sizeof X[0]) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -#define OPAQUE 0xffU - /* enums */ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ @@ -40,9 +37,6 @@ struct item { static char text[BUFSIZ] = ""; static char *embed; static int bh, mw, mh; -static int dmx = 0; /* put dmenu at this x offset */ -static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */ -static unsigned int dmw = 0; /* make dmenu this wide */ static int inputw = 0, promptw; static int lrpad; /* sum of left and right padding */ static size_t cursor; @@ -59,16 +53,10 @@ static XIC xic; static Drw *drw; static Clr *scheme[SchemeLast]; -static int useargb = 0; -static Visual *visual; -static int depth; -static Colormap cmap; - #include "config.h" static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; static char *(*fstrstr)(const char *, const char *) = strstr; -static void xinitvisual(); static void appenditem(struct item *item, struct item **list, struct item **last) @@ -614,7 +602,7 @@ setup(void) #endif /* init appearance */ for (j = 0; j < SchemeLast; j++) - scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2); + scheme[j] = drw_scm_create(drw, colors[j], 2); clip = XInternAtom(dpy, "CLIPBOARD", False); utf8 = XInternAtom(dpy, "UTF8_STRING", False); @@ -649,9 +637,9 @@ setup(void) if (INTERSECT(x, y, 1, 1, info[i])) break; - x = info[i].x_org + dmx; - y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy); - mw = (dmw>0 ? dmw : info[i].width); + x = info[i].x_org; + y = info[i].y_org + (topbar ? 0 : info[i].height - mh); + mw = info[i].width; XFree(info); } else #endif @@ -659,9 +647,9 @@ setup(void) if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); - x = dmx; - y = topbar ? dmy : wa.height - mh - dmy; - mw = (dmw>0 ? dmw : wa.width); + x = 0; + y = topbar ? 0 : wa.height - mh; + mw = wa.width; } promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; inputw = MIN(inputw, mw/3); @@ -669,13 +657,11 @@ setup(void) /* create menu window */ swa.override_redirect = True; - swa.background_pixel = 0; - swa.border_pixel = 0; - swa.colormap = cmap; + swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; - win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, - depth, CopyFromParent, visual, - CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa); + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, + CopyFromParent, CopyFromParent, CopyFromParent, + CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); XSetClassHint(dpy, win, &ch); @@ -704,7 +690,6 @@ static void usage(void) { fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" - " [-x xoffset] [-y yoffset] [-z width]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); exit(1); } @@ -732,12 +717,6 @@ main(int argc, char *argv[]) /* these options take one argument */ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); - else if (!strcmp(argv[i], "-x")) /* window x offset */ - dmx = atoi(argv[++i]); - else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */ - dmy = atoi(argv[++i]); - else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */ - dmw = atoi(argv[++i]); else if (!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ @@ -768,8 +747,7 @@ main(int argc, char *argv[]) if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); - xinitvisual(); - drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); + drw = drw_create(dpy, screen, root, wa.width, wa.height); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h; @@ -791,40 +769,3 @@ main(int argc, char *argv[]) return 1; /* unreachable */ } - - void -xinitvisual() -{ - XVisualInfo *infos; - XRenderPictFormat *fmt; - int nitems; - int i; - - XVisualInfo tpl = { - .screen = screen, - .depth = 32, - .class = TrueColor - }; - long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; - - infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); - visual = NULL; - for(i = 0; i < nitems; i ++) { - fmt = XRenderFindVisualFormat(dpy, infos[i].visual); - if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { - visual = infos[i].visual; - depth = infos[i].depth; - cmap = XCreateColormap(dpy, root, visual, AllocNone); - useargb = 1; - break; - } - } - - XFree(infos); - - if (! visual) { - visual = DefaultVisual(dpy, screen); - depth = DefaultDepth(dpy, screen); - cmap = DefaultColormap(dpy, screen); - } -} diff --git a/dmenu-5.0/dmenu.c.orig b/dmenu-5.0/dmenu.c.orig new file mode 100644 index 0000000..3e56e1a --- /dev/null +++ b/dmenu-5.0/dmenu.c.orig @@ -0,0 +1,821 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#ifdef XINERAMA +#include +#endif +#include + +#include "drw.h" +#include "util.h" + +/* macros */ +#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ + * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) +#define LENGTH(X) (sizeof X / sizeof X[0]) +#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) + +#define OPAQUE 0xffU + +/* enums */ +enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ + +struct item { + char *text; + struct item *left, *right; + int out; +}; + +static char text[BUFSIZ] = ""; +static char *embed; +static int bh, mw, mh; +static int inputw = 0, promptw; +static int lrpad; /* sum of left and right padding */ +static size_t cursor; +static struct item *items = NULL; +static struct item *matches, *matchend; +static struct item *prev, *curr, *next, *sel; +static int mon = -1, screen; + +static Atom clip, utf8; +static Display *dpy; +static Window root, parentwin, win; +static XIC xic; + +static Drw *drw; +static Clr *scheme[SchemeLast]; + +static int useargb = 0; +static Visual *visual; +static int depth; +static Colormap cmap; + +#include "config.h" + +static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; +static char *(*fstrstr)(const char *, const char *) = strstr; +static void xinitvisual(); + +static void +appenditem(struct item *item, struct item **list, struct item **last) +{ + if (*last) + (*last)->right = item; + else + *list = item; + + item->left = *last; + item->right = NULL; + *last = item; +} + +static void +calcoffsets(void) +{ + int i, n; + + if (lines > 0) + n = lines * bh; + else + n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">")); + /* calculate which items will begin the next page and previous page */ + for (i = 0, next = curr; next; next = next->right) + if ((i += (lines > 0) ? bh : MIN(TEXTW(next->text), n)) > n) + break; + for (i = 0, prev = curr; prev && prev->left; prev = prev->left) + if ((i += (lines > 0) ? bh : MIN(TEXTW(prev->left->text), n)) > n) + break; +} + +static void +cleanup(void) +{ + size_t i; + + XUngrabKey(dpy, AnyKey, AnyModifier, root); + for (i = 0; i < SchemeLast; i++) + free(scheme[i]); + drw_free(drw); + XSync(dpy, False); + XCloseDisplay(dpy); +} + +static char * +cistrstr(const char *s, const char *sub) +{ + size_t len; + + for (len = strlen(sub); *s; s++) + if (!strncasecmp(s, sub, len)) + return (char *)s; + return NULL; +} + +static int +drawitem(struct item *item, int x, int y, int w) +{ + if (item == sel) + drw_setscheme(drw, scheme[SchemeSel]); + else if (item->out) + drw_setscheme(drw, scheme[SchemeOut]); + else + drw_setscheme(drw, scheme[SchemeNorm]); + + return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); +} + +static void +drawmenu(void) +{ + unsigned int curpos; + struct item *item; + int x = 0, y = 0, w; + + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, 0, 0, mw, mh, 1, 1); + + if (prompt && *prompt) { + drw_setscheme(drw, scheme[SchemeSel]); + x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0); + } + /* draw input field */ + w = (lines > 0 || !matches) ? mw - x : inputw; + drw_setscheme(drw, scheme[SchemeNorm]); + drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + + curpos = TEXTW(text) - TEXTW(&text[cursor]); + if ((curpos += lrpad / 2 - 1) < w) { + drw_setscheme(drw, scheme[SchemeNorm]); + drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); + } + + if (lines > 0) { + /* draw vertical list */ + for (item = curr; item != next; item = item->right) + drawitem(item, x, y += bh, mw - x); + } else if (matches) { + /* draw horizontal list */ + x += inputw; + w = TEXTW("<"); + if (curr->left) { + drw_setscheme(drw, scheme[SchemeNorm]); + drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0); + } + x += w; + for (item = curr; item != next; item = item->right) + x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">"))); + if (next) { + w = TEXTW(">"); + drw_setscheme(drw, scheme[SchemeNorm]); + drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0); + } + } + drw_map(drw, win, 0, 0, mw, mh); +} + +static void +grabfocus(void) +{ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 }; + Window focuswin; + int i, revertwin; + + for (i = 0; i < 100; ++i) { + XGetInputFocus(dpy, &focuswin, &revertwin); + if (focuswin == win) + return; + XSetInputFocus(dpy, win, RevertToParent, CurrentTime); + nanosleep(&ts, NULL); + } + die("cannot grab focus"); +} + +static void +grabkeyboard(void) +{ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 }; + int i; + + if (embed) + return; + /* try to grab keyboard, we may have to wait for another process to ungrab */ + for (i = 0; i < 1000; i++) { + if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync, + GrabModeAsync, CurrentTime) == GrabSuccess) + return; + nanosleep(&ts, NULL); + } + die("cannot grab keyboard"); +} + +static void +match(void) +{ + static char **tokv = NULL; + static int tokn = 0; + + char buf[sizeof text], *s; + int i, tokc = 0; + size_t len, textsize; + struct item *item, *lprefix, *lsubstr, *prefixend, *substrend; + + strcpy(buf, text); + /* separate input text into tokens to be matched individually */ + for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " ")) + if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv))) + die("cannot realloc %u bytes:", tokn * sizeof *tokv); + len = tokc ? strlen(tokv[0]) : 0; + + matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; + textsize = strlen(text) + 1; + for (item = items; item && item->text; item++) { + for (i = 0; i < tokc; i++) + if (!fstrstr(item->text, tokv[i])) + break; + if (i != tokc) /* not all tokens match */ + continue; + /* exact matches go first, then prefixes, then substrings */ + if (!tokc || !fstrncmp(text, item->text, textsize)) + appenditem(item, &matches, &matchend); + else if (!fstrncmp(tokv[0], item->text, len)) + appenditem(item, &lprefix, &prefixend); + else + appenditem(item, &lsubstr, &substrend); + } + if (lprefix) { + if (matches) { + matchend->right = lprefix; + lprefix->left = matchend; + } else + matches = lprefix; + matchend = prefixend; + } + if (lsubstr) { + if (matches) { + matchend->right = lsubstr; + lsubstr->left = matchend; + } else + matches = lsubstr; + matchend = substrend; + } + curr = sel = matches; + calcoffsets(); +} + +static void +insert(const char *str, ssize_t n) +{ + if (strlen(text) + n > sizeof text - 1) + return; + /* move existing text out of the way, insert new text, and update cursor */ + memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0)); + if (n > 0) + memcpy(&text[cursor], str, n); + cursor += n; + match(); +} + +static size_t +nextrune(int inc) +{ + ssize_t n; + + /* return location of next utf8 rune in the given direction (+1 or -1) */ + for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc) + ; + return n; +} + +static void +movewordedge(int dir) +{ + if (dir < 0) { /* move cursor to the start of the word*/ + while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) + cursor = nextrune(-1); + while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) + cursor = nextrune(-1); + } else { /* move cursor to the end of the word */ + while (text[cursor] && strchr(worddelimiters, text[cursor])) + cursor = nextrune(+1); + while (text[cursor] && !strchr(worddelimiters, text[cursor])) + cursor = nextrune(+1); + } +} + +static void +keypress(XKeyEvent *ev) +{ + char buf[32]; + int len; + KeySym ksym; + Status status; + + len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status); + switch (status) { + default: /* XLookupNone, XBufferOverflow */ + return; + case XLookupChars: + goto insert; + case XLookupKeySym: + case XLookupBoth: + break; + } + + if (ev->state & ControlMask) { + switch(ksym) { + case XK_a: ksym = XK_Home; break; + case XK_b: ksym = XK_Left; break; + case XK_c: ksym = XK_Escape; break; + case XK_d: ksym = XK_Delete; break; + case XK_e: ksym = XK_End; break; + case XK_f: ksym = XK_Right; break; + case XK_g: ksym = XK_Escape; break; + case XK_h: ksym = XK_BackSpace; break; + case XK_i: ksym = XK_Tab; break; + case XK_j: /* fallthrough */ + case XK_J: /* fallthrough */ + case XK_m: /* fallthrough */ + case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break; + case XK_n: ksym = XK_Down; break; + case XK_p: ksym = XK_Up; break; + + case XK_k: /* delete right */ + text[cursor] = '\0'; + match(); + break; + case XK_u: /* delete left */ + insert(NULL, 0 - cursor); + break; + case XK_w: /* delete word */ + while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) + insert(NULL, nextrune(-1) - cursor); + while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)])) + insert(NULL, nextrune(-1) - cursor); + break; + case XK_y: /* paste selection */ + case XK_Y: + XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY, + utf8, utf8, win, CurrentTime); + return; + case XK_Left: + movewordedge(-1); + goto draw; + case XK_Right: + movewordedge(+1); + goto draw; + case XK_Return: + case XK_KP_Enter: + break; + case XK_bracketleft: + cleanup(); + exit(1); + default: + return; + } + } else if (ev->state & Mod1Mask) { + switch(ksym) { + case XK_b: + movewordedge(-1); + goto draw; + case XK_f: + movewordedge(+1); + goto draw; + case XK_g: ksym = XK_Home; break; + case XK_G: ksym = XK_End; break; + case XK_h: ksym = XK_Up; break; + case XK_j: ksym = XK_Next; break; + case XK_k: ksym = XK_Prior; break; + case XK_l: ksym = XK_Down; break; + default: + return; + } + } + + switch(ksym) { + default: +insert: + if (!iscntrl(*buf)) + insert(buf, len); + break; + case XK_Delete: + if (text[cursor] == '\0') + return; + cursor = nextrune(+1); + /* fallthrough */ + case XK_BackSpace: + if (cursor == 0) + return; + insert(NULL, nextrune(-1) - cursor); + break; + case XK_End: + if (text[cursor] != '\0') { + cursor = strlen(text); + break; + } + if (next) { + /* jump to end of list and position items in reverse */ + curr = matchend; + calcoffsets(); + curr = prev; + calcoffsets(); + while (next && (curr = curr->right)) + calcoffsets(); + } + sel = matchend; + break; + case XK_Escape: + cleanup(); + exit(1); + case XK_Home: + if (sel == matches) { + cursor = 0; + break; + } + sel = curr = matches; + calcoffsets(); + break; + case XK_Left: + if (cursor > 0 && (!sel || !sel->left || lines > 0)) { + cursor = nextrune(-1); + break; + } + if (lines > 0) + return; + /* fallthrough */ + case XK_Up: + if (sel && sel->left && (sel = sel->left)->right == curr) { + curr = prev; + calcoffsets(); + } + break; + case XK_Next: + if (!next) + return; + sel = curr = next; + calcoffsets(); + break; + case XK_Prior: + if (!prev) + return; + sel = curr = prev; + calcoffsets(); + break; + case XK_Return: + case XK_KP_Enter: + puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); + if (!(ev->state & ControlMask)) { + cleanup(); + exit(0); + } + if (sel) + sel->out = 1; + break; + case XK_Right: + if (text[cursor] != '\0') { + cursor = nextrune(+1); + break; + } + if (lines > 0) + return; + /* fallthrough */ + case XK_Down: + if (sel && sel->right && (sel = sel->right) == next) { + curr = next; + calcoffsets(); + } + break; + case XK_Tab: + if (!sel) + return; + strncpy(text, sel->text, sizeof text - 1); + text[sizeof text - 1] = '\0'; + cursor = strlen(text); + match(); + break; + } + +draw: + drawmenu(); +} + +static void +paste(void) +{ + char *p, *q; + int di; + unsigned long dl; + Atom da; + + /* we have been given the current selection, now insert it into input */ + if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False, + utf8, &da, &di, &dl, &dl, (unsigned char **)&p) + == Success && p) { + insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p)); + XFree(p); + } + drawmenu(); +} + +static void +readstdin(void) +{ + char buf[sizeof text], *p; + size_t i, imax = 0, size = 0; + unsigned int tmpmax = 0; + + /* read each line from stdin and add it to the item list */ + for (i = 0; fgets(buf, sizeof buf, stdin); i++) { + if (i + 1 >= size / sizeof *items) + if (!(items = realloc(items, (size += BUFSIZ)))) + die("cannot realloc %u bytes:", size); + if ((p = strchr(buf, '\n'))) + *p = '\0'; + if (!(items[i].text = strdup(buf))) + die("cannot strdup %u bytes:", strlen(buf) + 1); + items[i].out = 0; + drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL); + if (tmpmax > inputw) { + inputw = tmpmax; + imax = i; + } + } + if (items) + items[i].text = NULL; + inputw = items ? TEXTW(items[imax].text) : 0; + lines = MIN(lines, i); +} + +static void +run(void) +{ + XEvent ev; + + while (!XNextEvent(dpy, &ev)) { + if (XFilterEvent(&ev, win)) + continue; + switch(ev.type) { + case DestroyNotify: + if (ev.xdestroywindow.window != win) + break; + cleanup(); + exit(1); + case Expose: + if (ev.xexpose.count == 0) + drw_map(drw, win, 0, 0, mw, mh); + break; + case FocusIn: + /* regrab focus from parent window */ + if (ev.xfocus.window != win) + grabfocus(); + break; + case KeyPress: + keypress(&ev.xkey); + break; + case SelectionNotify: + if (ev.xselection.property == utf8) + paste(); + break; + case VisibilityNotify: + if (ev.xvisibility.state != VisibilityUnobscured) + XRaiseWindow(dpy, win); + break; + } + } +} + +static void +setup(void) +{ + int x, y, i, j; + unsigned int du; + XSetWindowAttributes swa; + XIM xim; + Window w, dw, *dws; + XWindowAttributes wa; + XClassHint ch = {"dmenu", "dmenu"}; +#ifdef XINERAMA + XineramaScreenInfo *info; + Window pw; + int a, di, n, area = 0; +#endif + /* init appearance */ + for (j = 0; j < SchemeLast; j++) + scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2); + + clip = XInternAtom(dpy, "CLIPBOARD", False); + utf8 = XInternAtom(dpy, "UTF8_STRING", False); + + /* calculate menu geometry */ + bh = drw->fonts->h + 2; + lines = MAX(lines, 0); + mh = (lines + 1) * bh; +#ifdef XINERAMA + i = 0; + if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) { + XGetInputFocus(dpy, &w, &di); + if (mon >= 0 && mon < n) + i = mon; + else if (w != root && w != PointerRoot && w != None) { + /* find top-level window containing current input focus */ + do { + if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws) + XFree(dws); + } while (w != root && w != pw); + /* find xinerama screen with which the window intersects most */ + if (XGetWindowAttributes(dpy, pw, &wa)) + for (j = 0; j < n; j++) + if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) { + area = a; + i = j; + } + } + /* no focused window is on screen, so use pointer location instead */ + if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) + for (i = 0; i < n; i++) + if (INTERSECT(x, y, 1, 1, info[i])) + break; + + x = info[i].x_org; + y = info[i].y_org + (topbar ? 0 : info[i].height - mh); + mw = info[i].width; + + XFree(info); + } else +#endif + { + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); + x = 0; + y = topbar ? 0 : wa.height - mh; + mw = wa.width; + } + promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; + inputw = MIN(inputw, mw/3); + match(); + + /* create menu window */ + swa.override_redirect = True; + swa.background_pixel = 0; + swa.border_pixel = 0; + swa.colormap = cmap; + swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; + win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, + depth, CopyFromParent, visual, + CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa); + XSetClassHint(dpy, win, &ch); + + + /* input methods */ + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) + die("XOpenIM failed: could not open input device"); + + xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, win, XNFocusWindow, win, NULL); + + XMapRaised(dpy, win); + if (embed) { + XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask); + if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { + for (i = 0; i < du && dws[i] != win; ++i) + XSelectInput(dpy, dws[i], FocusChangeMask); + XFree(dws); + } + grabfocus(); + } + drw_resize(drw, mw, mh); + drawmenu(); +} + +static void +usage(void) +{ + fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + XWindowAttributes wa; + int i, fast = 0; + + for (i = 1; i < argc; i++) + /* these options take no arguments */ + if (!strcmp(argv[i], "-v")) { /* prints version information */ + puts("dmenu-"VERSION); + exit(0); + } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ + topbar = 0; + else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ + fast = 1; + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; + } else if (i + 1 == argc) + usage(); + /* these options take one argument */ + else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ + lines = atoi(argv[++i]); + else if (!strcmp(argv[i], "-m")) + mon = atoi(argv[++i]); + else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ + prompt = argv[++i]; + else if (!strcmp(argv[i], "-fn")) /* font or font set */ + fonts[0] = argv[++i]; + else if (!strcmp(argv[i], "-nb")) /* normal background color */ + colors[SchemeNorm][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ + colors[SchemeNorm][ColFg] = argv[++i]; + else if (!strcmp(argv[i], "-sb")) /* selected background color */ + colors[SchemeSel][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ + colors[SchemeSel][ColFg] = argv[++i]; + else if (!strcmp(argv[i], "-w")) /* embedding window id */ + embed = argv[++i]; + else + usage(); + + if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + fputs("warning: no locale support\n", stderr); + if (!(dpy = XOpenDisplay(NULL))) + die("cannot open display"); + screen = DefaultScreen(dpy); + root = RootWindow(dpy, screen); + if (!embed || !(parentwin = strtol(embed, NULL, 0))) + parentwin = root; + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); + xinitvisual(); + drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); + if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) + die("no fonts could be loaded."); + lrpad = drw->fonts->h; + +#ifdef __OpenBSD__ + if (pledge("stdio rpath", NULL) == -1) + die("pledge"); +#endif + + if (fast && !isatty(0)) { + grabkeyboard(); + readstdin(); + } else { + readstdin(); + grabkeyboard(); + } + setup(); + run(); + + return 1; /* unreachable */ +} + + void +xinitvisual() +{ + XVisualInfo *infos; + XRenderPictFormat *fmt; + int nitems; + int i; + + XVisualInfo tpl = { + .screen = screen, + .depth = 32, + .class = TrueColor + }; + long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; + + infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); + visual = NULL; + for(i = 0; i < nitems; i ++) { + fmt = XRenderFindVisualFormat(dpy, infos[i].visual); + if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { + visual = infos[i].visual; + depth = infos[i].depth; + cmap = XCreateColormap(dpy, root, visual, AllocNone); + useargb = 1; + break; + } + } + + XFree(infos); + + if (! visual) { + visual = DefaultVisual(dpy, screen); + depth = DefaultDepth(dpy, screen); + cmap = DefaultColormap(dpy, screen); + } +} diff --git a/dmenu-5.0/dmenu.o b/dmenu-5.0/dmenu.o index c11cf4e..fb225c1 100644 Binary files a/dmenu-5.0/dmenu.o and b/dmenu-5.0/dmenu.o differ diff --git a/dmenu-5.0/dmenu_run b/dmenu-5.0/dmenu_run index 3c4ad23..834ede5 100755 --- a/dmenu-5.0/dmenu_run +++ b/dmenu-5.0/dmenu_run @@ -1,2 +1,2 @@ #!/bin/sh -dmenu_path | dmenu -i -y 340 -z 500 -l 20 -x 700 "$@" | ${SHELL:-"/bin/sh"} & +dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} & diff --git a/dmenu-5.0/drw.c b/dmenu-5.0/drw.c index fe3aadd..4cdbcbe 100644 --- a/dmenu-5.0/drw.c +++ b/dmenu-5.0/drw.c @@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen) } Drw * -drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) +drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) { Drw *drw = ecalloc(1, sizeof(Drw)); @@ -70,11 +70,8 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h drw->root = root; drw->w = w; drw->h = h; - drw->visual = visual; - drw->depth = depth; - drw->cmap = cmap; - drw->drawable = XCreatePixmap(dpy, root, w, h, depth); - drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); + drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); + drw->gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); return drw; @@ -90,7 +87,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) drw->h = h; if (drw->drawable) XFreePixmap(drw->dpy, drw->drawable); - drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); + drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); } void @@ -197,22 +194,21 @@ drw_fontset_free(Fnt *font) } void -drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha) +drw_clr_create(Drw *drw, Clr *dest, const char *clrname) { if (!drw || !dest || !clrname) return; - if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, + if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen), clrname, dest)) die("error, cannot allocate color '%s'", clrname); - - dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); } /* Wrapper to create color schemes. The caller has to call free(3) on the * returned color scheme when done using it. */ Clr * -drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) +drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) { size_t i; Clr *ret; @@ -222,7 +218,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], si return NULL; for (i = 0; i < clrcount; i++) - drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); + drw_clr_create(drw, &ret[i], clrnames[i]); return ret; } @@ -278,7 +274,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); - d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); + d = XftDrawCreate(drw->dpy, drw->drawable, + DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen)); x += lpad; w -= lpad; } diff --git a/dmenu-5.0/drw.c.orig b/dmenu-5.0/drw.c.orig new file mode 100644 index 0000000..fe3aadd --- /dev/null +++ b/dmenu-5.0/drw.c.orig @@ -0,0 +1,438 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#include + +#include "drw.h" +#include "util.h" + +#define UTF_INVALID 0xFFFD +#define UTF_SIZ 4 + +static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0}; +static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8}; +static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; +static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; + +static long +utf8decodebyte(const char c, size_t *i) +{ + for (*i = 0; *i < (UTF_SIZ + 1); ++(*i)) + if (((unsigned char)c & utfmask[*i]) == utfbyte[*i]) + return (unsigned char)c & ~utfmask[*i]; + return 0; +} + +static size_t +utf8validate(long *u, size_t i) +{ + if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) + *u = UTF_INVALID; + for (i = 1; *u > utfmax[i]; ++i) + ; + return i; +} + +static size_t +utf8decode(const char *c, long *u, size_t clen) +{ + size_t i, j, len, type; + long udecoded; + + *u = UTF_INVALID; + if (!clen) + return 0; + udecoded = utf8decodebyte(c[0], &len); + if (!BETWEEN(len, 1, UTF_SIZ)) + return 1; + for (i = 1, j = 1; i < clen && j < len; ++i, ++j) { + udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type); + if (type) + return j; + } + if (j < len) + return 0; + *u = udecoded; + utf8validate(u, len); + + return len; +} + +Drw * +drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) +{ + Drw *drw = ecalloc(1, sizeof(Drw)); + + drw->dpy = dpy; + drw->screen = screen; + drw->root = root; + drw->w = w; + drw->h = h; + drw->visual = visual; + drw->depth = depth; + drw->cmap = cmap; + drw->drawable = XCreatePixmap(dpy, root, w, h, depth); + drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); + XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); + + return drw; +} + +void +drw_resize(Drw *drw, unsigned int w, unsigned int h) +{ + if (!drw) + return; + + drw->w = w; + drw->h = h; + if (drw->drawable) + XFreePixmap(drw->dpy, drw->drawable); + drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); +} + +void +drw_free(Drw *drw) +{ + XFreePixmap(drw->dpy, drw->drawable); + XFreeGC(drw->dpy, drw->gc); + drw_fontset_free(drw->fonts); + free(drw); +} + +/* This function is an implementation detail. Library users should use + * drw_fontset_create instead. + */ +static Fnt * +xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern) +{ + Fnt *font; + XftFont *xfont = NULL; + FcPattern *pattern = NULL; + + if (fontname) { + /* Using the pattern found at font->xfont->pattern does not yield the + * same substitution results as using the pattern returned by + * FcNameParse; using the latter results in the desired fallback + * behaviour whereas the former just results in missing-character + * rectangles being drawn, at least with some fonts. */ + if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) { + fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname); + return NULL; + } + if (!(pattern = FcNameParse((FcChar8 *) fontname))) { + fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname); + XftFontClose(drw->dpy, xfont); + return NULL; + } + } else if (fontpattern) { + if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) { + fprintf(stderr, "error, cannot load font from pattern.\n"); + return NULL; + } + } else { + die("no font specified."); + } + + /* Do not allow using color fonts. This is a workaround for a BadLength + * error from Xft with color glyphs. Modelled on the Xterm workaround. See + * https://bugzilla.redhat.com/show_bug.cgi?id=1498269 + * https://lists.suckless.org/dev/1701/30932.html + * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349 + * and lots more all over the internet. + */ + FcBool iscol; + if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) { + XftFontClose(drw->dpy, xfont); + return NULL; + } + + font = ecalloc(1, sizeof(Fnt)); + font->xfont = xfont; + font->pattern = pattern; + font->h = xfont->ascent + xfont->descent; + font->dpy = drw->dpy; + + return font; +} + +static void +xfont_free(Fnt *font) +{ + if (!font) + return; + if (font->pattern) + FcPatternDestroy(font->pattern); + XftFontClose(font->dpy, font->xfont); + free(font); +} + +Fnt* +drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount) +{ + Fnt *cur, *ret = NULL; + size_t i; + + if (!drw || !fonts) + return NULL; + + for (i = 1; i <= fontcount; i++) { + if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) { + cur->next = ret; + ret = cur; + } + } + return (drw->fonts = ret); +} + +void +drw_fontset_free(Fnt *font) +{ + if (font) { + drw_fontset_free(font->next); + xfont_free(font); + } +} + +void +drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha) +{ + if (!drw || !dest || !clrname) + return; + + if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, + clrname, dest)) + die("error, cannot allocate color '%s'", clrname); + + dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); +} + +/* Wrapper to create color schemes. The caller has to call free(3) on the + * returned color scheme when done using it. */ +Clr * +drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) +{ + size_t i; + Clr *ret; + + /* need at least two colors for a scheme */ + if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor)))) + return NULL; + + for (i = 0; i < clrcount; i++) + drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); + return ret; +} + +void +drw_setfontset(Drw *drw, Fnt *set) +{ + if (drw) + drw->fonts = set; +} + +void +drw_setscheme(Drw *drw, Clr *scm) +{ + if (drw) + drw->scheme = scm; +} + +void +drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert) +{ + if (!drw || !drw->scheme) + return; + XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel); + if (filled) + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + else + XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); +} + +int +drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) +{ + char buf[1024]; + int ty; + unsigned int ew; + XftDraw *d = NULL; + Fnt *usedfont, *curfont, *nextfont; + size_t i, len; + int utf8strlen, utf8charlen, render = x || y || w || h; + long utf8codepoint = 0; + const char *utf8str; + FcCharSet *fccharset; + FcPattern *fcpattern; + FcPattern *match; + XftResult result; + int charexists = 0; + + if (!drw || (render && !drw->scheme) || !text || !drw->fonts) + return 0; + + if (!render) { + w = ~w; + } else { + XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); + d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); + x += lpad; + w -= lpad; + } + + usedfont = drw->fonts; + while (1) { + utf8strlen = 0; + utf8str = text; + nextfont = NULL; + while (*text) { + utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ); + for (curfont = drw->fonts; curfont; curfont = curfont->next) { + charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint); + if (charexists) { + if (curfont == usedfont) { + utf8strlen += utf8charlen; + text += utf8charlen; + } else { + nextfont = curfont; + } + break; + } + } + + if (!charexists || nextfont) + break; + else + charexists = 0; + } + + if (utf8strlen) { + drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL); + /* shorten text if necessary */ + for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--) + drw_font_getexts(usedfont, utf8str, len, &ew, NULL); + + if (len) { + memcpy(buf, utf8str, len); + buf[len] = '\0'; + if (len < utf8strlen) + for (i = len; i && i > len - 3; buf[--i] = '.') + ; /* NOP */ + + if (render) { + ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent; + XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg], + usedfont->xfont, x, ty, (XftChar8 *)buf, len); + } + x += ew; + w -= ew; + } + } + + if (!*text) { + break; + } else if (nextfont) { + charexists = 0; + usedfont = nextfont; + } else { + /* Regardless of whether or not a fallback font is found, the + * character must be drawn. */ + charexists = 1; + + fccharset = FcCharSetCreate(); + FcCharSetAddChar(fccharset, utf8codepoint); + + if (!drw->fonts->pattern) { + /* Refer to the comment in xfont_create for more information. */ + die("the first font in the cache must be loaded from a font string."); + } + + fcpattern = FcPatternDuplicate(drw->fonts->pattern); + FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); + FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); + FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); + + FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); + FcDefaultSubstitute(fcpattern); + match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result); + + FcCharSetDestroy(fccharset); + FcPatternDestroy(fcpattern); + + if (match) { + usedfont = xfont_create(drw, NULL, match); + if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) { + for (curfont = drw->fonts; curfont->next; curfont = curfont->next) + ; /* NOP */ + curfont->next = usedfont; + } else { + xfont_free(usedfont); + usedfont = drw->fonts; + } + } + } + } + if (d) + XftDrawDestroy(d); + + return x + (render ? w : 0); +} + +void +drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) +{ + if (!drw) + return; + + XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y); + XSync(drw->dpy, False); +} + +unsigned int +drw_fontset_getwidth(Drw *drw, const char *text) +{ + if (!drw || !drw->fonts || !text) + return 0; + return drw_text(drw, 0, 0, 0, 0, 0, text, 0); +} + +void +drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h) +{ + XGlyphInfo ext; + + if (!font || !text) + return; + + XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext); + if (w) + *w = ext.xOff; + if (h) + *h = font->h; +} + +Cur * +drw_cur_create(Drw *drw, int shape) +{ + Cur *cur; + + if (!drw || !(cur = ecalloc(1, sizeof(Cur)))) + return NULL; + + cur->cursor = XCreateFontCursor(drw->dpy, shape); + + return cur; +} + +void +drw_cur_free(Drw *drw, Cur *cursor) +{ + if (!cursor) + return; + + XFreeCursor(drw->dpy, cursor->cursor); + free(cursor); +} diff --git a/dmenu-5.0/drw.h b/dmenu-5.0/drw.h index f6fa5cd..4c67419 100644 --- a/dmenu-5.0/drw.h +++ b/dmenu-5.0/drw.h @@ -20,9 +20,6 @@ typedef struct { Display *dpy; int screen; Window root; - Visual *visual; - unsigned int depth; - Colormap cmap; Drawable drawable; GC gc; Clr *scheme; @@ -30,7 +27,7 @@ typedef struct { } Drw; /* Drawable abstraction */ -Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap); +Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); void drw_resize(Drw *drw, unsigned int w, unsigned int h); void drw_free(Drw *drw); @@ -41,8 +38,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text); void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); /* Colorscheme abstraction */ -void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); -Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); +void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); /* Cursor abstraction */ Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dmenu-5.0/drw.h.orig b/dmenu-5.0/drw.h.orig new file mode 100644 index 0000000..f6fa5cd --- /dev/null +++ b/dmenu-5.0/drw.h.orig @@ -0,0 +1,60 @@ +/* See LICENSE file for copyright and license details. */ + +typedef struct { + Cursor cursor; +} Cur; + +typedef struct Fnt { + Display *dpy; + unsigned int h; + XftFont *xfont; + FcPattern *pattern; + struct Fnt *next; +} Fnt; + +enum { ColFg, ColBg }; /* Clr scheme index */ +typedef XftColor Clr; + +typedef struct { + unsigned int w, h; + Display *dpy; + int screen; + Window root; + Visual *visual; + unsigned int depth; + Colormap cmap; + Drawable drawable; + GC gc; + Clr *scheme; + Fnt *fonts; +} Drw; + +/* Drawable abstraction */ +Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap); +void drw_resize(Drw *drw, unsigned int w, unsigned int h); +void drw_free(Drw *drw); + +/* Fnt abstraction */ +Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount); +void drw_fontset_free(Fnt* set); +unsigned int drw_fontset_getwidth(Drw *drw, const char *text); +void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); + +/* Colorscheme abstraction */ +void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); + +/* Cursor abstraction */ +Cur *drw_cur_create(Drw *drw, int shape); +void drw_cur_free(Drw *drw, Cur *cursor); + +/* Drawing context manipulation */ +void drw_setfontset(Drw *drw, Fnt *set); +void drw_setscheme(Drw *drw, Clr *scm); + +/* Drawing functions */ +void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert); +int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert); + +/* Map functions */ +void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); diff --git a/dmenu-5.0/drw.o b/dmenu-5.0/drw.o index fa110cc..57700fd 100644 Binary files a/dmenu-5.0/drw.o and b/dmenu-5.0/drw.o differ diff --git a/dmenu-5.0/patches/dmenu-alpha-20210605-1a13d04.diff b/dmenu-5.0/patches/dmenu-alpha-20210605-1a13d04.diff deleted file mode 100644 index 51679f7..0000000 --- a/dmenu-5.0/patches/dmenu-alpha-20210605-1a13d04.diff +++ /dev/null @@ -1,267 +0,0 @@ -diff --git a/config.def.h b/config.def.h -index 1edb647..697d511 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -2,6 +2,7 @@ - /* Default settings; can be overriden by command line. */ - - static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -+static const unsigned int alpha = 0xf0; - /* -fn option overrides fonts[0]; default X11 font or font set */ - static const char *fonts[] = { - "monospace:size=10" -@@ -13,6 +14,13 @@ static const char *colors[SchemeLast][2] = { - [SchemeSel] = { "#eeeeee", "#005577" }, - [SchemeOut] = { "#000000", "#00ffff" }, - }; -+ -+static const unsigned int alphas[SchemeLast][2] = { -+ [SchemeNorm] = { OPAQUE, alpha }, -+ [SchemeSel] = { OPAQUE, alpha }, -+ [SchemeOut] = { OPAQUE, alpha }, -+}; -+ - /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ - static unsigned int lines = 0; - -diff --git a/dmenu.c b/dmenu.c -index 65f25ce..3e56e1a 100644 ---- a/dmenu.c -+++ b/dmenu.c -@@ -10,6 +10,7 @@ - - #include - #include -+#include - #include - #ifdef XINERAMA - #include -@@ -25,6 +26,8 @@ - #define LENGTH(X) (sizeof X / sizeof X[0]) - #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) - -+#define OPAQUE 0xffU -+ - /* enums */ - enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */ - -@@ -53,10 +56,16 @@ static XIC xic; - static Drw *drw; - static Clr *scheme[SchemeLast]; - -+static int useargb = 0; -+static Visual *visual; -+static int depth; -+static Colormap cmap; -+ - #include "config.h" - - static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; - static char *(*fstrstr)(const char *, const char *) = strstr; -+static void xinitvisual(); - - static void - appenditem(struct item *item, struct item **list, struct item **last) -@@ -602,7 +611,7 @@ setup(void) - #endif - /* init appearance */ - for (j = 0; j < SchemeLast; j++) -- scheme[j] = drw_scm_create(drw, colors[j], 2); -+ scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2); - - clip = XInternAtom(dpy, "CLIPBOARD", False); - utf8 = XInternAtom(dpy, "UTF8_STRING", False); -@@ -640,6 +649,7 @@ setup(void) - x = info[i].x_org; - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); - mw = info[i].width; -+ - XFree(info); - } else - #endif -@@ -657,11 +667,13 @@ setup(void) - - /* create menu window */ - swa.override_redirect = True; -- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; -+ swa.background_pixel = 0; -+ swa.border_pixel = 0; -+ swa.colormap = cmap; - swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; -- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, -- CopyFromParent, CopyFromParent, CopyFromParent, -- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); -+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, -+ depth, CopyFromParent, visual, -+ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa); - XSetClassHint(dpy, win, &ch); - - -@@ -747,7 +759,8 @@ main(int argc, char *argv[]) - if (!XGetWindowAttributes(dpy, parentwin, &wa)) - die("could not get embedding window attributes: 0x%lx", - parentwin); -- drw = drw_create(dpy, screen, root, wa.width, wa.height); -+ xinitvisual(); -+ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); - if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) - die("no fonts could be loaded."); - lrpad = drw->fonts->h; -@@ -769,3 +782,40 @@ main(int argc, char *argv[]) - - return 1; /* unreachable */ - } -+ -+ void -+xinitvisual() -+{ -+ XVisualInfo *infos; -+ XRenderPictFormat *fmt; -+ int nitems; -+ int i; -+ -+ XVisualInfo tpl = { -+ .screen = screen, -+ .depth = 32, -+ .class = TrueColor -+ }; -+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; -+ -+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); -+ visual = NULL; -+ for(i = 0; i < nitems; i ++) { -+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual); -+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { -+ visual = infos[i].visual; -+ depth = infos[i].depth; -+ cmap = XCreateColormap(dpy, root, visual, AllocNone); -+ useargb = 1; -+ break; -+ } -+ } -+ -+ XFree(infos); -+ -+ if (! visual) { -+ visual = DefaultVisual(dpy, screen); -+ depth = DefaultDepth(dpy, screen); -+ cmap = DefaultColormap(dpy, screen); -+ } -+} -diff --git a/drw.c b/drw.c -index 4cdbcbe..fe3aadd 100644 ---- a/drw.c -+++ b/drw.c -@@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen) - } - - Drw * --drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) -+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) - { - Drw *drw = ecalloc(1, sizeof(Drw)); - -@@ -70,8 +70,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h - drw->root = root; - drw->w = w; - drw->h = h; -- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); -- drw->gc = XCreateGC(dpy, root, 0, NULL); -+ drw->visual = visual; -+ drw->depth = depth; -+ drw->cmap = cmap; -+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth); -+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); - XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); - - return drw; -@@ -87,7 +90,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) - drw->h = h; - if (drw->drawable) - XFreePixmap(drw->dpy, drw->drawable); -- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); -+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); - } - - void -@@ -194,21 +197,22 @@ drw_fontset_free(Fnt *font) - } - - void --drw_clr_create(Drw *drw, Clr *dest, const char *clrname) -+drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha) - { - if (!drw || !dest || !clrname) - return; - -- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), -- DefaultColormap(drw->dpy, drw->screen), -+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, - clrname, dest)) - die("error, cannot allocate color '%s'", clrname); -+ -+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); - } - - /* Wrapper to create color schemes. The caller has to call free(3) on the - * returned color scheme when done using it. */ - Clr * --drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) -+drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) - { - size_t i; - Clr *ret; -@@ -218,7 +222,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) - return NULL; - - for (i = 0; i < clrcount; i++) -- drw_clr_create(drw, &ret[i], clrnames[i]); -+ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); - return ret; - } - -@@ -274,9 +278,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp - } else { - XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); - XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); -- d = XftDrawCreate(drw->dpy, drw->drawable, -- DefaultVisual(drw->dpy, drw->screen), -- DefaultColormap(drw->dpy, drw->screen)); -+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); - x += lpad; - w -= lpad; - } -diff --git a/drw.h b/drw.h -index 4c67419..f6fa5cd 100644 ---- a/drw.h -+++ b/drw.h -@@ -20,6 +20,9 @@ typedef struct { - Display *dpy; - int screen; - Window root; -+ Visual *visual; -+ unsigned int depth; -+ Colormap cmap; - Drawable drawable; - GC gc; - Clr *scheme; -@@ -27,7 +30,7 @@ typedef struct { - } Drw; - - /* Drawable abstraction */ --Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); -+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap); - void drw_resize(Drw *drw, unsigned int w, unsigned int h); - void drw_free(Drw *drw); - -@@ -38,8 +41,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text); - void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); - - /* Colorscheme abstraction */ --void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); --Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); -+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); -+Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); - - /* Cursor abstraction */ - Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dmenu-5.0/patches/dmenu-border-4.9.diff b/dmenu-5.0/patches/dmenu-border-4.9.diff deleted file mode 100644 index 89b4437..0000000 --- a/dmenu-5.0/patches/dmenu-border-4.9.diff +++ /dev/null @@ -1,25 +0,0 @@ -diff -up dmenu-4.9-b/config.def.h dmenu-4.9-a/config.def.h ---- dmenu-4.9-b/config.def.h 2019-02-02 13:55:02.000000000 +0100 -+++ dmenu-4.9-a/config.def.h 2019-05-19 02:10:12.740040403 +0200 -@@ -21,3 +21,6 @@ static unsigned int lines = 0; - * for example: " /?\"&[]" - */ - static const char worddelimiters[] = " "; -+ -+/* Size of the window border */ -+static const unsigned int border_width = 5; -diff -up dmenu-4.9-b/dmenu.c dmenu-4.9-a/dmenu.c ---- dmenu-4.9-b/dmenu.c 2019-02-02 13:55:02.000000000 +0100 -+++ dmenu-4.9-a/dmenu.c 2019-05-19 02:11:20.966710117 +0200 -@@ -654,9 +654,10 @@ setup(void) - swa.override_redirect = True; - swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; - swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; -- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0, -+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, - CopyFromParent, CopyFromParent, CopyFromParent, - CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); -+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); - XSetClassHint(dpy, win, &ch); - - /* open input methods */ diff --git a/dmenu-5.0/patches/dmenu-xyw-5.0.diff b/dmenu-5.0/patches/dmenu-xyw-5.0.diff deleted file mode 100644 index ddf9cfb..0000000 --- a/dmenu-5.0/patches/dmenu-xyw-5.0.diff +++ /dev/null @@ -1,116 +0,0 @@ -From 7dc7cb96cdda9ad66e33109223c4cc297a7721d1 Mon Sep 17 00:00:00 2001 -From: Alex Cole -Date: Tue, 6 Oct 2020 10:42:07 +1300 -Subject: [PATCH] Updated xyw for 5.0 properly - ---- - dmenu.1 | 24 ++++++++++++++++++++++++ - dmenu.c | 22 ++++++++++++++++------ - 2 files changed, 40 insertions(+), 6 deletions(-) - -diff --git a/dmenu.1 b/dmenu.1 -index 323f93c..a4ecbbb 100644 ---- a/dmenu.1 -+++ b/dmenu.1 -@@ -8,6 +8,12 @@ dmenu \- dynamic menu - .IR lines ] - .RB [ \-m - .IR monitor ] -+.RB [ \-x -+.IR xoffset ] -+.RB [ \-y -+.IR yoffset ] -+.RB [ \-z -+.IR width ] - .RB [ \-p - .IR prompt ] - .RB [ \-fn -@@ -54,6 +60,24 @@ dmenu lists items vertically, with the given number of lines. - dmenu is displayed on the monitor number supplied. Monitor numbers are starting - from 0. - .TP -+.BI \-x " xoffset" -+dmenu is placed at this offset measured from the left side of the monitor. -+Can be negative. -+If option -+.B \-m -+is present, the measurement will use the given monitor. -+.TP -+.BI \-y " yoffset" -+dmenu is placed at this offset measured from the top of the monitor. If the -+.B \-b -+option is used, the offset is measured from the bottom. Can be negative. -+If option -+.B \-m -+is present, the measurement will use the given monitor. -+.TP -+.BI \-z " width" -+sets the width of the dmenu window. -+.TP - .BI \-p " prompt" - defines the prompt to be displayed to the left of the input field. - .TP -diff --git a/dmenu.c b/dmenu.c -index 65f25ce..7be19ae 100644 ---- a/dmenu.c -+++ b/dmenu.c -@@ -37,6 +37,9 @@ struct item { - static char text[BUFSIZ] = ""; - static char *embed; - static int bh, mw, mh; -+static int dmx = 0; /* put dmenu at this x offset */ -+static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */ -+static unsigned int dmw = 0; /* make dmenu this wide */ - static int inputw = 0, promptw; - static int lrpad; /* sum of left and right padding */ - static size_t cursor; -@@ -637,9 +640,9 @@ setup(void) - if (INTERSECT(x, y, 1, 1, info[i])) - break; - -- x = info[i].x_org; -- y = info[i].y_org + (topbar ? 0 : info[i].height - mh); -- mw = info[i].width; -+ x = info[i].x_org + dmx; -+ y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy); -+ mw = (dmw>0 ? dmw : info[i].width); - XFree(info); - } else - #endif -@@ -647,9 +650,9 @@ setup(void) - if (!XGetWindowAttributes(dpy, parentwin, &wa)) - die("could not get embedding window attributes: 0x%lx", - parentwin); -- x = 0; -- y = topbar ? 0 : wa.height - mh; -- mw = wa.width; -+ x = dmx; -+ y = topbar ? dmy : wa.height - mh - dmy; -+ mw = (dmw>0 ? dmw : wa.width); - } - promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; - inputw = MIN(inputw, mw/3); -@@ -690,6 +693,7 @@ static void - usage(void) - { - fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" -+ " [-x xoffset] [-y yoffset] [-z width]\n" - " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr); - exit(1); - } -@@ -717,6 +721,12 @@ main(int argc, char *argv[]) - /* these options take one argument */ - else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ - lines = atoi(argv[++i]); -+ else if (!strcmp(argv[i], "-x")) /* window x offset */ -+ dmx = atoi(argv[++i]); -+ else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */ -+ dmy = atoi(argv[++i]); -+ else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */ -+ dmw = atoi(argv[++i]); - else if (!strcmp(argv[i], "-m")) - mon = atoi(argv[++i]); - else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ --- -2.28.0 - diff --git a/dmenu-5.0/stest b/dmenu-5.0/stest index a20d66d..63e0ea3 100755 Binary files a/dmenu-5.0/stest and b/dmenu-5.0/stest differ diff --git a/dwm-6.2/Makefile b/dwm-6.2/Makefile index 77bcbc0..03900cd 100644 --- a/dwm-6.2/Makefile +++ b/dwm-6.2/Makefile @@ -39,6 +39,7 @@ dist: clean install: all mkdir -p ${DESTDIR}${PREFIX}/bin cp -f dwm ${DESTDIR}${PREFIX}/bin + cp -f wmbar ${DESTDIR}${PREFIX}/bin chmod 755 ${DESTDIR}${PREFIX}/bin/dwm mkdir -p ${DESTDIR}${MANPREFIX}/man1 sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 diff --git a/dwm-6.2/TODO b/dwm-6.2/TODO deleted file mode 100644 index 2ae3ddf..0000000 --- a/dwm-6.2/TODO +++ /dev/null @@ -1 +0,0 @@ -- Change all SHCMD launchers to actual launchers diff --git a/dwm-6.2/autostart.h b/dwm-6.2/autostart.h deleted file mode 100644 index 4aaadee..0000000 --- a/dwm-6.2/autostart.h +++ /dev/null @@ -1,8 +0,0 @@ -static const char *const autostart[] = { - "fehbg", NULL, - "dmenu_run && killall dmenu", NULL, - "dwmblocks", NULL, - "picom_run", NULL, - "dunst", NULL, - NULL /* terminate */ -}; diff --git a/dwm-6.2/colors.h b/dwm-6.2/colors.h new file mode 100644 index 0000000..8026ee1 --- /dev/null +++ b/dwm-6.2/colors.h @@ -0,0 +1,40 @@ +/* dwm color configuration */ +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_cyan[] = "#4B4E74"; + +/* st config */ + +float alpha = 0.6; /* some themes may have this lighter or stronger then others */ + +static const char *colorname[] = { + /* 8 normal colors */ + "#050704", /* black */ + "#d80e0e", /* red */ + "#06f115", /* green */ + "#d8ff00", /* yellow */ + "#0050d2", /* blue */ + "#802bee", /* magenta */ + "#23f0f2", /* cyan */ + "#cfcfcf", /* white */ + + /* 8 bright colors */ + "#cfcfcf", /* black */ + "#ff2857", /* red */ + "#79fc6a", /* green */ + "#d7ff62", /* yellow */ + "#698eff", /* blue */ + "#a461fb", /* magenta */ + "#91fff5", /* cyan */ + "#ffffff", /* white */ + + [255] = 0, + + /* special colors */ + "#cccccc", + "#555555", + "#000000", /* background */ + "#cfcfcf", /* foreground */ +}; diff --git a/dwm-6.2/config.def.h b/dwm-6.2/config.def.h index 48474eb..e1c116d 100644 --- a/dwm-6.2/config.def.h +++ b/dwm-6.2/config.def.h @@ -1,19 +1,22 @@ -#include "../themes/theme.h" - /* See LICENSE file for copyright and license details. */ /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ -static const unsigned int gappih = 12; /* horiz inner gap between windows */ -static const unsigned int gappiv = 15; /* vert inner gap between windows */ -static const unsigned int gappoh = 20; /* horiz outer gap between windows and screen edge */ -static const unsigned int gappov = 12; /* vert outer gap between windows and screen edge */ -static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ +static const unsigned int gappih = 20; /* horiz inner gap between windows */ +static const unsigned int gappiv = 10; /* vert inner gap between windows */ +static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ +static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ +static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "Source Code Pro:size=9" }; -static const char dmenufont[] = "Source Code Pro:size=9"; +static const char *fonts[] = { "monospace:size=10" }; +static const char dmenufont[] = "monospace:size=10"; +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_cyan[] = "#005577"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, @@ -26,7 +29,7 @@ static const char *const autostart[] = { }; /* tagging */ -static const char *tags[] = { "/", "dev", "web", "etc", }; +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { /* xprop(1): @@ -43,11 +46,26 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ +#include "vanitygaps.c" + static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[@]", spiral }, + { "[\\]", dwindle }, + { "H[]", deck }, + { "TTT", bstack }, + { "===", bstackhoriz }, + { "HHH", grid }, + { "###", nrowgrid }, + { "---", horizgrid }, + { ":::", gaplessgrid }, + { "|M|", centeredmaster }, + { ">M>", centeredfloatingmaster }, + { "><>", NULL }, /* no layout function means floating behavior */ + { NULL, NULL }, }; /* key definitions */ @@ -68,36 +86,36 @@ static const char *termcmd[] = { "st", NULL }; static Key keys[] = { /* modifier key function argument */ - { MODKEY, XK_d, spawn, {.v = dmenucmd } }, - { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, -/* { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, -*/ { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, - { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, - { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_i, incrigaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_i, incrigaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_o, incrogaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_o, incrogaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_6, incrihgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_6, incrihgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_7, incrivgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_7, incrivgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_8, incrohgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_8, incrohgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_9, incrovgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } }, { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, - { MODKEY, XK_y, incrihgaps, {.i = +1 } }, - { MODKEY, XK_o, incrihgaps, {.i = -1 } }, - { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, - { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, - { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, - { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, - { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, - { MODKEY|ShiftMask, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, - { MODKEY, XK_x, killclient, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - /*{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, */ + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, @@ -107,14 +125,6 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - // Custom keybinds - { MODKEY, XK_f, spawn, SHCMD("surf_run") }, - { MODKEY|ShiftMask, XK_f, spawn, SHCMD("chromium") }, - { MODKEY|ShiftMask, XK_b, spawn, SHCMD("brighter") }, - { MODKEY|ShiftMask, XK_l, spawn, SHCMD("darker") }, - { MODKEY|ShiftMask, XK_u, spawn, SHCMD("vol_up") }, - { MODKEY|ShiftMask, XK_d, spawn, SHCMD("vol_down") }, - { MODKEY|ShiftMask, XK_m, spawn, SHCMD("mute") }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) diff --git a/dwm-6.2/config.h b/dwm-6.2/config.h index e11dec9..7c82875 100644 --- a/dwm-6.2/config.h +++ b/dwm-6.2/config.h @@ -1,41 +1,32 @@ -#include "../theme.h" -#include "autostart.h" - -/* See LICENSE file for copyright and license details. */ - +#include "colors.h" /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ - -static const unsigned int gappih = 12; /* horiz inner gap between windows */ -static const unsigned int gappiv = 15; /* vert inner gap between windows */ -static const unsigned int gappoh = 20; /* horiz outer gap between windows and screen edge */ -static const unsigned int gappov = 12; /* vert outer gap between windows and screen edge */ - -static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ +static const unsigned int gappih = 4; /* horiz inner gap between windows */ +static const unsigned int gappiv = 4; /* vert inner gap between windows */ +static const unsigned int gappoh = 4; /* horiz outer gap between windows and screen edge */ +static const unsigned int gappov = 4; /* vert outer gap between windows and screen edge */ +static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ - static const char *fonts[] = { "Source Code Pro:size=9" }; static const char dmenufont[] = "Source Code Pro:size=9"; - -static const unsigned int baralpha = 0xd0; -static const unsigned int borderalpha = OPAQUE; - static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeSel] = { col_gray4, col_cyan, col_cyan }, }; -static const unsigned int alphas[][3] = { - [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, - [SchemeSel] = { OPAQUE, baralpha, borderalpha }, +static const char *const autostart[] = { + "picom", NULL, + "wmbar", NULL, + "dunst", NULL, + "fehbg", NULL, /* terminate */ + NULL }; - /* tagging */ -static const char *tags[] = { "/", "dev", "web", "etc", }; +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { /* xprop(1): @@ -49,14 +40,29 @@ static const Rule rules[] = { /* layout(s) */ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const int nmaster = 1; /* numbof clients in master area */ +static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ +#include "vanitygaps.c" + static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[@]", spiral }, + { "[\\]", dwindle }, + { "H[]", deck }, + { "TTT", bstack }, + { "===", bstackhoriz }, + { "HHH", grid }, + { "###", nrowgrid }, + { "---", horizgrid }, + { ":::", gaplessgrid }, + { "|M|", centeredmaster }, + { ">M>", centeredfloatingmaster }, + { "><>", NULL }, /* no layout function means floating behavior */ + { NULL, NULL }, }; /* key definitions */ @@ -71,25 +77,14 @@ static const Layout layouts[] = { #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ - -/* replaces regular quit because it didn't work :( */ -static const char *quitcmd[] = { "killall", "dwm", NULL }; -static const char *browsercmd[] = { "chromium", NULL }; - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; -static const char scratchpadname[] = "ScratchPad"; -static const char scratchpadfile[] = "/tmp/scratchpad_file"; -static const char scratchpadeditor[] = "/usr/bin/vim"; -static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", scratchpadeditor, scratchpadfile, NULL }; - static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_d, spawn, {.v = dmenucmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } }, - { MODKEY, XK_s, spawn, {.v = scratchpadcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, @@ -97,27 +92,27 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, */ { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, - { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, - { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, - { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, + { MODKEY|ShiftMask, XK_Return, zoom, {0} }, + { MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_i, incrigaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_i, incrigaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_o, incrogaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_o, incrogaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_6, incrihgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_6, incrihgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_7, incrivgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_7, incrivgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_8, incrohgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_8, incrohgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_9, incrovgaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } }, { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, - { MODKEY, XK_y, incrihgaps, {.i = +1 } }, - { MODKEY, XK_o, incrihgaps, {.i = -1 } }, - { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, - { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, - { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, - { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, - { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, - { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, - { MODKEY|ShiftMask, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_x, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - /*{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, */ + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, @@ -127,13 +122,11 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - // Custom keybinds - { MODKEY|ShiftMask, XK_f, spawn, {.v = browsercmd} }, - { MODKEY|ShiftMask, XK_b, spawn, SHCMD("brighter") }, - { MODKEY|ShiftMask, XK_l, spawn, SHCMD("darker") }, - { MODKEY|ShiftMask, XK_u, spawn, SHCMD("vol_up") }, - { MODKEY|ShiftMask, XK_d, spawn, SHCMD("vol_down") }, - { MODKEY|ShiftMask, XK_m, spawn, SHCMD("mute") }, + { MODKEY|ShiftMask, XK_p, spawn, SHCMD("mic_toggle") }, + { MODKEY|ShiftMask, XK_u, spawn, SHCMD("vol_up") }, + { MODKEY|ShiftMask, XK_d, spawn, SHCMD("vol_down") }, + { MODKEY|ShiftMask, XK_m, spawn, SHCMD("mute") }, + { MODKEY|ShiftMask, XK_f, spawn, SHCMD("tabbed surf -e") }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) @@ -143,10 +136,9 @@ static Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_q, spawn, {.v = quitcmd } }, + { MODKEY|ShiftMask, XK_q, quit, {0} }, }; - /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { diff --git a/dwm-6.2/config.mk b/dwm-6.2/config.mk index 3cb1518..6d36cb7 100644 --- a/dwm-6.2/config.mk +++ b/dwm-6.2/config.mk @@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/dwm-6.2/drw.c b/dwm-6.2/drw.c index 5b41ecd..8fd1ca4 100644 --- a/dwm-6.2/drw.c +++ b/dwm-6.2/drw.c @@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen) } Drw * -drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap) +drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h) { Drw *drw = ecalloc(1, sizeof(Drw)); @@ -70,11 +70,8 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h drw->root = root; drw->w = w; drw->h = h; - drw->visual = visual; - drw->depth = depth; - drw->cmap = cmap; - drw->drawable = XCreatePixmap(dpy, root, w, h, depth); - drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); + drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen)); + drw->gc = XCreateGC(dpy, root, 0, NULL); XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); return drw; @@ -90,7 +87,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h) drw->h = h; if (drw->drawable) XFreePixmap(drw->dpy, drw->drawable); - drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); + drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen)); } void @@ -196,23 +193,21 @@ drw_fontset_free(Fnt *font) } void -drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha) +drw_clr_create(Drw *drw, Clr *dest, const char *clrname) { if (!drw || !dest || !clrname) return; - if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, + if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen), clrname, dest)) die("error, cannot allocate color '%s'", clrname); - - dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24); - } /* Wrapper to create color schemes. The caller has to call free(3) on the * returned color scheme when done using it. */ Clr * -drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount) +drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) { size_t i; Clr *ret; @@ -222,7 +217,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], si return NULL; for (i = 0; i < clrcount; i++) - drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]); + drw_clr_create(drw, &ret[i], clrnames[i]); return ret; } @@ -278,7 +273,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp } else { XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel); XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h); - d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap); + d = XftDrawCreate(drw->dpy, drw->drawable, + DefaultVisual(drw->dpy, drw->screen), + DefaultColormap(drw->dpy, drw->screen)); x += lpad; w -= lpad; } diff --git a/dwm-6.2/drw.h b/dwm-6.2/drw.h index a56f523..4bcd5ad 100644 --- a/dwm-6.2/drw.h +++ b/dwm-6.2/drw.h @@ -20,9 +20,6 @@ typedef struct { Display *dpy; int screen; Window root; - Visual *visual; - unsigned int depth; - Colormap cmap; Drawable drawable; GC gc; Clr *scheme; @@ -30,7 +27,7 @@ typedef struct { } Drw; /* Drawable abstraction */ -Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap); +Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); void drw_resize(Drw *drw, unsigned int w, unsigned int h); void drw_free(Drw *drw); @@ -41,8 +38,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text); void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h); /* Colorscheme abstraction */ -void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha); -Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount); +void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); /* Cursor abstraction */ Cur *drw_cur_create(Drw *drw, int shape); diff --git a/dwm-6.2/drw.o b/dwm-6.2/drw.o new file mode 100644 index 0000000..ecc65b6 Binary files /dev/null and b/dwm-6.2/drw.o differ diff --git a/dwm-6.2/dwm b/dwm-6.2/dwm new file mode 100755 index 0000000..8c801ca Binary files /dev/null and b/dwm-6.2/dwm differ diff --git a/dwm-6.2/dwm.c b/dwm-6.2/dwm.c index 75c23c3..162cfe2 100644 --- a/dwm-6.2/dwm.c +++ b/dwm-6.2/dwm.c @@ -57,8 +57,6 @@ #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -#define OPAQUE 0xffU - /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel }; /* color schemes */ @@ -153,7 +151,6 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac static void arrange(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); -static void attachabove(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); @@ -206,16 +203,6 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); -static void setgaps(int oh, int ov, int ih, int iv); -static void incrgaps(const Arg *arg); -static void incrigaps(const Arg *arg); -static void incrogaps(const Arg *arg); -static void incrohgaps(const Arg *arg); -static void incrovgaps(const Arg *arg); -static void incrihgaps(const Arg *arg); -static void incrivgaps(const Arg *arg); -static void togglegaps(const Arg *arg); -static void defaultgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -225,10 +212,8 @@ static void sigchld(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); -static void tile(Monitor *); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); -static void togglescratch(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -250,7 +235,6 @@ static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); -static void xinitvisual(); static void zoom(const Arg *arg); static void autostart_exec(void); @@ -260,7 +244,6 @@ static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh, blw = 0; /* bar geometry */ -static int enablegaps = 1; /* enables gaps, used by togglegaps */ static int lrpad; /* sum of left and right padding for text */ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; @@ -289,16 +272,9 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; -static int useargb = 0; -static Visual *visual; -static int depth; -static Colormap cmap; - /* configuration, allows nested code to access above variables */ #include "config.h" -static unsigned int scratchtag = 1 << LENGTH(tags); - /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -462,20 +438,6 @@ attach(Client *c) c->mon->clients = c; } -void -attachabove(Client *c) -{ - if (c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) { - attach(c); - return; - } - - Client *at; - for (at = c->mon->clients; at->next != c->mon->sel; at = at->next); - c->next = at->next; - at->next = c; -} - void attachstack(Client *c) { @@ -1123,14 +1085,6 @@ manage(Window w, XWindowAttributes *wa) && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); c->bw = borderpx; - selmon->tagset[selmon->seltags] &= ~scratchtag; - if (!strcmp(c->name, scratchpadname)) { - c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag; - c->isfloating = True; - c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); - c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); - } - wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); @@ -1144,7 +1098,7 @@ manage(Window w, XWindowAttributes *wa) c->isfloating = c->oldstate = trans != None || c->isfixed; if (c->isfloating) XRaiseWindow(dpy, c->win); - attachabove(c); + attach(c); attachstack(c); XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (unsigned char *) &(c->win), 1); @@ -1509,7 +1463,7 @@ sendmon(Client *c, Monitor *m) detachstack(c); c->mon = m; c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ - attachabove(c); + attach(c); attachstack(c); focus(NULL); arrange(NULL); @@ -1589,111 +1543,6 @@ setfullscreen(Client *c, int fullscreen) } } -void -setgaps(int oh, int ov, int ih, int iv) -{ - if (oh < 0) oh = 0; - if (ov < 0) ov = 0; - if (ih < 0) ih = 0; - if (iv < 0) iv = 0; - - selmon->gappoh = oh; - selmon->gappov = ov; - selmon->gappih = ih; - selmon->gappiv = iv; - arrange(selmon); -} - -void -togglegaps(const Arg *arg) -{ - enablegaps = !enablegaps; - arrange(selmon); -} - -void -defaultgaps(const Arg *arg) -{ - setgaps(gappoh, gappov, gappih, gappiv); -} - -void -incrgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov + arg->i, - selmon->gappih + arg->i, - selmon->gappiv + arg->i - ); -} - -void -incrigaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov, - selmon->gappih + arg->i, - selmon->gappiv + arg->i - ); -} - -void -incrogaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov + arg->i, - selmon->gappih, - selmon->gappiv - ); -} - -void -incrohgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh + arg->i, - selmon->gappov, - selmon->gappih, - selmon->gappiv - ); -} - -void -incrovgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov + arg->i, - selmon->gappih, - selmon->gappiv - ); -} - -void -incrihgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov, - selmon->gappih + arg->i, - selmon->gappiv - ); -} - -void -incrivgaps(const Arg *arg) -{ - setgaps( - selmon->gappoh, - selmon->gappov, - selmon->gappih, - selmon->gappiv + arg->i - ); -} - void setlayout(const Arg *arg) { @@ -1738,8 +1587,7 @@ setup(void) sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); root = RootWindow(dpy, screen); - xinitvisual(); - drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap); + drw = drw_create(dpy, screen, root, sw, sh); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h; @@ -1767,7 +1615,7 @@ setup(void) /* init appearance */ scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); + scheme[i] = drw_scm_create(drw, colors[i], 3); /* init bars */ updatebars(); updatestatus(); @@ -1855,7 +1703,6 @@ spawn(const Arg *arg) { if (arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; - selmon->tagset[selmon->seltags] &= ~scratchtag; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); @@ -1885,38 +1732,6 @@ tagmon(const Arg *arg) sendmon(selmon->sel, dirtomon(arg->i)); } -void -tile(Monitor *m) -{ - unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - - if (smartgaps == n) { - oe = 0; // outer gaps disabled - } - - if (n > m->nmaster) - mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0; - else - mw = m->ww - 2*m->gappov*oe + m->gappiv*ie; - for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - r = MIN(n, m->nmaster) - i; - h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; - resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0); - my += HEIGHT(c) + m->gappih*ie; - } else { - r = n - i; - h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; - resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0); - ty += HEIGHT(c) + m->gappih*ie; - } -} - void togglebar(const Arg *arg) { @@ -1940,28 +1755,6 @@ togglefloating(const Arg *arg) arrange(selmon); } -void -togglescratch(const Arg *arg) -{ - Client *c; - unsigned int found = 0; - - for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next); - if (found) { - unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; - if (newtagset) { - selmon->tagset[selmon->seltags] = newtagset; - focus(NULL); - arrange(selmon); - } - if (ISVISIBLE(c)) { - focus(c); - restack(selmon); - } - } else - spawn(arg); -} - void toggletag(const Arg *arg) { @@ -2047,18 +1840,16 @@ updatebars(void) Monitor *m; XSetWindowAttributes wa = { .override_redirect = True, - .background_pixel = 0, - .border_pixel = 0, - .colormap = cmap, + .background_pixmap = ParentRelative, .event_mask = ButtonPressMask|ExposureMask }; XClassHint ch = {"dwm", "dwm"}; for (m = mons; m; m = m->next) { if (m->barwin) continue; - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, depth, - InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa); + m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), + CopyFromParent, DefaultVisual(dpy, screen), + CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XMapRaised(dpy, m->barwin); XSetClassHint(dpy, m->barwin, &ch); @@ -2142,7 +1933,7 @@ updategeom(void) m->clients = c->next; detachstack(c); c->mon = mons; - attachabove(c); + attach(c); attachstack(c); } if (m == selmon) @@ -2355,43 +2146,6 @@ xerrorstart(Display *dpy, XErrorEvent *ee) return -1; } -void -xinitvisual() -{ - XVisualInfo *infos; - XRenderPictFormat *fmt; - int nitems; - int i; - - XVisualInfo tpl = { - .screen = screen, - .depth = 32, - .class = TrueColor - }; - long masks = VisualScreenMask | VisualDepthMask | VisualClassMask; - - infos = XGetVisualInfo(dpy, masks, &tpl, &nitems); - visual = NULL; - for(i = 0; i < nitems; i ++) { - fmt = XRenderFindVisualFormat(dpy, infos[i].visual); - if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { - visual = infos[i].visual; - depth = infos[i].depth; - cmap = XCreateColormap(dpy, root, visual, AllocNone); - useargb = 1; - break; - } - } - - XFree(infos); - - if (! visual) { - visual = DefaultVisual(dpy, screen); - depth = DefaultDepth(dpy, screen); - cmap = DefaultColormap(dpy, screen); - } -} - void zoom(const Arg *arg) { diff --git a/dwm-6.2/dwm.o b/dwm-6.2/dwm.o new file mode 100644 index 0000000..a28b09d Binary files /dev/null and b/dwm-6.2/dwm.o differ diff --git a/dwm-6.2/keys.h b/dwm-6.2/keys.h deleted file mode 100644 index 8b13789..0000000 --- a/dwm-6.2/keys.h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/dwm-6.2/patches/dwm-attachabove-6.2-20200421.diff b/dwm-6.2/patches/dwm-attachabove-6.2-20200421.diff deleted file mode 100644 index 198f293..0000000 --- a/dwm-6.2/patches/dwm-attachabove-6.2-20200421.diff +++ /dev/null @@ -1,60 +0,0 @@ -diff --git a/local/src/dwm/dwm.c b/local/src/dwm/dwm.c -index 83e44e0..94392b4 100644 ---- a/local/src/dwm/dwm.c -+++ b/local/src/dwm/dwm.c -@@ -164,6 +164,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac - static void arrange(Monitor *m); - static void arrangemon(Monitor *m); - static void attach(Client *c); -+static void attachabove(Client *c); - static void attachstack(Client *c); - static void buttonpress(XEvent *e); - static void checkotherwm(void); -@@ -431,6 +432,20 @@ attach(Client *c) - c->mon->clients = c; - } - -+void -+attachabove(Client *c) -+{ -+ if (c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) { -+ attach(c); -+ return; -+ } -+ -+ Client *at; -+ for (at = c->mon->clients; at->next != c->mon->sel; at = at->next); -+ c->next = at->next; -+ at->next = c; -+} -+ - void - attachstack(Client *c) - { -@@ -1272,7 +1287,7 @@ manage(Window w, XWindowAttributes *wa) - c->isfloating = c->oldstate = trans != None || c->isfixed; - if (c->isfloating) - XRaiseWindow(dpy, c->win); -- attach(c); -+ attachabove(c); - attachstack(c); - XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, - (unsigned char *) &(c->win), 1); -@@ -1633,7 +1648,7 @@ sendmon(Client *c, Monitor *m) - detachstack(c); - c->mon = m; - c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ -- attach(c); -+ attachabove(c); - attachstack(c); - focus(NULL); - arrange(NULL); -@@ -2122,7 +2137,7 @@ updategeom(void) - m->clients = c->next; - detachstack(c); - c->mon = mons; -- attach(c); -+ attachabove(c); - attachstack(c); - } - if (m == selmon) diff --git a/dwm-6.2/patches/dwm-centerfirstwindow-6.2.diff b/dwm-6.2/patches/dwm-centerfirstwindow-6.2.diff deleted file mode 100644 index 707f2ec..0000000 --- a/dwm-6.2/patches/dwm-centerfirstwindow-6.2.diff +++ /dev/null @@ -1,67 +0,0 @@ -diff -up dwm-6.2-orig/config.def.h dwm-6.2-modd/config.def.h ---- dwm-6.2-orig/config.def.h 2019-02-02 16:55:28.000000000 +0400 -+++ dwm-6.2-modd/config.def.h 2021-04-25 16:05:22.569759243 +0400 -@@ -26,9 +26,10 @@ static const Rule rules[] = { - * WM_CLASS(STRING) = instance, class - * WM_NAME(STRING) = title - */ -- /* class instance title tags mask isfloating monitor */ -- { "Gimp", NULL, NULL, 0, 1, -1 }, -- { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, -+ /* class instance title tags mask isfloating CenterThisWindow? monitor */ -+ { "st", NULL, NULL, 0, 0, 1, -1 }, -+ { "Gimp", NULL, NULL, 0, 1, 0, -1 }, -+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, - }; - - /* layout(s) */ -diff -up dwm-6.2-orig/dwm.c dwm-6.2-modd/dwm.c ---- dwm-6.2-orig/dwm.c 2019-02-02 16:55:28.000000000 +0400 -+++ dwm-6.2-modd/dwm.c 2021-04-25 16:06:15.368310756 +0400 -@@ -92,7 +92,7 @@ struct Client { - int basew, baseh, incw, inch, maxw, maxh, minw, minh; - int bw, oldbw; - unsigned int tags; -- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; -+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow; - Client *next; - Client *snext; - Monitor *mon; -@@ -138,6 +138,7 @@ typedef struct { - const char *title; - unsigned int tags; - int isfloating; -+ int CenterThisWindow; - int monitor; - } Rule; - -@@ -286,6 +287,7 @@ applyrules(Client *c) - - /* rule matching */ - c->isfloating = 0; -+ c->CenterThisWindow = 0; - c->tags = 0; - XGetClassHint(dpy, c->win, &ch); - class = ch.res_class ? ch.res_class : broken; -@@ -298,6 +300,7 @@ applyrules(Client *c) - && (!r->instance || strstr(instance, r->instance))) - { - c->isfloating = r->isfloating; -+ c->CenterThisWindow = r->CenterThisWindow; - c->tags |= r->tags; - for (m = mons; m && m->num != r->monitor; m = m->next); - if (m) -@@ -1694,6 +1697,13 @@ tile(Monitor *m) - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); - ty += HEIGHT(c); - } -+ -+ if (n == 1 && selmon->sel->CenterThisWindow) -+ resizeclient(selmon->sel, -+ (selmon->mw - selmon->mw * 0.5) / 2, -+ (selmon->mh - selmon->mh * 0.5) / 2, -+ selmon->mw * 0.5, -+ selmon->mh * 0.5); - } - - void diff --git a/dwm-6.2/patches/dwm-fixborders-6.2.diff b/dwm-6.2/patches/dwm-fixborders-6.2.diff deleted file mode 100644 index 0a17b9e..0000000 --- a/dwm-6.2/patches/dwm-fixborders-6.2.diff +++ /dev/null @@ -1,27 +0,0 @@ -From 1529909466206016f2101457bbf37c67195714c8 Mon Sep 17 00:00:00 2001 -From: Jakub Leszczak -Date: Fri, 22 Nov 2019 10:46:53 +0800 -Subject: [PATCH] Fix transparent borders - -When terminal has transparency then its borders also become transparent. -Fix it by removing transparency from any pixels drawn. ---- - drw.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drw.c b/drw.c -index 8fd1ca4..490a592 100644 ---- a/drw.c -+++ b/drw.c -@@ -202,6 +202,8 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname) - DefaultColormap(drw->dpy, drw->screen), - clrname, dest)) - die("error, cannot allocate color '%s'", clrname); -+ -+ dest->pixel |= 0xff << 24; - } - - /* Wrapper to create color schemes. The caller has to call free(3) on the --- -2.26.2 - diff --git a/dwm-6.2/patches/dwm-scratchpad-6.2.diff b/dwm-6.2/patches/dwm-scratchpad-6.2.diff deleted file mode 100644 index 2062263..0000000 --- a/dwm-6.2/patches/dwm-scratchpad-6.2.diff +++ /dev/null @@ -1,90 +0,0 @@ -diff -up a/config.def.h b/config.def.h ---- a/config.def.h 2019-06-06 21:23:27.006661784 +0200 -+++ b/config.def.h 2019-06-20 15:05:59.083102462 +0200 -@@ -58,11 +58,14 @@ static const Layout layouts[] = { - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ - static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; - static const char *termcmd[] = { "st", NULL }; -+static const char scratchpadname[] = "scratchpad"; -+static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; - - static Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, - { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, -+ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, - { MODKEY, XK_b, togglebar, {0} }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, -diff -up a/dwm.c b/dwm.c ---- a/dwm.c 2019-06-06 21:23:27.023328450 +0200 -+++ b/dwm.c 2019-06-20 15:07:01.089767947 +0200 -@@ -213,6 +213,7 @@ static void tagmon(const Arg *arg); - static void tile(Monitor *); - static void togglebar(const Arg *arg); - static void togglefloating(const Arg *arg); -+static void togglescratch(const Arg *arg); - static void toggletag(const Arg *arg); - static void toggleview(const Arg *arg); - static void unfocus(Client *c, int setfocus); -@@ -273,6 +274,8 @@ static Window root, wmcheckwin; - /* configuration, allows nested code to access above variables */ - #include "config.h" - -+static unsigned int scratchtag = 1 << LENGTH(tags); -+ - /* compile-time check if all tags fit into an unsigned int bit array. */ - struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; - -@@ -1052,6 +1055,14 @@ manage(Window w, XWindowAttributes *wa) - && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); - c->bw = borderpx; - -+ selmon->tagset[selmon->seltags] &= ~scratchtag; -+ if (!strcmp(c->name, scratchpadname)) { -+ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag; -+ c->isfloating = True; -+ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); -+ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); -+ } -+ - wc.border_width = c->bw; - XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); -@@ -1661,6 +1672,7 @@ spawn(const Arg *arg) - { - if (arg->v == dmenucmd) - dmenumon[0] = '0' + selmon->num; -+ selmon->tagset[selmon->seltags] &= ~scratchtag; - if (fork() == 0) { - if (dpy) - close(ConnectionNumber(dpy)); -@@ -1748,6 +1760,28 @@ togglefloating(const Arg *arg) - } - - void -+togglescratch(const Arg *arg) -+{ -+ Client *c; -+ unsigned int found = 0; -+ -+ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next); -+ if (found) { -+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; -+ if (newtagset) { -+ selmon->tagset[selmon->seltags] = newtagset; -+ focus(NULL); -+ arrange(selmon); -+ } -+ if (ISVISIBLE(c)) { -+ focus(c); -+ restack(selmon); -+ } -+ } else -+ spawn(arg); -+} -+ -+void - toggletag(const Arg *arg) - { - unsigned int newtags; diff --git a/dwm-6.2/patches/dwm-vanitygaps-20190508-6.2.diff b/dwm-6.2/patches/dwm-vanitygaps-20190508-6.2.diff deleted file mode 100644 index ea22e23..0000000 --- a/dwm-6.2/patches/dwm-vanitygaps-20190508-6.2.diff +++ /dev/null @@ -1,259 +0,0 @@ -From 20967685d6879bd611a856ade154df19da9ddc7b Mon Sep 17 00:00:00 2001 -From: Stein Gunnar Bakkeby -Date: Wed, 8 May 2019 08:07:14 +0200 -Subject: [PATCH] Vanity gaps - allows control of both inner and outer gaps - between windows and screen edge - ---- - config.def.h | 21 +++++++++ - dwm.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- - 2 files changed, 161 insertions(+), 10 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..0927c2d 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -3,6 +3,11 @@ - /* appearance */ - static const unsigned int borderpx = 1; /* border pixel of windows */ - static const unsigned int snap = 32; /* snap pixel */ -+static const unsigned int gappih = 10; /* horiz inner gap between windows */ -+static const unsigned int gappiv = 10; /* vert inner gap between windows */ -+static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ -+static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ -+static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ - static const int showbar = 1; /* 0 means no bar */ - static const int topbar = 1; /* 0 means bottom bar */ - static const char *fonts[] = { "monospace:size=10" }; -@@ -70,6 +75,22 @@ static Key keys[] = { - { MODKEY, XK_d, incnmaster, {.i = -1 } }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, -+ { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, -+ { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, -+ { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, -+ { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, -+ { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, -+ { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, -+ { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, -+ { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, -+ { MODKEY, XK_y, incrihgaps, {.i = +1 } }, -+ { MODKEY, XK_o, incrihgaps, {.i = -1 } }, -+ { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, -+ { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, -+ { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, -+ { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, -+ { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, -+ { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, - { MODKEY, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, -diff --git a/dwm.c b/dwm.c -index 4465af1..88f3e04 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -119,6 +119,10 @@ struct Monitor { - int by; /* bar geometry */ - int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ -+ int gappih; /* horizontal gap between windows */ -+ int gappiv; /* vertical gap between windows */ -+ int gappoh; /* horizontal outer gaps */ -+ int gappov; /* vertical outer gaps */ - unsigned int seltags; - unsigned int sellt; - unsigned int tagset[2]; -@@ -199,6 +203,16 @@ static void sendmon(Client *c, Monitor *m); - static void setclientstate(Client *c, long state); - static void setfocus(Client *c); - static void setfullscreen(Client *c, int fullscreen); -+static void setgaps(int oh, int ov, int ih, int iv); -+static void incrgaps(const Arg *arg); -+static void incrigaps(const Arg *arg); -+static void incrogaps(const Arg *arg); -+static void incrohgaps(const Arg *arg); -+static void incrovgaps(const Arg *arg); -+static void incrihgaps(const Arg *arg); -+static void incrivgaps(const Arg *arg); -+static void togglegaps(const Arg *arg); -+static void defaultgaps(const Arg *arg); - static void setlayout(const Arg *arg); - static void setmfact(const Arg *arg); - static void setup(void); -@@ -240,6 +254,7 @@ static char stext[256]; - static int screen; - static int sw, sh; /* X display screen geometry width, height */ - static int bh, blw = 0; /* bar geometry */ -+static int enablegaps = 1; /* enables gaps, used by togglegaps */ - static int lrpad; /* sum of left and right padding for text */ - static int (*xerrorxlib)(Display *, XErrorEvent *); - static unsigned int numlockmask = 0; -@@ -638,6 +653,10 @@ createmon(void) - m->nmaster = nmaster; - m->showbar = showbar; - m->topbar = topbar; -+ m->gappih = gappih; -+ m->gappiv = gappiv; -+ m->gappoh = gappoh; -+ m->gappov = gappov; - m->lt[0] = &layouts[0]; - m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); -@@ -1498,6 +1517,111 @@ setfullscreen(Client *c, int fullscreen) - } - - void -+setgaps(int oh, int ov, int ih, int iv) -+{ -+ if (oh < 0) oh = 0; -+ if (ov < 0) ov = 0; -+ if (ih < 0) ih = 0; -+ if (iv < 0) iv = 0; -+ -+ selmon->gappoh = oh; -+ selmon->gappov = ov; -+ selmon->gappih = ih; -+ selmon->gappiv = iv; -+ arrange(selmon); -+} -+ -+void -+togglegaps(const Arg *arg) -+{ -+ enablegaps = !enablegaps; -+ arrange(selmon); -+} -+ -+void -+defaultgaps(const Arg *arg) -+{ -+ setgaps(gappoh, gappov, gappih, gappiv); -+} -+ -+void -+incrgaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh + arg->i, -+ selmon->gappov + arg->i, -+ selmon->gappih + arg->i, -+ selmon->gappiv + arg->i -+ ); -+} -+ -+void -+incrigaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh, -+ selmon->gappov, -+ selmon->gappih + arg->i, -+ selmon->gappiv + arg->i -+ ); -+} -+ -+void -+incrogaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh + arg->i, -+ selmon->gappov + arg->i, -+ selmon->gappih, -+ selmon->gappiv -+ ); -+} -+ -+void -+incrohgaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh + arg->i, -+ selmon->gappov, -+ selmon->gappih, -+ selmon->gappiv -+ ); -+} -+ -+void -+incrovgaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh, -+ selmon->gappov + arg->i, -+ selmon->gappih, -+ selmon->gappiv -+ ); -+} -+ -+void -+incrihgaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh, -+ selmon->gappov, -+ selmon->gappih + arg->i, -+ selmon->gappiv -+ ); -+} -+ -+void -+incrivgaps(const Arg *arg) -+{ -+ setgaps( -+ selmon->gappoh, -+ selmon->gappov, -+ selmon->gappih, -+ selmon->gappiv + arg->i -+ ); -+} -+ -+void - setlayout(const Arg *arg) - { - if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) -@@ -1673,26 +1797,32 @@ tagmon(const Arg *arg) - void - tile(Monitor *m) - { -- unsigned int i, n, h, mw, my, ty; -+ unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; - -+ if (smartgaps == n) { -+ oe = 0; // outer gaps disabled -+ } -+ - if (n > m->nmaster) -- mw = m->nmaster ? m->ww * m->mfact : 0; -+ mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0; - else -- mw = m->ww; -- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) -+ mw = m->ww - 2*m->gappov*oe + m->gappiv*ie; -+ for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { -- h = (m->wh - my) / (MIN(n, m->nmaster) - i); -- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); -- my += HEIGHT(c); -+ r = MIN(n, m->nmaster) - i; -+ h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; -+ resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0); -+ my += HEIGHT(c) + m->gappih*ie; - } else { -- h = (m->wh - ty) / (n - i); -- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); -- ty += HEIGHT(c); -+ r = n - i; -+ h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; -+ resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0); -+ ty += HEIGHT(c) + m->gappih*ie; - } - } - --- -2.7.4 - diff --git a/dwm-6.2/patches/dwm-vanitygaps-6.2.diff b/dwm-6.2/patches/dwm-vanitygaps-6.2.diff new file mode 100644 index 0000000..18cbd6d --- /dev/null +++ b/dwm-6.2/patches/dwm-vanitygaps-6.2.diff @@ -0,0 +1,971 @@ +From 9709d08daa290c8c7319571cd9e6ef4ec40e7683 Mon Sep 17 00:00:00 2001 +From: bakkeby +Date: Wed, 6 May 2020 17:21:25 +0200 +Subject: [PATCH] vanitygaps - adds gaps to layouts + +This patch differentiates between inner and outer gaps as well as +horizontal and vertical gaps. + +The logic of these layouts also aims to be pixel perfect by ensuring +an even split of the available space and re-distributing the remainder +among the available clients. +--- + config.def.h | 38 ++- + dwm.c | 35 +-- + vanitygaps.c | 809 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 854 insertions(+), 28 deletions(-) + create mode 100644 vanitygaps.c + +diff --git a/config.def.h b/config.def.h +index 1c0b587..a886863 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -3,6 +3,11 @@ + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ ++static const unsigned int gappih = 20; /* horiz inner gap between windows */ ++static const unsigned int gappiv = 10; /* vert inner gap between windows */ ++static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ ++static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */ ++static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ + static const char *fonts[] = { "monospace:size=10" }; +@@ -36,11 +41,26 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] + static const int nmaster = 1; /* number of clients in master area */ + static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ + ++#define FORCE_VSPLIT 1 /* nrowgrid layout: force two clients to always split vertically */ ++#include "vanitygaps.c" ++ + static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ +- { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "[@]", spiral }, ++ { "[\\]", dwindle }, ++ { "H[]", deck }, ++ { "TTT", bstack }, ++ { "===", bstackhoriz }, ++ { "HHH", grid }, ++ { "###", nrowgrid }, ++ { "---", horizgrid }, ++ { ":::", gaplessgrid }, ++ { "|M|", centeredmaster }, ++ { ">M>", centeredfloatingmaster }, ++ { "><>", NULL }, /* no layout function means floating behavior */ ++ { NULL, NULL }, + }; + + /* key definitions */ +@@ -71,6 +91,22 @@ static Key keys[] = { + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, ++ { MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_u, incrgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_i, incrigaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_i, incrigaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_o, incrogaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_o, incrogaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_6, incrihgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_6, incrihgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_7, incrivgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_7, incrivgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_8, incrohgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_8, incrohgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_9, incrovgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, +diff --git a/dwm.c b/dwm.c +index 4465af1..c3b2d82 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -119,6 +119,10 @@ struct Monitor { + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ ++ int gappih; /* horizontal gap between windows */ ++ int gappiv; /* vertical gap between windows */ ++ int gappoh; /* horizontal outer gaps */ ++ int gappov; /* vertical outer gaps */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; +@@ -208,7 +212,6 @@ static void sigchld(int unused); + static void spawn(const Arg *arg); + static void tag(const Arg *arg); + static void tagmon(const Arg *arg); +-static void tile(Monitor *); + static void togglebar(const Arg *arg); + static void togglefloating(const Arg *arg); + static void toggletag(const Arg *arg); +@@ -638,6 +641,10 @@ createmon(void) + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; ++ m->gappih = gappih; ++ m->gappiv = gappiv; ++ m->gappoh = gappoh; ++ m->gappov = gappov; + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); +@@ -1670,32 +1677,6 @@ tagmon(const Arg *arg) + sendmon(selmon->sel, dirtomon(arg->i)); + } + +-void +-tile(Monitor *m) +-{ +- unsigned int i, n, h, mw, my, ty; +- Client *c; +- +- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); +- if (n == 0) +- return; +- +- if (n > m->nmaster) +- mw = m->nmaster ? m->ww * m->mfact : 0; +- else +- mw = m->ww; +- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) +- if (i < m->nmaster) { +- h = (m->wh - my) / (MIN(n, m->nmaster) - i); +- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); +- my += HEIGHT(c); +- } else { +- h = (m->wh - ty) / (n - i); +- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); +- ty += HEIGHT(c); +- } +-} +- + void + togglebar(const Arg *arg) + { +diff --git a/vanitygaps.c b/vanitygaps.c +new file mode 100644 +index 0000000..3f31593 +--- /dev/null ++++ b/vanitygaps.c +@@ -0,0 +1,809 @@ ++/* Key binding functions */ ++static void defaultgaps(const Arg *arg); ++static void incrgaps(const Arg *arg); ++static void incrigaps(const Arg *arg); ++static void incrogaps(const Arg *arg); ++static void incrohgaps(const Arg *arg); ++static void incrovgaps(const Arg *arg); ++static void incrihgaps(const Arg *arg); ++static void incrivgaps(const Arg *arg); ++static void togglegaps(const Arg *arg); ++/* Layouts (delete the ones you do not need) */ ++static void bstack(Monitor *m); ++static void bstackhoriz(Monitor *m); ++static void centeredmaster(Monitor *m); ++static void centeredfloatingmaster(Monitor *m); ++static void deck(Monitor *m); ++static void dwindle(Monitor *m); ++static void fibonacci(Monitor *m, int s); ++static void grid(Monitor *m); ++static void nrowgrid(Monitor *m); ++static void spiral(Monitor *m); ++static void tile(Monitor *m); ++/* Internals */ ++static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc); ++static void getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr); ++static void setgaps(int oh, int ov, int ih, int iv); ++ ++/* Settings */ ++#if !PERTAG_PATCH ++static int enablegaps = 1; ++#endif // PERTAG_PATCH ++ ++void ++setgaps(int oh, int ov, int ih, int iv) ++{ ++ if (oh < 0) oh = 0; ++ if (ov < 0) ov = 0; ++ if (ih < 0) ih = 0; ++ if (iv < 0) iv = 0; ++ ++ selmon->gappoh = oh; ++ selmon->gappov = ov; ++ selmon->gappih = ih; ++ selmon->gappiv = iv; ++ arrange(selmon); ++} ++ ++void ++togglegaps(const Arg *arg) ++{ ++ #if PERTAG_PATCH ++ selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag]; ++ #else ++ enablegaps = !enablegaps; ++ #endif // PERTAG_PATCH ++ arrange(NULL); ++} ++ ++void ++defaultgaps(const Arg *arg) ++{ ++ setgaps(gappoh, gappov, gappih, gappiv); ++} ++ ++void ++incrgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh + arg->i, ++ selmon->gappov + arg->i, ++ selmon->gappih + arg->i, ++ selmon->gappiv + arg->i ++ ); ++} ++ ++void ++incrigaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov, ++ selmon->gappih + arg->i, ++ selmon->gappiv + arg->i ++ ); ++} ++ ++void ++incrogaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh + arg->i, ++ selmon->gappov + arg->i, ++ selmon->gappih, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrohgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh + arg->i, ++ selmon->gappov, ++ selmon->gappih, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrovgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov + arg->i, ++ selmon->gappih, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrihgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov, ++ selmon->gappih + arg->i, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrivgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov, ++ selmon->gappih, ++ selmon->gappiv + arg->i ++ ); ++} ++ ++void ++getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc) ++{ ++ unsigned int n, oe, ie; ++ #if PERTAG_PATCH ++ oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag]; ++ #else ++ oe = ie = enablegaps; ++ #endif // PERTAG_PATCH ++ Client *c; ++ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); ++ if (smartgaps && n == 1) { ++ oe = 0; // outer gaps disabled when only one client ++ } ++ ++ *oh = m->gappoh*oe; // outer horizontal gap ++ *ov = m->gappov*oe; // outer vertical gap ++ *ih = m->gappih*ie; // inner horizontal gap ++ *iv = m->gappiv*ie; // inner vertical gap ++ *nc = n; // number of clients ++} ++ ++void ++getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr) ++{ ++ unsigned int n; ++ float mfacts, sfacts; ++ int mtotal = 0, stotal = 0; ++ Client *c; ++ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); ++ mfacts = MIN(n, m->nmaster); ++ sfacts = n - m->nmaster; ++ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ++ if (n < m->nmaster) ++ mtotal += msize / mfacts; ++ else ++ stotal += ssize / sfacts; ++ ++ *mf = mfacts; // total factor of master area ++ *sf = sfacts; // total factor of stack area ++ *mr = msize - mtotal; // the remainder (rest) of pixels after an even master split ++ *sr = ssize - stotal; // the remainder (rest) of pixels after an even stack split ++} ++ ++/*** ++ * Layouts ++ */ ++ ++/* ++ * Bottomstack layout + gaps ++ * https://dwm.suckless.org/patches/bottomstack/ ++ */ ++static void ++bstack(Monitor *m) ++{ ++ unsigned int i, n; ++ int oh, ov, ih, iv; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int sx = 0, sy = 0, sh = 0, sw = 0; ++ float mfacts, sfacts; ++ int mrest, srest; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ sx = mx = m->wx + ov; ++ sy = my = m->wy + oh; ++ sh = mh = m->wh - 2*oh; ++ mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); ++ sw = m->ww - 2*ov - iv * (n - m->nmaster - 1); ++ ++ if (m->nmaster && n > m->nmaster) { ++ sh = (mh - ih) * (1 - m->mfact); ++ mh = mh - ih - sh; ++ sx = mx; ++ sy = my + mh + ih; ++ } ++ ++ getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { ++ if (i < m->nmaster) { ++ resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); ++ mx += WIDTH(c) + iv; ++ } else { ++ resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); ++ sx += WIDTH(c) + iv; ++ } ++ } ++} ++ ++static void ++bstackhoriz(Monitor *m) ++{ ++ unsigned int i, n; ++ int oh, ov, ih, iv; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int sx = 0, sy = 0, sh = 0, sw = 0; ++ float mfacts, sfacts; ++ int mrest, srest; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ sx = mx = m->wx + ov; ++ sy = my = m->wy + oh; ++ mh = m->wh - 2*oh; ++ sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); ++ mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); ++ sw = m->ww - 2*ov; ++ ++ if (m->nmaster && n > m->nmaster) { ++ sh = (mh - ih) * (1 - m->mfact); ++ mh = mh - ih - sh; ++ sy = my + mh + ih; ++ sh = m->wh - mh - 2*oh - ih * (n - m->nmaster); ++ } ++ ++ getfacts(m, mw, sh, &mfacts, &sfacts, &mrest, &srest); ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { ++ if (i < m->nmaster) { ++ resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); ++ mx += WIDTH(c) + iv; ++ } else { ++ resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); ++ sy += HEIGHT(c) + ih; ++ } ++ } ++} ++ ++/* ++ * Centred master layout + gaps ++ * https://dwm.suckless.org/patches/centeredmaster/ ++ */ ++void ++centeredmaster(Monitor *m) ++{ ++ unsigned int i, n; ++ int oh, ov, ih, iv; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int lx = 0, ly = 0, lw = 0, lh = 0; ++ int rx = 0, ry = 0, rw = 0, rh = 0; ++ float mfacts = 0, lfacts = 0, rfacts = 0; ++ int mtotal = 0, ltotal = 0, rtotal = 0; ++ int mrest = 0, lrest = 0, rrest = 0; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ /* initialize areas */ ++ mx = m->wx + ov; ++ my = m->wy + oh; ++ mh = m->wh - 2*oh - ih * ((!m->nmaster ? n : MIN(n, m->nmaster)) - 1); ++ mw = m->ww - 2*ov; ++ lh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - 1); ++ rh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - ((n - m->nmaster) % 2 ? 0 : 1)); ++ ++ if (m->nmaster && n > m->nmaster) { ++ /* go mfact box in the center if more than nmaster clients */ ++ if (n - m->nmaster > 1) { ++ /* ||<-S->|<---M--->|<-S->|| */ ++ mw = (m->ww - 2*ov - 2*iv) * m->mfact; ++ lw = (m->ww - mw - 2*ov - 2*iv) / 2; ++ rw = (m->ww - mw - 2*ov - 2*iv) - lw; ++ mx += lw + iv; ++ } else { ++ /* ||<---M--->|<-S->|| */ ++ mw = (mw - iv) * m->mfact; ++ lw = 0; ++ rw = m->ww - mw - iv - 2*ov; ++ } ++ lx = m->wx + ov; ++ ly = m->wy + oh; ++ rx = mx + mw + iv; ++ ry = m->wy + oh; ++ } ++ ++ /* calculate facts */ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { ++ if (!m->nmaster || n < m->nmaster) ++ mfacts += 1; ++ else if ((n - m->nmaster) % 2) ++ lfacts += 1; // total factor of left hand stack area ++ else ++ rfacts += 1; // total factor of right hand stack area ++ } ++ ++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ++ if (!m->nmaster || n < m->nmaster) ++ mtotal += mh / mfacts; ++ else if ((n - m->nmaster) % 2) ++ ltotal += lh / lfacts; ++ else ++ rtotal += rh / rfacts; ++ ++ mrest = mh - mtotal; ++ lrest = lh - ltotal; ++ rrest = rh - rtotal; ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { ++ if (!m->nmaster || i < m->nmaster) { ++ /* nmaster clients are stacked vertically, in the center of the screen */ ++ resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); ++ my += HEIGHT(c) + ih; ++ } else { ++ /* stack clients are stacked vertically */ ++ if ((i - m->nmaster) % 2 ) { ++ resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); ++ ly += HEIGHT(c) + ih; ++ } else { ++ resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); ++ ry += HEIGHT(c) + ih; ++ } ++ } ++ } ++} ++ ++void ++centeredfloatingmaster(Monitor *m) ++{ ++ unsigned int i, n; ++ float mfacts, sfacts; ++ float mivf = 1.0; // master inner vertical gap factor ++ int oh, ov, ih, iv, mrest, srest; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int sx = 0, sy = 0, sh = 0, sw = 0; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ sx = mx = m->wx + ov; ++ sy = my = m->wy + oh; ++ sh = mh = m->wh - 2*oh; ++ mw = m->ww - 2*ov - iv*(n - 1); ++ sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); ++ ++ if (m->nmaster && n > m->nmaster) { ++ mivf = 0.8; ++ /* go mfact box in the center if more than nmaster clients */ ++ if (m->ww > m->wh) { ++ mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); ++ mh = m->wh * 0.9; ++ } else { ++ mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1); ++ mh = m->wh * m->mfact; ++ } ++ mx = m->wx + (m->ww - mw) / 2; ++ my = m->wy + (m->wh - mh - 2*oh) / 2; ++ ++ sx = m->wx + ov; ++ sy = m->wy + oh; ++ sh = m->wh - 2*oh; ++ } ++ ++ getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ if (i < m->nmaster) { ++ /* nmaster clients are stacked horizontally, in the center of the screen */ ++ resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); ++ mx += WIDTH(c) + iv*mivf; ++ } else { ++ /* stack clients are stacked horizontally */ ++ resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); ++ sx += WIDTH(c) + iv; ++ } ++} ++ ++/* ++ * Deck layout + gaps ++ * https://dwm.suckless.org/patches/deck/ ++ */ ++void ++deck(Monitor *m) ++{ ++ unsigned int i, n; ++ int oh, ov, ih, iv; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int sx = 0, sy = 0, sh = 0, sw = 0; ++ float mfacts, sfacts; ++ int mrest, srest; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ sx = mx = m->wx + ov; ++ sy = my = m->wy + oh; ++ sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); ++ sw = mw = m->ww - 2*ov; ++ ++ if (m->nmaster && n > m->nmaster) { ++ sw = (mw - iv) * (1 - m->mfact); ++ mw = mw - iv - sw; ++ sx = mx + mw + iv; ++ sh = m->wh - 2*oh; ++ } ++ ++ getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); ++ ++ if (n - m->nmaster > 0) /* override layout symbol */ ++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster); ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ if (i < m->nmaster) { ++ resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); ++ my += HEIGHT(c) + ih; ++ } else { ++ resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0); ++ } ++} ++ ++/* ++ * Fibonacci layout + gaps ++ * https://dwm.suckless.org/patches/fibonacci/ ++ */ ++void ++fibonacci(Monitor *m, int s) ++{ ++ unsigned int i, n; ++ int nx, ny, nw, nh; ++ int oh, ov, ih, iv; ++ int nv, hrest = 0, wrest = 0, r = 1; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ nx = m->wx + ov; ++ ny = m->wy + oh; ++ nw = m->ww - 2*ov; ++ nh = m->wh - 2*oh; ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { ++ if (r) { ++ if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw)) ++ || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) { ++ r = 0; ++ } ++ if (r && i < n - 1) { ++ if (i % 2) { ++ nv = (nh - ih) / 2; ++ hrest = nh - 2*nv - ih; ++ nh = nv; ++ } else { ++ nv = (nw - iv) / 2; ++ wrest = nw - 2*nv - iv; ++ nw = nv; ++ } ++ ++ if ((i % 4) == 2 && !s) ++ nx += nw + iv; ++ else if ((i % 4) == 3 && !s) ++ ny += nh + ih; ++ } ++ ++ if ((i % 4) == 0) { ++ if (s) { ++ ny += nh + ih; ++ nh += hrest; ++ } ++ else { ++ nh -= hrest; ++ ny -= nh + ih; ++ } ++ } ++ else if ((i % 4) == 1) { ++ nx += nw + iv; ++ nw += wrest; ++ } ++ else if ((i % 4) == 2) { ++ ny += nh + ih; ++ nh += hrest; ++ if (i < n - 1) ++ nw += wrest; ++ } ++ else if ((i % 4) == 3) { ++ if (s) { ++ nx += nw + iv; ++ nw -= wrest; ++ } else { ++ nw -= wrest; ++ nx -= nw + iv; ++ nh += hrest; ++ } ++ } ++ if (i == 0) { ++ if (n != 1) { ++ nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact); ++ wrest = 0; ++ } ++ ny = m->wy + oh; ++ } ++ else if (i == 1) ++ nw = m->ww - nw - iv - 2*ov; ++ i++; ++ } ++ ++ resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); ++ } ++} ++ ++void ++dwindle(Monitor *m) ++{ ++ fibonacci(m, 1); ++} ++ ++void ++spiral(Monitor *m) ++{ ++ fibonacci(m, 0); ++} ++ ++/* ++ * Gappless grid layout + gaps (ironically) ++ * https://dwm.suckless.org/patches/gaplessgrid/ ++ */ ++void ++gaplessgrid(Monitor *m) ++{ ++ unsigned int i, n; ++ int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters ++ int oh, ov, ih, iv; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ /* grid dimensions */ ++ for (cols = 0; cols <= n/2; cols++) ++ if (cols*cols >= n) ++ break; ++ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ ++ cols = 2; ++ rows = n/cols; ++ cn = rn = 0; // reset column no, row no, client count ++ ++ ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; ++ cw = (m->ww - 2*ov - iv * (cols - 1)) / cols; ++ rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; ++ crest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; ++ x = m->wx + ov; ++ y = m->wy + oh; ++ ++ for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { ++ if (i/rows + 1 > cols - n%cols) { ++ rows = n/cols + 1; ++ ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; ++ rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; ++ } ++ resize(c, ++ x, ++ y + rn*(ch + ih) + MIN(rn, rrest), ++ cw + (cn < crest ? 1 : 0) - 2*c->bw, ++ ch + (rn < rrest ? 1 : 0) - 2*c->bw, ++ 0); ++ rn++; ++ if (rn >= rows) { ++ rn = 0; ++ x += cw + ih + (cn < crest ? 1 : 0); ++ cn++; ++ } ++ } ++} ++ ++/* ++ * Gridmode layout + gaps ++ * https://dwm.suckless.org/patches/gridmode/ ++ */ ++void ++grid(Monitor *m) ++{ ++ unsigned int i, n; ++ int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows; ++ int oh, ov, ih, iv; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ ++ /* grid dimensions */ ++ for (rows = 0; rows <= n/2; rows++) ++ if (rows*rows >= n) ++ break; ++ cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; ++ ++ /* window geoms (cell height/width) */ ++ ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1); ++ cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1); ++ chrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; ++ cwrest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { ++ cc = i / rows; ++ cr = i % rows; ++ cx = m->wx + ov + cc * (cw + iv) + MIN(cc, cwrest); ++ cy = m->wy + oh + cr * (ch + ih) + MIN(cr, chrest); ++ resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); ++ } ++} ++ ++/* ++ * Horizontal grid layout + gaps ++ * https://dwm.suckless.org/patches/horizgrid/ ++ */ ++void ++horizgrid(Monitor *m) { ++ Client *c; ++ unsigned int n, i; ++ int oh, ov, ih, iv; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int sx = 0, sy = 0, sh = 0, sw = 0; ++ int ntop, nbottom = 1; ++ float mfacts, sfacts; ++ int mrest, srest; ++ ++ /* Count windows */ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ if (n <= 2) ++ ntop = n; ++ else { ++ ntop = n / 2; ++ nbottom = n - ntop; ++ } ++ sx = mx = m->wx + ov; ++ sy = my = m->wy + oh; ++ sh = mh = m->wh - 2*oh; ++ sw = mw = m->ww - 2*ov; ++ ++ if (n > ntop) { ++ sh = (mh - ih) / 2; ++ mh = mh - ih - sh; ++ sy = my + mh + ih; ++ mw = m->ww - 2*ov - iv * (ntop - 1); ++ sw = m->ww - 2*ov - iv * (nbottom - 1); ++ } ++ ++ mfacts = ntop; ++ sfacts = nbottom; ++ mrest = mw - (mw / ntop) * ntop; ++ srest = sw - (sw / nbottom) * nbottom; ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ if (i < ntop) { ++ resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); ++ mx += WIDTH(c) + iv; ++ } else { ++ resize(c, sx, sy, (sw / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); ++ sx += WIDTH(c) + iv; ++ } ++} ++ ++/* ++ * nrowgrid layout + gaps ++ * https://dwm.suckless.org/patches/nrowgrid/ ++ */ ++void ++nrowgrid(Monitor *m) ++{ ++ unsigned int n; ++ int ri = 0, ci = 0; /* counters */ ++ int oh, ov, ih, iv; /* vanitygap settings */ ++ unsigned int cx, cy, cw, ch; /* client geometry */ ++ unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */ ++ unsigned int cols, rows = m->nmaster + 1; ++ Client *c; ++ ++ /* count clients */ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ ++ /* nothing to do here */ ++ if (n == 0) ++ return; ++ ++ /* force 2 clients to always split vertically */ ++ if (FORCE_VSPLIT && n == 2) ++ rows = 1; ++ ++ /* never allow empty rows */ ++ if (n < rows) ++ rows = n; ++ ++ /* define first row */ ++ cols = n / rows; ++ uc = cols; ++ cy = m->wy + oh; ++ ch = (m->wh - 2*oh - ih*(rows - 1)) / rows; ++ uh = ch; ++ ++ for (c = nexttiled(m->clients); c; c = nexttiled(c->next), ci++) { ++ if (ci == cols) { ++ uw = 0; ++ ci = 0; ++ ri++; ++ ++ /* next row */ ++ cols = (n - uc) / (rows - ri); ++ uc += cols; ++ cy = m->wy + oh + uh + ih; ++ uh += ch + ih; ++ } ++ ++ cx = m->wx + ov + uw; ++ cw = (m->ww - 2*ov - uw) / (cols - ci); ++ uw += cw + iv; ++ ++ resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0); ++ } ++} ++ ++/* ++ * Default tile layout + gaps ++ */ ++static void ++tile(Monitor *m) ++{ ++ unsigned int i, n; ++ int oh, ov, ih, iv; ++ int mx = 0, my = 0, mh = 0, mw = 0; ++ int sx = 0, sy = 0, sh = 0, sw = 0; ++ float mfacts, sfacts; ++ int mrest, srest; ++ Client *c; ++ ++ getgaps(m, &oh, &ov, &ih, &iv, &n); ++ if (n == 0) ++ return; ++ ++ sx = mx = m->wx + ov; ++ sy = my = m->wy + oh; ++ mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); ++ sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); ++ sw = mw = m->ww - 2*ov; ++ ++ if (m->nmaster && n > m->nmaster) { ++ sw = (mw - iv) * (1 - m->mfact); ++ mw = mw - iv - sw; ++ sx = mx + mw + iv; ++ } ++ ++ getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); ++ ++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ if (i < m->nmaster) { ++ resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); ++ my += HEIGHT(c) + ih; ++ } else { ++ resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); ++ sy += HEIGHT(c) + ih; ++ } ++} +\ No newline at end of file +-- +2.19.1 + diff --git a/dwm-6.2/patches/sarc-autostart.diff b/dwm-6.2/patches/sarc-autostart.diff deleted file mode 100644 index efee676..0000000 --- a/dwm-6.2/patches/sarc-autostart.diff +++ /dev/null @@ -1,179 +0,0 @@ -From 37e970479dc5d40e57fc0cbfeaa5e39941483237 Mon Sep 17 00:00:00 2001 -From: Gan Ainm -Date: Wed, 10 Jun 2020 10:59:02 +0000 -Subject: [PATCH] dwm-xdgautostart-6.2.diff - -=================================================================== ---- - dwm.1 | 23 +++++++++++++++++ - dwm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 105 insertions(+) - -diff --git a/dwm.1 b/dwm.1 -index 13b3729..9533aa6 100644 ---- a/dwm.1 -+++ b/dwm.1 -@@ -30,6 +30,14 @@ top left corner. The tags which are applied to one or more windows are - indicated with an empty square in the top left corner. - .P - dwm draws a small border around windows to indicate the focus state. -+.P -+On start, dwm can start additional programs that may be specified in two special -+shell scripts (see the FILES section below), autostart_blocking.sh and -+autostart.sh. The former is executed first and dwm will wait for its -+termination before starting. The latter is executed in the background before -+dwm enters its handler loop. -+.P -+Either of these files may be omitted. - .SH OPTIONS - .TP - .B \-v -@@ -152,6 +160,21 @@ Toggles focused window between floating and tiled state. - .TP - .B Mod1\-Button3 - Resize focused window while dragging. Tiled windows will be toggled to the floating state. -+.SH FILES -+The files containing programs to be started along with dwm are searched for in -+the following directories: -+.IP "1. $XDG_DATA_HOME/dwm" -+.IP "2. $HOME/.local/share/dwm" -+.IP "3. $HOME/.dwm" -+.P -+The first existing directory is scanned for any of the autostart files below. -+.TP 15 -+autostart.sh -+This file is started as a shell background process before dwm enters its handler -+loop. -+.TP 15 -+autostart_blocking.sh -+This file is started before any autostart.sh; dwm waits for its termination. - .SH CUSTOMIZATION - dwm is customized by creating a custom config.h and (re)compiling the source - code. This keeps it fast, secure and simple. -diff --git a/dwm.c b/dwm.c -index 4465af1..2156b49 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -193,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h); - static void resizemouse(const Arg *arg); - static void restack(Monitor *m); - static void run(void); -+static void runautostart(void); - static void scan(void); - static int sendevent(Client *c, Atom proto); - static void sendmon(Client *c, Monitor *m); -@@ -235,7 +237,11 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); - static void zoom(const Arg *arg); - - /* variables */ -+static const char autostartblocksh[] = "autostart_blocking.sh"; -+static const char autostartsh[] = "autostart.sh"; - static const char broken[] = "broken"; -+static const char dwmdir[] = "dwm"; -+static const char localshare[] = ".local/share"; - static char stext[256]; - static int screen; - static int sw, sh; /* X display screen geometry width, height */ -@@ -1380,6 +1386,83 @@ run(void) - handler[ev.type](&ev); /* call handler */ - } - -+void -+runautostart(void) -+{ -+ char *pathpfx; -+ char *path; -+ char *xdgdatahome; -+ char *home; -+ struct stat sb; -+ -+ if ((home = getenv("HOME")) == NULL) -+ /* this is almost impossible */ -+ return; -+ -+ /* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm, -+ * otherwise use ~/.local/share/dwm as autostart script directory -+ */ -+ xdgdatahome = getenv("XDG_DATA_HOME"); -+ if (xdgdatahome != NULL && *xdgdatahome != '\0') { -+ /* space for path segments, separators and nul */ -+ pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2); -+ -+ if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) { -+ free(pathpfx); -+ return; -+ } -+ } else { -+ /* space for path segments, separators and nul */ -+ pathpfx = ecalloc(1, strlen(home) + strlen(localshare) -+ + strlen(dwmdir) + 3); -+ -+ if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) { -+ free(pathpfx); -+ return; -+ } -+ } -+ -+ /* check if the autostart script directory exists */ -+ if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) { -+ /* the XDG conformant path does not exist or is no directory -+ * so we try ~/.dwm instead -+ */ -+ char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3); -+ if(pathpfx_new == NULL) { -+ free(pathpfx); -+ return; -+ } -+ pathpfx = pathpfx_new; -+ -+ if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) { -+ free(pathpfx); -+ return; -+ } -+ } -+ -+ /* try the blocking script first */ -+ path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2); -+ if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) { -+ free(path); -+ free(pathpfx); -+ } -+ -+ if (access(path, X_OK) == 0) -+ system(path); -+ -+ /* now the non-blocking script */ -+ if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) { -+ free(path); -+ free(pathpfx); -+ } -+ -+ if (access(path, X_OK) == 0) -+ system(strcat(path, " &")); -+ -+ free(pathpfx); -+ free(path); -+} -+ - void - scan(void) - { -@@ -2142,6 +2223,7 @@ main(int argc, char *argv[]) - die("pledge"); - #endif /* __OpenBSD__ */ - scan(); -+ runautostart(); - run(); - cleanup(); - XCloseDisplay(dpy); --- -2.27.0 - diff --git a/dwm-6.2/util.o b/dwm-6.2/util.o new file mode 100644 index 0000000..3b48c2f Binary files /dev/null and b/dwm-6.2/util.o differ diff --git a/dwm-6.2/vanitygaps.c b/dwm-6.2/vanitygaps.c new file mode 100644 index 0000000..3f31593 --- /dev/null +++ b/dwm-6.2/vanitygaps.c @@ -0,0 +1,809 @@ +/* Key binding functions */ +static void defaultgaps(const Arg *arg); +static void incrgaps(const Arg *arg); +static void incrigaps(const Arg *arg); +static void incrogaps(const Arg *arg); +static void incrohgaps(const Arg *arg); +static void incrovgaps(const Arg *arg); +static void incrihgaps(const Arg *arg); +static void incrivgaps(const Arg *arg); +static void togglegaps(const Arg *arg); +/* Layouts (delete the ones you do not need) */ +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); +static void centeredmaster(Monitor *m); +static void centeredfloatingmaster(Monitor *m); +static void deck(Monitor *m); +static void dwindle(Monitor *m); +static void fibonacci(Monitor *m, int s); +static void grid(Monitor *m); +static void nrowgrid(Monitor *m); +static void spiral(Monitor *m); +static void tile(Monitor *m); +/* Internals */ +static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc); +static void getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr); +static void setgaps(int oh, int ov, int ih, int iv); + +/* Settings */ +#if !PERTAG_PATCH +static int enablegaps = 1; +#endif // PERTAG_PATCH + +void +setgaps(int oh, int ov, int ih, int iv) +{ + if (oh < 0) oh = 0; + if (ov < 0) ov = 0; + if (ih < 0) ih = 0; + if (iv < 0) iv = 0; + + selmon->gappoh = oh; + selmon->gappov = ov; + selmon->gappih = ih; + selmon->gappiv = iv; + arrange(selmon); +} + +void +togglegaps(const Arg *arg) +{ + #if PERTAG_PATCH + selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag]; + #else + enablegaps = !enablegaps; + #endif // PERTAG_PATCH + arrange(NULL); +} + +void +defaultgaps(const Arg *arg) +{ + setgaps(gappoh, gappov, gappih, gappiv); +} + +void +incrgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh + arg->i, + selmon->gappov + arg->i, + selmon->gappih + arg->i, + selmon->gappiv + arg->i + ); +} + +void +incrigaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov, + selmon->gappih + arg->i, + selmon->gappiv + arg->i + ); +} + +void +incrogaps(const Arg *arg) +{ + setgaps( + selmon->gappoh + arg->i, + selmon->gappov + arg->i, + selmon->gappih, + selmon->gappiv + ); +} + +void +incrohgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh + arg->i, + selmon->gappov, + selmon->gappih, + selmon->gappiv + ); +} + +void +incrovgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov + arg->i, + selmon->gappih, + selmon->gappiv + ); +} + +void +incrihgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov, + selmon->gappih + arg->i, + selmon->gappiv + ); +} + +void +incrivgaps(const Arg *arg) +{ + setgaps( + selmon->gappoh, + selmon->gappov, + selmon->gappih, + selmon->gappiv + arg->i + ); +} + +void +getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc) +{ + unsigned int n, oe, ie; + #if PERTAG_PATCH + oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag]; + #else + oe = ie = enablegaps; + #endif // PERTAG_PATCH + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (smartgaps && n == 1) { + oe = 0; // outer gaps disabled when only one client + } + + *oh = m->gappoh*oe; // outer horizontal gap + *ov = m->gappov*oe; // outer vertical gap + *ih = m->gappih*ie; // inner horizontal gap + *iv = m->gappiv*ie; // inner vertical gap + *nc = n; // number of clients +} + +void +getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr) +{ + unsigned int n; + float mfacts, sfacts; + int mtotal = 0, stotal = 0; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + mfacts = MIN(n, m->nmaster); + sfacts = n - m->nmaster; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) + if (n < m->nmaster) + mtotal += msize / mfacts; + else + stotal += ssize / sfacts; + + *mf = mfacts; // total factor of master area + *sf = sfacts; // total factor of stack area + *mr = msize - mtotal; // the remainder (rest) of pixels after an even master split + *sr = ssize - stotal; // the remainder (rest) of pixels after an even stack split +} + +/*** + * Layouts + */ + +/* + * Bottomstack layout + gaps + * https://dwm.suckless.org/patches/bottomstack/ + */ +static void +bstack(Monitor *m) +{ + unsigned int i, n; + int oh, ov, ih, iv; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh; + mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); + sw = m->ww - 2*ov - iv * (n - m->nmaster - 1); + + if (m->nmaster && n > m->nmaster) { + sh = (mh - ih) * (1 - m->mfact); + mh = mh - ih - sh; + sx = mx; + sy = my + mh + ih; + } + + getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + mx += WIDTH(c) + iv; + } else { + resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + sx += WIDTH(c) + iv; + } + } +} + +static void +bstackhoriz(Monitor *m) +{ + unsigned int i, n; + int oh, ov, ih, iv; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + mh = m->wh - 2*oh; + sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); + mw = m->ww - 2*ov - iv * (MIN(n, m->nmaster) - 1); + sw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sh = (mh - ih) * (1 - m->mfact); + mh = mh - ih - sh; + sy = my + mh + ih; + sh = m->wh - mh - 2*oh - ih * (n - m->nmaster); + } + + getfacts(m, mw, sh, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + mx += WIDTH(c) + iv; + } else { + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + sy += HEIGHT(c) + ih; + } + } +} + +/* + * Centred master layout + gaps + * https://dwm.suckless.org/patches/centeredmaster/ + */ +void +centeredmaster(Monitor *m) +{ + unsigned int i, n; + int oh, ov, ih, iv; + int mx = 0, my = 0, mh = 0, mw = 0; + int lx = 0, ly = 0, lw = 0, lh = 0; + int rx = 0, ry = 0, rw = 0, rh = 0; + float mfacts = 0, lfacts = 0, rfacts = 0; + int mtotal = 0, ltotal = 0, rtotal = 0; + int mrest = 0, lrest = 0, rrest = 0; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + /* initialize areas */ + mx = m->wx + ov; + my = m->wy + oh; + mh = m->wh - 2*oh - ih * ((!m->nmaster ? n : MIN(n, m->nmaster)) - 1); + mw = m->ww - 2*ov; + lh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - 1); + rh = m->wh - 2*oh - ih * (((n - m->nmaster) / 2) - ((n - m->nmaster) % 2 ? 0 : 1)); + + if (m->nmaster && n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (n - m->nmaster > 1) { + /* ||<-S->|<---M--->|<-S->|| */ + mw = (m->ww - 2*ov - 2*iv) * m->mfact; + lw = (m->ww - mw - 2*ov - 2*iv) / 2; + rw = (m->ww - mw - 2*ov - 2*iv) - lw; + mx += lw + iv; + } else { + /* ||<---M--->|<-S->|| */ + mw = (mw - iv) * m->mfact; + lw = 0; + rw = m->ww - mw - iv - 2*ov; + } + lx = m->wx + ov; + ly = m->wy + oh; + rx = mx + mw + iv; + ry = m->wy + oh; + } + + /* calculate facts */ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (!m->nmaster || n < m->nmaster) + mfacts += 1; + else if ((n - m->nmaster) % 2) + lfacts += 1; // total factor of left hand stack area + else + rfacts += 1; // total factor of right hand stack area + } + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) + if (!m->nmaster || n < m->nmaster) + mtotal += mh / mfacts; + else if ((n - m->nmaster) % 2) + ltotal += lh / lfacts; + else + rtotal += rh / rfacts; + + mrest = mh - mtotal; + lrest = lh - ltotal; + rrest = rh - rtotal; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (!m->nmaster || i < m->nmaster) { + /* nmaster clients are stacked vertically, in the center of the screen */ + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + my += HEIGHT(c) + ih; + } else { + /* stack clients are stacked vertically */ + if ((i - m->nmaster) % 2 ) { + resize(c, lx, ly, lw - (2*c->bw), (lh / lfacts) + ((i - 2*m->nmaster) < 2*lrest ? 1 : 0) - (2*c->bw), 0); + ly += HEIGHT(c) + ih; + } else { + resize(c, rx, ry, rw - (2*c->bw), (rh / rfacts) + ((i - 2*m->nmaster) < 2*rrest ? 1 : 0) - (2*c->bw), 0); + ry += HEIGHT(c) + ih; + } + } + } +} + +void +centeredfloatingmaster(Monitor *m) +{ + unsigned int i, n; + float mfacts, sfacts; + float mivf = 1.0; // master inner vertical gap factor + int oh, ov, ih, iv, mrest, srest; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh; + mw = m->ww - 2*ov - iv*(n - 1); + sw = m->ww - 2*ov - iv*(n - m->nmaster - 1); + + if (m->nmaster && n > m->nmaster) { + mivf = 0.8; + /* go mfact box in the center if more than nmaster clients */ + if (m->ww > m->wh) { + mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1); + mh = m->wh * 0.9; + } else { + mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1); + mh = m->wh * m->mfact; + } + mx = m->wx + (m->ww - mw) / 2; + my = m->wy + (m->wh - mh - 2*oh) / 2; + + sx = m->wx + ov; + sy = m->wy + oh; + sh = m->wh - 2*oh; + } + + getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + /* nmaster clients are stacked horizontally, in the center of the screen */ + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + mx += WIDTH(c) + iv*mivf; + } else { + /* stack clients are stacked horizontally */ + resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + sx += WIDTH(c) + iv; + } +} + +/* + * Deck layout + gaps + * https://dwm.suckless.org/patches/deck/ + */ +void +deck(Monitor *m) +{ + unsigned int i, n; + int oh, ov, ih, iv; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); + sw = mw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sw = (mw - iv) * (1 - m->mfact); + mw = mw - iv - sw; + sx = mx + mw + iv; + sh = m->wh - 2*oh; + } + + getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); + + if (n - m->nmaster > 0) /* override layout symbol */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "D %d", n - m->nmaster); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + my += HEIGHT(c) + ih; + } else { + resize(c, sx, sy, sw - (2*c->bw), sh - (2*c->bw), 0); + } +} + +/* + * Fibonacci layout + gaps + * https://dwm.suckless.org/patches/fibonacci/ + */ +void +fibonacci(Monitor *m, int s) +{ + unsigned int i, n; + int nx, ny, nw, nh; + int oh, ov, ih, iv; + int nv, hrest = 0, wrest = 0, r = 1; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + nx = m->wx + ov; + ny = m->wy + oh; + nw = m->ww - 2*ov; + nh = m->wh - 2*oh; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { + if (r) { + if ((i % 2 && (nh - ih) / 2 <= (bh + 2*c->bw)) + || (!(i % 2) && (nw - iv) / 2 <= (bh + 2*c->bw))) { + r = 0; + } + if (r && i < n - 1) { + if (i % 2) { + nv = (nh - ih) / 2; + hrest = nh - 2*nv - ih; + nh = nv; + } else { + nv = (nw - iv) / 2; + wrest = nw - 2*nv - iv; + nw = nv; + } + + if ((i % 4) == 2 && !s) + nx += nw + iv; + else if ((i % 4) == 3 && !s) + ny += nh + ih; + } + + if ((i % 4) == 0) { + if (s) { + ny += nh + ih; + nh += hrest; + } + else { + nh -= hrest; + ny -= nh + ih; + } + } + else if ((i % 4) == 1) { + nx += nw + iv; + nw += wrest; + } + else if ((i % 4) == 2) { + ny += nh + ih; + nh += hrest; + if (i < n - 1) + nw += wrest; + } + else if ((i % 4) == 3) { + if (s) { + nx += nw + iv; + nw -= wrest; + } else { + nw -= wrest; + nx -= nw + iv; + nh += hrest; + } + } + if (i == 0) { + if (n != 1) { + nw = (m->ww - iv - 2*ov) - (m->ww - iv - 2*ov) * (1 - m->mfact); + wrest = 0; + } + ny = m->wy + oh; + } + else if (i == 1) + nw = m->ww - nw - iv - 2*ov; + i++; + } + + resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False); + } +} + +void +dwindle(Monitor *m) +{ + fibonacci(m, 1); +} + +void +spiral(Monitor *m) +{ + fibonacci(m, 0); +} + +/* + * Gappless grid layout + gaps (ironically) + * https://dwm.suckless.org/patches/gaplessgrid/ + */ +void +gaplessgrid(Monitor *m) +{ + unsigned int i, n; + int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters + int oh, ov, ih, iv; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + /* grid dimensions */ + for (cols = 0; cols <= n/2; cols++) + if (cols*cols >= n) + break; + if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ + cols = 2; + rows = n/cols; + cn = rn = 0; // reset column no, row no, client count + + ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; + cw = (m->ww - 2*ov - iv * (cols - 1)) / cols; + rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; + crest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; + x = m->wx + ov; + y = m->wy + oh; + + for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { + if (i/rows + 1 > cols - n%cols) { + rows = n/cols + 1; + ch = (m->wh - 2*oh - ih * (rows - 1)) / rows; + rrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; + } + resize(c, + x, + y + rn*(ch + ih) + MIN(rn, rrest), + cw + (cn < crest ? 1 : 0) - 2*c->bw, + ch + (rn < rrest ? 1 : 0) - 2*c->bw, + 0); + rn++; + if (rn >= rows) { + rn = 0; + x += cw + ih + (cn < crest ? 1 : 0); + cn++; + } + } +} + +/* + * Gridmode layout + gaps + * https://dwm.suckless.org/patches/gridmode/ + */ +void +grid(Monitor *m) +{ + unsigned int i, n; + int cx, cy, cw, ch, cc, cr, chrest, cwrest, cols, rows; + int oh, ov, ih, iv; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + + /* grid dimensions */ + for (rows = 0; rows <= n/2; rows++) + if (rows*rows >= n) + break; + cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; + + /* window geoms (cell height/width) */ + ch = (m->wh - 2*oh - ih * (rows - 1)) / (rows ? rows : 1); + cw = (m->ww - 2*ov - iv * (cols - 1)) / (cols ? cols : 1); + chrest = (m->wh - 2*oh - ih * (rows - 1)) - ch * rows; + cwrest = (m->ww - 2*ov - iv * (cols - 1)) - cw * cols; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + cc = i / rows; + cr = i % rows; + cx = m->wx + ov + cc * (cw + iv) + MIN(cc, cwrest); + cy = m->wy + oh + cr * (ch + ih) + MIN(cr, chrest); + resize(c, cx, cy, cw + (cc < cwrest ? 1 : 0) - 2*c->bw, ch + (cr < chrest ? 1 : 0) - 2*c->bw, False); + } +} + +/* + * Horizontal grid layout + gaps + * https://dwm.suckless.org/patches/horizgrid/ + */ +void +horizgrid(Monitor *m) { + Client *c; + unsigned int n, i; + int oh, ov, ih, iv; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + int ntop, nbottom = 1; + float mfacts, sfacts; + int mrest, srest; + + /* Count windows */ + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + if (n <= 2) + ntop = n; + else { + ntop = n / 2; + nbottom = n - ntop; + } + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + sh = mh = m->wh - 2*oh; + sw = mw = m->ww - 2*ov; + + if (n > ntop) { + sh = (mh - ih) / 2; + mh = mh - ih - sh; + sy = my + mh + ih; + mw = m->ww - 2*ov - iv * (ntop - 1); + sw = m->ww - 2*ov - iv * (nbottom - 1); + } + + mfacts = ntop; + sfacts = nbottom; + mrest = mw - (mw / ntop) * ntop; + srest = sw - (sw / nbottom) * nbottom; + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < ntop) { + resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0); + mx += WIDTH(c) + iv; + } else { + resize(c, sx, sy, (sw / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0); + sx += WIDTH(c) + iv; + } +} + +/* + * nrowgrid layout + gaps + * https://dwm.suckless.org/patches/nrowgrid/ + */ +void +nrowgrid(Monitor *m) +{ + unsigned int n; + int ri = 0, ci = 0; /* counters */ + int oh, ov, ih, iv; /* vanitygap settings */ + unsigned int cx, cy, cw, ch; /* client geometry */ + unsigned int uw = 0, uh = 0, uc = 0; /* utilization trackers */ + unsigned int cols, rows = m->nmaster + 1; + Client *c; + + /* count clients */ + getgaps(m, &oh, &ov, &ih, &iv, &n); + + /* nothing to do here */ + if (n == 0) + return; + + /* force 2 clients to always split vertically */ + if (FORCE_VSPLIT && n == 2) + rows = 1; + + /* never allow empty rows */ + if (n < rows) + rows = n; + + /* define first row */ + cols = n / rows; + uc = cols; + cy = m->wy + oh; + ch = (m->wh - 2*oh - ih*(rows - 1)) / rows; + uh = ch; + + for (c = nexttiled(m->clients); c; c = nexttiled(c->next), ci++) { + if (ci == cols) { + uw = 0; + ci = 0; + ri++; + + /* next row */ + cols = (n - uc) / (rows - ri); + uc += cols; + cy = m->wy + oh + uh + ih; + uh += ch + ih; + } + + cx = m->wx + ov + uw; + cw = (m->ww - 2*ov - uw) / (cols - ci); + uw += cw + iv; + + resize(c, cx, cy, cw - (2*c->bw), ch - (2*c->bw), 0); + } +} + +/* + * Default tile layout + gaps + */ +static void +tile(Monitor *m) +{ + unsigned int i, n; + int oh, ov, ih, iv; + int mx = 0, my = 0, mh = 0, mw = 0; + int sx = 0, sy = 0, sh = 0, sw = 0; + float mfacts, sfacts; + int mrest, srest; + Client *c; + + getgaps(m, &oh, &ov, &ih, &iv, &n); + if (n == 0) + return; + + sx = mx = m->wx + ov; + sy = my = m->wy + oh; + mh = m->wh - 2*oh - ih * (MIN(n, m->nmaster) - 1); + sh = m->wh - 2*oh - ih * (n - m->nmaster - 1); + sw = mw = m->ww - 2*ov; + + if (m->nmaster && n > m->nmaster) { + sw = (mw - iv) * (1 - m->mfact); + mw = mw - iv - sw; + sx = mx + mw + iv; + } + + getfacts(m, mh, sh, &mfacts, &sfacts, &mrest, &srest); + + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + resize(c, mx, my, mw - (2*c->bw), (mh / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), 0); + my += HEIGHT(c) + ih; + } else { + resize(c, sx, sy, sw - (2*c->bw), (sh / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), 0); + sy += HEIGHT(c) + ih; + } +} \ No newline at end of file diff --git a/dwm-6.2/wmbar b/dwm-6.2/wmbar new file mode 100755 index 0000000..efb720a --- /dev/null +++ b/dwm-6.2/wmbar @@ -0,0 +1,9 @@ +#!/bin/sh + +OS="Arch Linux" +KERNEL=$(uname -r) +HOSTNAME=$(uname -n) +WMVER=sarc-3.0 +# User can be printed by $USER + +xsetroot -name "$USER | $KERNEL | $HOSTNAME | $WMVER" diff --git a/dwmblocks/.gitignore b/dwmblocks/.gitignore deleted file mode 100644 index b6605b4..0000000 --- a/dwmblocks/.gitignore +++ /dev/null @@ -1,56 +0,0 @@ -# Custom blocks file -blocks.h - -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex -dwmblocks - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf diff --git a/dwmblocks/LICENSE b/dwmblocks/LICENSE deleted file mode 100644 index 3ec2656..0000000 --- a/dwmblocks/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -ISC License (ISC) - -Copyright 2020 torrinfail - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/dwmblocks/Makefile b/dwmblocks/Makefile deleted file mode 100644 index ef43ef4..0000000 --- a/dwmblocks/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -PREFIX ?= /usr/local -CC ?= cc -LDFLAGS = -lX11 - -output: dwmblocks.c blocks.def.h blocks.h - ${CC} dwmblocks.c $(LDFLAGS) -o dwmblocks -blocks.h: - cp blocks.def.h $@ - - -clean: - rm -f *.o *.gch dwmblocks -install: output - mkdir -p $(DESTDIR)$(PREFIX)/bin - install -m 0755 dwmblocks $(DESTDIR)$(PREFIX)/bin/dwmblocks -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks diff --git a/dwmblocks/README.md b/dwmblocks/README.md deleted file mode 100644 index dda2259..0000000 --- a/dwmblocks/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# dwmblocks -Modular status bar for dwm written in c. -# usage -To use dwmblocks first run 'make' and then install it with 'sudo make install'. -After that you can put dwmblocks in your xinitrc or other startup script to have it start with dwm. -# modifying blocks -The statusbar is made from text output from commandline programs. -Blocks are added and removed by editing the blocks.h header file. -By default the blocks.h header file is created the first time you run make which copies the default config from blocks.def.h. -This is so you can edit your status bar commands and they will not get overwritten in a future update. -# patches -Here are some patches to dwmblocks that add features that I either don't want to merge in, or that require a dwm patch to work. -I do not maintain these but I will take pull requests to update them. -
-dwmblocks-statuscmd-b6b0be4.diff diff --git a/dwmblocks/blocks.def.h b/dwmblocks/blocks.def.h deleted file mode 100644 index b152ab9..0000000 --- a/dwmblocks/blocks.def.h +++ /dev/null @@ -1,11 +0,0 @@ -//Modify this file to change what commands output to your statusbar, and recompile using the make command. -static const Block blocks[] = { - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - {"", "uname -n ", 0, 0}, - {"", "uname -r", 0, 0}, - {"", "date '+%I:%M%p'", 5, 0}, -}; - -//sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim[] = " | "; -static unsigned int delimLen = 5; diff --git a/dwmblocks/dwmblocks.c b/dwmblocks/dwmblocks.c deleted file mode 100644 index ded717c..0000000 --- a/dwmblocks/dwmblocks.c +++ /dev/null @@ -1,213 +0,0 @@ -#include -#include -#include -#include -#include -#ifndef NO_X -#include -#endif -#ifdef __OpenBSD__ -#define SIGPLUS SIGUSR1+1 -#define SIGMINUS SIGUSR1-1 -#else -#define SIGPLUS SIGRTMIN -#define SIGMINUS SIGRTMIN -#endif -#define LENGTH(X) (sizeof(X) / sizeof (X[0])) -#define CMDLENGTH 50 -#define MIN( a, b ) ( ( a < b) ? a : b ) -#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1) - -typedef struct { - char* icon; - char* command; - unsigned int interval; - unsigned int signal; -} Block; -#ifndef __OpenBSD__ -void dummysighandler(int num); -#endif -void sighandler(int num); -void getcmds(int time); -void getsigcmds(unsigned int signal); -void setupsignals(); -void sighandler(int signum); -int getstatus(char *str, char *last); -void statusloop(); -void termhandler(); -void pstdout(); -#ifndef NO_X -void setroot(); -static void (*writestatus) () = setroot; -static int setupX(); -static Display *dpy; -static int screen; -static Window root; -#else -static void (*writestatus) () = pstdout; -#endif - - -#include "blocks.h" - -static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; -static char statusstr[2][STATUSLENGTH]; -static int statusContinue = 1; -static int returnStatus = 0; - -//opens process *cmd and stores output in *output -void getcmd(const Block *block, char *output) -{ - strcpy(output, block->icon); - FILE *cmdf = popen(block->command, "r"); - if (!cmdf) - return; - int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-i-delimLen, cmdf); - i = strlen(output); - if (i == 0) { - //return if block and command output are both empty - pclose(cmdf); - return; - } - if (delim[0] != '\0') { - //only chop off newline if one is present at the end - i = output[i-1] == '\n' ? i-1 : i; - strncpy(output+i, delim, delimLen); - } - else - output[i++] = '\0'; - pclose(cmdf); -} - -void getcmds(int time) -{ - const Block* current; - for (unsigned int i = 0; i < LENGTH(blocks); i++) { - current = blocks + i; - if ((current->interval != 0 && time % current->interval == 0) || time == -1) - getcmd(current,statusbar[i]); - } -} - -void getsigcmds(unsigned int signal) -{ - const Block *current; - for (unsigned int i = 0; i < LENGTH(blocks); i++) { - current = blocks + i; - if (current->signal == signal) - getcmd(current,statusbar[i]); - } -} - -void setupsignals() -{ -#ifndef __OpenBSD__ - /* initialize all real time signals with dummy handler */ - for (int i = SIGRTMIN; i <= SIGRTMAX; i++) - signal(i, dummysighandler); -#endif - - for (unsigned int i = 0; i < LENGTH(blocks); i++) { - if (blocks[i].signal > 0) - signal(SIGMINUS+blocks[i].signal, sighandler); - } - -} - -int getstatus(char *str, char *last) -{ - strcpy(last, str); - str[0] = '\0'; - for (unsigned int i = 0; i < LENGTH(blocks); i++) - strcat(str, statusbar[i]); - str[strlen(str)-strlen(delim)] = '\0'; - return strcmp(str, last);//0 if they are the same -} - -#ifndef NO_X -void setroot() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only set root if text has changed. - return; - XStoreName(dpy, root, statusstr[0]); - XFlush(dpy); -} - -int setupX() -{ - dpy = XOpenDisplay(NULL); - if (!dpy) { - fprintf(stderr, "dwmblocks: Failed to open display\n"); - return 0; - } - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - return 1; -} -#endif - -void pstdout() -{ - if (!getstatus(statusstr[0], statusstr[1]))//Only write out if text has changed. - return; - printf("%s\n",statusstr[0]); - fflush(stdout); -} - - -void statusloop() -{ - setupsignals(); - int i = 0; - getcmds(-1); - while (1) { - getcmds(i++); - writestatus(); - if (!statusContinue) - break; - sleep(1.0); - } -} - -#ifndef __OpenBSD__ -/* this signal handler should do nothing */ -void dummysighandler(int signum) -{ - return; -} -#endif - -void sighandler(int signum) -{ - getsigcmds(signum-SIGPLUS); - writestatus(); -} - -void termhandler() -{ - statusContinue = 0; -} - -int main(int argc, char** argv) -{ - for (int i = 0; i < argc; i++) {//Handle command line arguments - if (!strcmp("-d",argv[i])) - strncpy(delim, argv[++i], delimLen); - else if (!strcmp("-p",argv[i])) - writestatus = pstdout; - } -#ifndef NO_X - if (!setupX()) - return 1; -#endif - delimLen = MIN(delimLen, strlen(delim)); - delim[delimLen++] = '\0'; - signal(SIGTERM, termhandler); - signal(SIGINT, termhandler); - statusloop(); -#ifndef NO_X - XCloseDisplay(dpy); -#endif - return 0; -} diff --git a/etc/.xinitrc b/etc/.xinitrc deleted file mode 100644 index 431377a..0000000 --- a/etc/.xinitrc +++ /dev/null @@ -1 +0,0 @@ -exec dwm diff --git a/etc/clean b/etc/clean deleted file mode 100755 index b422c79..0000000 --- a/etc/clean +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# This script is used to test new installations of sarc and delete current ones - -sudo rm /usr/local/bin/dm* -sudo rm /usr/local/bin/dwm* -sudo rm /usr/local/bin/st* -sudo rm /usr/local/bin/ss -sudo rm /etc/wallpaper* -sudo pacman -Rnsc sarc diff --git a/etc/ns.conf b/etc/ns.conf deleted file mode 100644 index 4d83a91..0000000 --- a/etc/ns.conf +++ /dev/null @@ -1,15 +0,0 @@ -# ns.conf -# -# Don't remove from /etc or bad things will happen -# -# The interface var is the WiFi device name, wlan0 or wlp3s0 ex. -# -# INTERFACE="wlan0" -# -# -# The config var is your wpa_supplicant config file, usually located in /etc -# -# CONFIG="/etc/wpa_supplicant.conf" - -INTERFACE="wlp0s16u3u3" -CONFIG="/etc/wpa_supplicant.conf" diff --git a/etc/screenshots/blue.png b/etc/screenshots/blue.png deleted file mode 100644 index 0d139fe..0000000 Binary files a/etc/screenshots/blue.png and /dev/null differ diff --git a/etc/screenshots/green.png b/etc/screenshots/green.png deleted file mode 100644 index 6fdbf0b..0000000 Binary files a/etc/screenshots/green.png and /dev/null differ diff --git a/etc/screenshots/red.png b/etc/screenshots/red.png deleted file mode 100644 index 004faaf..0000000 Binary files a/etc/screenshots/red.png and /dev/null differ diff --git a/etc/wallpaper/blend.wallpaper.jpg b/etc/wallpaper/blend.wallpaper.jpg deleted file mode 100644 index becd272..0000000 Binary files a/etc/wallpaper/blend.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/blue.wallpaper.jpg b/etc/wallpaper/blue.wallpaper.jpg deleted file mode 100644 index 0920b93..0000000 Binary files a/etc/wallpaper/blue.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/default.wallpaper.jpg b/etc/wallpaper/default.wallpaper.jpg deleted file mode 100644 index 9fc1f81..0000000 Binary files a/etc/wallpaper/default.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/dracula.wallpaper.jpg b/etc/wallpaper/dracula.wallpaper.jpg deleted file mode 100644 index 19bf67e..0000000 Binary files a/etc/wallpaper/dracula.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/green.wallpaper.jpg b/etc/wallpaper/green.wallpaper.jpg deleted file mode 100644 index 111ffe1..0000000 Binary files a/etc/wallpaper/green.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/liquid_blue.wallpaper.jpg b/etc/wallpaper/liquid_blue.wallpaper.jpg deleted file mode 100644 index 7f6baf5..0000000 Binary files a/etc/wallpaper/liquid_blue.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/liquid_red.wallpaper.jpg b/etc/wallpaper/liquid_red.wallpaper.jpg deleted file mode 100644 index 3e2a4bc..0000000 Binary files a/etc/wallpaper/liquid_red.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/nord.wallpaper.jpg b/etc/wallpaper/nord.wallpaper.jpg deleted file mode 100644 index e84e3e5..0000000 Binary files a/etc/wallpaper/nord.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/purple.wallpaper.jpg b/etc/wallpaper/purple.wallpaper.jpg deleted file mode 100644 index f0e89e8..0000000 Binary files a/etc/wallpaper/purple.wallpaper.jpg and /dev/null differ diff --git a/etc/wallpaper/red.wallpaper.jpg b/etc/wallpaper/red.wallpaper.jpg deleted file mode 100644 index 4cc72e2..0000000 Binary files a/etc/wallpaper/red.wallpaper.jpg and /dev/null differ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..430f61a --- /dev/null +++ b/install.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +cd scripts/ +cp * /usr/local/bin/ + +cd ../dmenu-5.0/ +make install + +cd ../dwm-6.2 +make install + +cd ../st-0.8.4 +make install +cd .. diff --git a/scripts/brighter b/scripts/brighter new file mode 100755 index 0000000..b495a84 --- /dev/null +++ b/scripts/brighter @@ -0,0 +1,4 @@ +#!/bin/sh + + +sudo light -A 6 diff --git a/scripts/darker b/scripts/darker new file mode 100755 index 0000000..f7530e7 --- /dev/null +++ b/scripts/darker @@ -0,0 +1,7 @@ +#!/bin/sh + +# +# A script that lowers and ups the brightness +# + +sudo light -U 6 diff --git a/scripts/fehbg b/scripts/fehbg new file mode 100755 index 0000000..b9b46d1 --- /dev/null +++ b/scripts/fehbg @@ -0,0 +1 @@ +feh --bg-fill ~/.config/wallpaper.png diff --git a/scripts/mic_toggle b/scripts/mic_toggle new file mode 100755 index 0000000..f36e8a4 --- /dev/null +++ b/scripts/mic_toggle @@ -0,0 +1,3 @@ +#!/bin/sh +amixer set Capture toggle +notify-send "Toggled mute" diff --git a/scripts/mute b/scripts/mute new file mode 100755 index 0000000..7941e5d --- /dev/null +++ b/scripts/mute @@ -0,0 +1,4 @@ +#!/bin/sh + +pactl set-sink-mute @DEFAULT_SINK@ toggle & +dunstify "Toggled mute" & diff --git a/scripts/rs b/scripts/rs new file mode 100755 index 0000000..f8f1468 --- /dev/null +++ b/scripts/rs @@ -0,0 +1,4 @@ +#!/bin/sh +# A script to start sarc +sx dwm +# That's it diff --git a/scripts/screenshot b/scripts/screenshot new file mode 100755 index 0000000..7154c73 --- /dev/null +++ b/scripts/screenshot @@ -0,0 +1,6 @@ +#!/bin/sh + +pictureName=$(echo "Enter filename of screenshot" | dmenu) +sleep 1s +import $pictureName.png +mv $pictureName.png ~/Pictures/Screenshots diff --git a/scripts/vol_down b/scripts/vol_down new file mode 100755 index 0000000..9a01c42 --- /dev/null +++ b/scripts/vol_down @@ -0,0 +1,4 @@ +#!/bin/sh + +pactl set-sink-volume @DEFAULT_SINK@ -5% & +dunstify "Turned the volume down 5%" diff --git a/scripts/vol_up b/scripts/vol_up new file mode 100755 index 0000000..5107cd5 --- /dev/null +++ b/scripts/vol_up @@ -0,0 +1,5 @@ +#!/bin/sh + +pactl set-sink-volume @DEFAULT_SINK@ +5% & +dunstify "Turned the volume up +5" & + diff --git a/st-0.8.4/config.h b/st-0.8.4/config.h index c3012af..6ac76a1 100644 --- a/st-0.8.4/config.h +++ b/st-0.8.4/config.h @@ -1,4 +1,4 @@ -#include "../theme.h" +#include "../dwm-6.2/colors.h" /* See LICENSE file for copyright and license details. */ /* diff --git a/st-0.8.4/patches/st-rightclickpaste-0.8.2.diff b/st-0.8.4/patches/st-rightclickpaste-0.8.2.diff new file mode 100644 index 0000000..d959417 --- /dev/null +++ b/st-0.8.4/patches/st-rightclickpaste-0.8.2.diff @@ -0,0 +1,28 @@ +From 111e5d0311f174592ccecee2af11067103abaee7 Mon Sep 17 00:00:00 2001 +From: aleks +Date: Sun, 11 Aug 2019 03:15:26 +0200 +Subject: [PATCH] Make right-click paste + +Pressing right-click pastes from the primary-selection. +If combined with the clipboard-patch right-click pastes from the clipboard. +Middle-click does nothing. +--- + x.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/x.c b/x.c +index 0422421..13a5849 100644 +--- a/x.c ++++ b/x.c +@@ -643,7 +643,7 @@ brelease(XEvent *e) + return; + } + +- if (e->xbutton.button == Button2) ++ if (e->xbutton.button == Button3) + selpaste(NULL); + else if (e->xbutton.button == Button1) + mousesel(e, 1); +-- +2.22.0 + diff --git a/st-0.8.4/patches/st-scrollback-mouse-increment-0.8.2.diff b/st-0.8.4/patches/st-scrollback-mouse-increment-0.8.2.diff new file mode 100644 index 0000000..9556a9d --- /dev/null +++ b/st-0.8.4/patches/st-scrollback-mouse-increment-0.8.2.diff @@ -0,0 +1,34 @@ +From 63e717e51dcd2f59c7a3aa75b659926aa92e08f3 Mon Sep 17 00:00:00 2001 +From: Jacob Louis Prosser +Date: Mon, 5 Aug 2019 18:20:25 +1000 +Subject: [st] [patch] Exposed variable to easily change mouse scroll increment. + +--- + config.def.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/config.def.h b/config.def.h +index ad20c4c..47e4b66 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -154,6 +154,7 @@ static unsigned int defaultattr = 11; + * Internal mouse shortcuts. + * Beware that overloading Button1 will disable the selection. + */ ++const unsigned int mousescrollincrement = 1; + static MouseShortcut mshortcuts[] = { + /* button mask string */ + { Button4, XK_NO_MOD, "\031" }, +@@ -162,8 +163,8 @@ static MouseShortcut mshortcuts[] = { + + MouseKey mkeys[] = { + /* button mask function argument */ +- { Button4, ShiftMask, kscrollup, {.i = 1} }, +- { Button5, ShiftMask, kscrolldown, {.i = 1} }, ++ { Button4, ShiftMask, kscrollup, {.i = mousescrollincrement} }, ++ { Button5, ShiftMask, kscrolldown, {.i = mousescrollincrement} }, + }; + + /* Internal keyboard shortcuts. */ +-- +2.22.0 diff --git a/st-0.8.4/st b/st-0.8.4/st new file mode 100755 index 0000000..b5216af Binary files /dev/null and b/st-0.8.4/st differ diff --git a/st-0.8.4/st.o b/st-0.8.4/st.o new file mode 100644 index 0000000..e3f7921 Binary files /dev/null and b/st-0.8.4/st.o differ diff --git a/st-0.8.4/x.o b/st-0.8.4/x.o new file mode 100644 index 0000000..5eb1e8b Binary files /dev/null and b/st-0.8.4/x.o differ diff --git a/surf-2.1/LICENSE b/surf-2.1/LICENSE deleted file mode 100644 index 2cdab7c..0000000 --- a/surf-2.1/LICENSE +++ /dev/null @@ -1,48 +0,0 @@ -MIT/X Consortium License - -© 2009-2010 Enno Boland -© 2009 Thomas Menari -© 2009 Simon Rozet -© 2009 Andrew Antle -© 2010-2011 pancake -© 2011-2013 Anselm R Garbe -© 2011-2012 Troels Henriksen -© 2011 Connor Lane Smith -© 2012-2017 Christoph Lohmann <20h@r-36.net> -© 2013 Shayan Pooya -© 2013 Jens Nyberg -© 2013 Carlos J. Torres -© 2013 Alexander Sedov -© 2013 Nick White -© 2013 David Dufberg -© 2014-2017 Quentin Rameau -© 2014-2016 Markus Teich -© 2015 Jakukyo Friel -© 2015 Ben Woolley -© 2015 Greg Reagle -© 2015 GhostAV -© 2015 Ivan Tham -© 2015 Alexander Huemer -© 2015 Michael Stevens -© 2015 Felix Janda -© 2016 Charles Lehner -© 2016 Dmitry Bogatov - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - diff --git a/surf-2.1/Makefile b/surf-2.1/Makefile deleted file mode 100644 index 1edf820..0000000 --- a/surf-2.1/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -# surf - simple browser -# See LICENSE file for copyright and license details. -.POSIX: - -include config.mk - -SRC = surf.c -WSRC = webext-surf.c -OBJ = $(SRC:.c=.o) -WOBJ = $(WSRC:.c=.o) -WLIB = $(WSRC:.c=.so) - -all: options surf $(WLIB) - -options: - @echo surf build options: - @echo "CC = $(CC)" - @echo "CFLAGS = $(SURFCFLAGS) $(CFLAGS)" - @echo "WEBEXTCFLAGS = $(WEBEXTCFLAGS) $(CFLAGS)" - @echo "LDFLAGS = $(LDFLAGS)" - -surf: $(OBJ) - $(CC) $(SURFLDFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) - -$(OBJ) $(WOBJ): config.h common.h config.mk - -config.h: - cp config.def.h $@ - -$(OBJ): $(SRC) - $(CC) $(SURFCFLAGS) $(CFLAGS) -c $(SRC) - -$(WLIB): $(WOBJ) - $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $? $(WEBEXTLIBS) - -$(WOBJ): $(WSRC) - $(CC) $(WEBEXTCFLAGS) $(CFLAGS) -c $(WSRC) - -clean: - rm -f surf $(OBJ) - rm -f $(WLIB) $(WOBJ) - -distclean: clean - rm -f config.h surf-$(VERSION).tar.gz - -dist: distclean - mkdir -p surf-$(VERSION) - cp -R LICENSE Makefile config.mk config.def.h README \ - surf-open.sh arg.h TODO.md surf.png \ - surf.1 common.h $(SRC) $(WSRC) surf-$(VERSION) - tar -cf surf-$(VERSION).tar surf-$(VERSION) - gzip surf-$(VERSION).tar - rm -rf surf-$(VERSION) - -install: all - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f surf $(DESTDIR)$(PREFIX)/bin - chmod 755 $(DESTDIR)$(PREFIX)/bin/surf - mkdir -p $(DESTDIR)$(LIBDIR) - cp -f $(WLIB) $(DESTDIR)$(LIBDIR) - for wlib in $(WLIB); do \ - chmod 644 $(DESTDIR)$(LIBDIR)/$$wlib; \ - done - mkdir -p $(DESTDIR)$(MANPREFIX)/man1 - sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1 - chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1 - -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/surf - rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1 - for wlib in $(WLIB); do \ - rm -f $(DESTDIR)$(LIBDIR)/$$wlib; \ - done - - rmdir $(DESTDIR)$(LIBDIR) - -.PHONY: all options distclean clean dist install uninstall diff --git a/surf-2.1/README b/surf-2.1/README deleted file mode 100644 index da4577f..0000000 --- a/surf-2.1/README +++ /dev/null @@ -1,40 +0,0 @@ -surf - simple webkit-based browser -================================== -surf is a simple Web browser based on WebKit/GTK+. - -Requirements ------------- -In order to build surf you need GTK+ and Webkit/GTK+ header files. - -In order to use the functionality of the url-bar, also install dmenu[0]. - -Installation ------------- -Edit config.mk to match your local setup (surf is installed into -the /usr/local namespace by default). - -Afterwards enter the following command to build and install surf (if -necessary as root): - - make clean install - -Running surf ------------- -run - surf [URI] - -See the manpage for further options. - -Running surf in tabbed ----------------------- -For running surf in tabbed[1] there is a script included in the distribution, -which is run like this: - - surf-open.sh [URI] - -Further invocations of the script will run surf with the specified URI in this -instance of tabbed. - -[0] http://tools.suckless.org/dmenu -[1] http://tools.suckless.org/tabbed - diff --git a/surf-2.1/TODO.md b/surf-2.1/TODO.md deleted file mode 100644 index da5f44d..0000000 --- a/surf-2.1/TODO.md +++ /dev/null @@ -1,10 +0,0 @@ -# TODO - -* suckless adblocking -* replace twitch() with proper gtk calls to make scrollbars reappear -* replace webkit with something sane -* add video player options - * play in plugin - * play in video player - * call command with URI (quvi + cclive) - diff --git a/surf-2.1/arg.h b/surf-2.1/arg.h deleted file mode 100644 index ba3fb3f..0000000 --- a/surf-2.1/arg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copy me if you can. - * by 20h - */ - -#ifndef ARG_H__ -#define ARG_H__ - -extern char *argv0; - -/* use main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ - argv[0] && argv[0][0] == '-'\ - && argv[0][1];\ - argc--, argv++) {\ - char argc_;\ - char **argv_;\ - int brk_;\ - if (argv[0][1] == '-' && argv[0][2] == '\0') {\ - argv++;\ - argc--;\ - break;\ - }\ - for (brk_ = 0, argv[0]++, argv_ = argv;\ - argv[0][0] && !brk_;\ - argv[0]++) {\ - if (argv_ != argv)\ - break;\ - argc_ = argv[0][0];\ - switch (argc_) -#define ARGEND }\ - } - -#define ARGC() argc_ - -#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ - ((x), abort(), (char *)0) :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ - (char *)0 :\ - (brk_ = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#endif diff --git a/surf-2.1/common.h b/surf-2.1/common.h deleted file mode 100644 index 3990c42..0000000 --- a/surf-2.1/common.h +++ /dev/null @@ -1 +0,0 @@ -#define MSGBUFSZ 8 diff --git a/surf-2.1/config.def.h b/surf-2.1/config.def.h deleted file mode 100644 index c393592..0000000 --- a/surf-2.1/config.def.h +++ /dev/null @@ -1,207 +0,0 @@ -/* modifier 0 means no modifier */ -static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */ -static char *fulluseragent = ""; /* Or override the whole user agent string */ -static char *scriptfile = "~/.surf/script.js"; -static char *styledir = "~/.surf/styles/"; -static char *certdir = "~/.surf/certificates/"; -static char *cachedir = "~/.surf/cache/"; -static char *cookiefile = "~/.surf/cookies.txt"; - -/* Webkit default features */ -/* Highest priority value will be used. - * Default parameters are priority 0 - * Per-uri parameters are priority 1 - * Command parameters are priority 2 - */ -static Parameter defconfig[ParameterLast] = { - /* parameter Arg value priority */ - [AccessMicrophone] = { { .i = 0 }, }, - [AccessWebcam] = { { .i = 0 }, }, - [Certificate] = { { .i = 0 }, }, - [CaretBrowsing] = { { .i = 0 }, }, - [CookiePolicies] = { { .v = "@Aa" }, }, - [DefaultCharset] = { { .v = "UTF-8" }, }, - [DiskCache] = { { .i = 1 }, }, - [DNSPrefetch] = { { .i = 0 }, }, - [Ephemeral] = { { .i = 0 }, }, - [FileURLsCrossAccess] = { { .i = 0 }, }, - [FontSize] = { { .i = 12 }, }, - [FrameFlattening] = { { .i = 0 }, }, - [Geolocation] = { { .i = 0 }, }, - [HideBackground] = { { .i = 0 }, }, - [Inspector] = { { .i = 0 }, }, - [Java] = { { .i = 1 }, }, - [JavaScript] = { { .i = 1 }, }, - [KioskMode] = { { .i = 0 }, }, - [LoadImages] = { { .i = 1 }, }, - [MediaManualPlay] = { { .i = 1 }, }, - [PreferredLanguages] = { { .v = (char *[]){ NULL } }, }, - [RunInFullscreen] = { { .i = 0 }, }, - [ScrollBars] = { { .i = 1 }, }, - [ShowIndicators] = { { .i = 1 }, }, - [SiteQuirks] = { { .i = 1 }, }, - [SmoothScrolling] = { { .i = 0 }, }, - [SpellChecking] = { { .i = 0 }, }, - [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, }, - [StrictTLS] = { { .i = 1 }, }, - [Style] = { { .i = 1 }, }, - [WebGL] = { { .i = 0 }, }, - [ZoomLevel] = { { .f = 1.0 }, }, -}; - -static UriParameters uriparams[] = { - { "(://|\\.)suckless\\.org(/|$)", { - [JavaScript] = { { .i = 0 }, 1 }, - }, }, -}; - -/* default window size: width, height */ -static int winsize[] = { 800, 600 }; - -static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | - WEBKIT_FIND_OPTIONS_WRAP_AROUND; - -#define PROMPT_GO "Go:" -#define PROMPT_FIND "Find:" - -/* SETPROP(readprop, setprop, prompt)*/ -#define SETPROP(r, s, p) { \ - .v = (const char *[]){ "/bin/sh", "-c", \ - "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \ - "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \ - "| dmenu -l 10 -p \"$4\" -w $1)\" && " \ - "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ - "surf-setprop", winid, r, s, p, NULL \ - } \ -} - -/* DOWNLOAD(URI, referer) */ -#define DOWNLOAD(u, r) { \ - .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\ - "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \ - " -e \"$3\" \"$4\"; read", \ - "surf-download", useragent, cookiefile, r, u, NULL \ - } \ -} - -/* PLUMB(URI) */ -/* This called when some URI which does not begin with "about:", - * "http://" or "https://" should be opened. - */ -#define PLUMB(u) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "xdg-open \"$0\"", u, NULL \ - } \ -} - -/* VIDEOPLAY(URI) */ -#define VIDEOPLAY(u) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "mpv --really-quiet \"$0\"", u, NULL \ - } \ -} - -/* BM_ADD(readprop) */ -#define BM_ADD(r) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \ - "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \ - "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \ - "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \ - winid, r, NULL \ - } \ -} - -/* styles */ -/* - * The iteration will stop at the first match, beginning at the beginning of - * the list. - */ -static SiteSpecific styles[] = { - /* regexp file in $styledir */ - { ".*", "default.css" }, -}; - -/* certificates */ -/* - * Provide custom certificate for urls - */ -static SiteSpecific certs[] = { - /* regexp file in $certdir */ - { "://suckless\\.org/", "suckless.org.crt" }, -}; - -#define MODKEY GDK_CONTROL_MASK - -/* hotkeys */ -/* - * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to - * edit the CLEANMASK() macro. - */ -static Key keys[] = { - /* modifier keyval function arg */ - { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, - { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - { MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") }, - - { 0, GDK_KEY_Escape, stop, { 0 } }, - { MODKEY, GDK_KEY_c, stop, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } }, - { MODKEY, GDK_KEY_r, reload, { .i = 0 } }, - - { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, - { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, - - /* vertical and horizontal scrolling, in viewport percentage */ - { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } }, - { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } }, - { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } }, - { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } }, - { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } }, - { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } }, - - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } }, - { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } }, - { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } }, - - { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } }, - { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } }, - - { MODKEY, GDK_KEY_n, find, { .i = +1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } }, - { MODKEY, GDK_KEY_t, showcert, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, - { 0, GDK_KEY_F11, togglefullscreen, { 0 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, -}; - -/* button definitions */ -/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ -static Button buttons[] = { - /* target event mask button function argument stop event */ - { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 }, - { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 }, - { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 }, - { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 }, - { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, - { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, -}; - -#define HOMEPAGE "https://duckduckgo.com/" diff --git a/surf-2.1/config.def.h.orig b/surf-2.1/config.def.h.orig deleted file mode 100644 index 2d963e8..0000000 --- a/surf-2.1/config.def.h.orig +++ /dev/null @@ -1,194 +0,0 @@ -/* modifier 0 means no modifier */ -static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */ -static char *fulluseragent = ""; /* Or override the whole user agent string */ -static char *scriptfile = "~/.surf/script.js"; -static char *styledir = "~/.surf/styles/"; -static char *certdir = "~/.surf/certificates/"; -static char *cachedir = "~/.surf/cache/"; -static char *cookiefile = "~/.surf/cookies.txt"; - -/* Webkit default features */ -/* Highest priority value will be used. - * Default parameters are priority 0 - * Per-uri parameters are priority 1 - * Command parameters are priority 2 - */ -static Parameter defconfig[ParameterLast] = { - /* parameter Arg value priority */ - [AccessMicrophone] = { { .i = 0 }, }, - [AccessWebcam] = { { .i = 0 }, }, - [Certificate] = { { .i = 0 }, }, - [CaretBrowsing] = { { .i = 0 }, }, - [CookiePolicies] = { { .v = "@Aa" }, }, - [DefaultCharset] = { { .v = "UTF-8" }, }, - [DiskCache] = { { .i = 1 }, }, - [DNSPrefetch] = { { .i = 0 }, }, - [Ephemeral] = { { .i = 0 }, }, - [FileURLsCrossAccess] = { { .i = 0 }, }, - [FontSize] = { { .i = 12 }, }, - [FrameFlattening] = { { .i = 0 }, }, - [Geolocation] = { { .i = 0 }, }, - [HideBackground] = { { .i = 0 }, }, - [Inspector] = { { .i = 0 }, }, - [Java] = { { .i = 1 }, }, - [JavaScript] = { { .i = 1 }, }, - [KioskMode] = { { .i = 0 }, }, - [LoadImages] = { { .i = 1 }, }, - [MediaManualPlay] = { { .i = 1 }, }, - [PreferredLanguages] = { { .v = (char *[]){ NULL } }, }, - [RunInFullscreen] = { { .i = 0 }, }, - [ScrollBars] = { { .i = 1 }, }, - [ShowIndicators] = { { .i = 1 }, }, - [SiteQuirks] = { { .i = 1 }, }, - [SmoothScrolling] = { { .i = 0 }, }, - [SpellChecking] = { { .i = 0 }, }, - [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, }, - [StrictTLS] = { { .i = 1 }, }, - [Style] = { { .i = 1 }, }, - [WebGL] = { { .i = 0 }, }, - [ZoomLevel] = { { .f = 1.0 }, }, -}; - -static UriParameters uriparams[] = { - { "(://|\\.)suckless\\.org(/|$)", { - [JavaScript] = { { .i = 0 }, 1 }, - }, }, -}; - -/* default window size: width, height */ -static int winsize[] = { 800, 600 }; - -static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | - WEBKIT_FIND_OPTIONS_WRAP_AROUND; - -#define PROMPT_GO "Go:" -#define PROMPT_FIND "Find:" - -/* SETPROP(readprop, setprop, prompt)*/ -#define SETPROP(r, s, p) { \ - .v = (const char *[]){ "/bin/sh", "-c", \ - "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \ - "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \ - "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ - "surf-setprop", winid, r, s, p, NULL \ - } \ -} - -/* DOWNLOAD(URI, referer) */ -#define DOWNLOAD(u, r) { \ - .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\ - "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \ - " -e \"$3\" \"$4\"; read", \ - "surf-download", useragent, cookiefile, r, u, NULL \ - } \ -} - -/* PLUMB(URI) */ -/* This called when some URI which does not begin with "about:", - * "http://" or "https://" should be opened. - */ -#define PLUMB(u) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "xdg-open \"$0\"", u, NULL \ - } \ -} - -/* VIDEOPLAY(URI) */ -#define VIDEOPLAY(u) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "mpv --really-quiet \"$0\"", u, NULL \ - } \ -} - -/* styles */ -/* - * The iteration will stop at the first match, beginning at the beginning of - * the list. - */ -static SiteSpecific styles[] = { - /* regexp file in $styledir */ - { ".*", "default.css" }, -}; - -/* certificates */ -/* - * Provide custom certificate for urls - */ -static SiteSpecific certs[] = { - /* regexp file in $certdir */ - { "://suckless\\.org/", "suckless.org.crt" }, -}; - -#define MODKEY GDK_CONTROL_MASK - -/* hotkeys */ -/* - * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to - * edit the CLEANMASK() macro. - */ -static Key keys[] = { - /* modifier keyval function arg */ - { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, - { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - - { 0, GDK_KEY_Escape, stop, { 0 } }, - { MODKEY, GDK_KEY_c, stop, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } }, - { MODKEY, GDK_KEY_r, reload, { .i = 0 } }, - - { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, - { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, - - /* vertical and horizontal scrolling, in viewport percentage */ - { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } }, - { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } }, - { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } }, - { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } }, - { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } }, - { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } }, - - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } }, - { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } }, - { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } }, - - { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } }, - { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } }, - - { MODKEY, GDK_KEY_n, find, { .i = +1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } }, - { MODKEY, GDK_KEY_t, showcert, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, - { 0, GDK_KEY_F11, togglefullscreen, { 0 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, -}; - -/* button definitions */ -/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ -static Button buttons[] = { - /* target event mask button function argument stop event */ - { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 }, - { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 }, - { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 }, - { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 }, - { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, - { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, -}; - -#define HOMEPAGE "https://duckduckgo.com/" diff --git a/surf-2.1/config.h b/surf-2.1/config.h deleted file mode 100644 index 750e281..0000000 --- a/surf-2.1/config.h +++ /dev/null @@ -1,208 +0,0 @@ -/* modifier 0 means no modifier */ -static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */ -static char *fulluseragent = ""; /* Or override the whole user agent string */ -static char *scriptfile = "~/.surf/script.js"; -static char *styledir = "~/.surf/styles/"; -static char *certdir = "~/.surf/certificates/"; -static char *cachedir = "~/.surf/cache/"; -static char *cookiefile = "~/.surf/cookies.txt"; - -/* Webkit default features */ -/* Highest priority value will be used. - * Default parameters are priority 0 - * Per-uri parameters are priority 1 - * Command parameters are priority 2 - */ -static Parameter defconfig[ParameterLast] = { - /* parameter Arg value priority */ - [AccessMicrophone] = { { .i = 0 }, }, - [AccessWebcam] = { { .i = 0 }, }, - [Certificate] = { { .i = 0 }, }, - [CaretBrowsing] = { { .i = 0 }, }, - [CookiePolicies] = { { .v = "@Aa" }, }, - [DefaultCharset] = { { .v = "UTF-8" }, }, - [DiskCache] = { { .i = 1 }, }, - [DNSPrefetch] = { { .i = 0 }, }, - [Ephemeral] = { { .i = 0 }, }, - [FileURLsCrossAccess] = { { .i = 0 }, }, - [FontSize] = { { .i = 12 }, }, - [FrameFlattening] = { { .i = 0 }, }, - [Geolocation] = { { .i = 0 }, }, - [HideBackground] = { { .i = 0 }, }, - [Inspector] = { { .i = 0 }, }, - [Java] = { { .i = 1 }, }, - [JavaScript] = { { .i = 1 }, }, - [KioskMode] = { { .i = 0 }, }, - [LoadImages] = { { .i = 1 }, }, - [MediaManualPlay] = { { .i = 1 }, }, - [PreferredLanguages] = { { .v = (char *[]){ NULL } }, }, - [RunInFullscreen] = { { .i = 0 }, }, - [ScrollBars] = { { .i = 1 }, }, - [ShowIndicators] = { { .i = 1 }, }, - [SiteQuirks] = { { .i = 1 }, }, - [SmoothScrolling] = { { .i = 0 }, }, - [SpellChecking] = { { .i = 0 }, }, - [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, }, - [StrictTLS] = { { .i = 1 }, }, - [Style] = { { .i = 1 }, }, - [WebGL] = { { .i = 0 }, }, - [ZoomLevel] = { { .f = 1.0 }, }, -}; - -static UriParameters uriparams[] = { - { "(://|\\.)suckless\\.org(/|$)", { - [JavaScript] = { { .i = 0 }, 1 }, - }, }, -}; - -/* default window size: width, height */ -static int winsize[] = { 800, 600 }; - -static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | - WEBKIT_FIND_OPTIONS_WRAP_AROUND; - -#define PROMPT_GO "Go:" -#define PROMPT_FIND "Find:" - -/* SETPROP(readprop, setprop, prompt)*/ -#define SETPROP(r, s, p) { \ - .v = (const char *[]){ "/bin/sh", "-c", \ - "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \ - "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \ - "| dmenu -l 10 -p \"$4\" -w $1)\" && " \ - "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ - "surf-setprop", winid, r, s, p, NULL \ - } \ -} - -/* DOWNLOAD(URI, referer) */ -#define DOWNLOAD(u, r) { \ - .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\ - "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \ - " -e \"$3\" \"$4\"; read", \ - "surf-download", useragent, cookiefile, r, u, NULL \ - } \ -} - -/* PLUMB(URI) */ -/* This called when some URI which does not begin with "about:", - * "http://" or "https://" should be opened. - */ -#define PLUMB(u) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "xdg-open \"$0\"", u, NULL \ - } \ -} - -/* VIDEOPLAY(URI) */ -#define VIDEOPLAY(u) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "mpv --really-quiet \"$0\"", u, NULL \ - } \ -} - -/* BM_ADD(readprop) */ -#define BM_ADD(r) {\ - .v = (const char *[]){ "/bin/sh", "-c", \ - "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \ - "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \ - "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \ - "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \ - winid, r, NULL \ - } \ -} - -/* styles */ -/* - * The iteration will stop at the first match, beginning at the beginning of - * the list. - */ -static SiteSpecific styles[] = { - /* regexp file in $styledir */ - { ".*", "default.css" }, -}; - -/* certificates */ -/* - * Provide custom certificate for urls - */ -static SiteSpecific certs[] = { - /* regexp file in $certdir */ - { "://suckless\\.org/", "suckless.org.crt" }, -}; - -#define MODKEY GDK_CONTROL_MASK - -/* hotkeys */ -/* - * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to - * edit the CLEANMASK() macro. - */ -static Key keys[] = { - /* modifier keyval function arg */ - { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, - { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - { MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") }, - - { 0, GDK_KEY_Escape, stop, { 0 } }, - { MODKEY, GDK_KEY_c, stop, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } }, - { MODKEY, GDK_KEY_r, reload, { .i = 0 } }, - - { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, - { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, - - /* vertical and horizontal scrolling, in viewport percentage */ - { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } }, - { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } }, - { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } }, - { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } }, - { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } }, - { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } }, - - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } }, - { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } }, - { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } }, - { MODKEY, GDK_KEY_z, zoom, { .i = +1 } }, - - { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } }, - { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } }, - - { MODKEY, GDK_KEY_n, find, { .i = +1 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } }, - { MODKEY, GDK_KEY_t, showcert, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, - { 0, GDK_KEY_F11, togglefullscreen, { 0 } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } }, - - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } }, - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, -}; - -/* button definitions */ -/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ -static Button buttons[] = { - /* target event mask button function argument stop event */ - { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 }, - { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 }, - { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 }, - { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 }, - { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, - { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, -}; - -#define HOMEPAGE "https://duckduckgo.com/" diff --git a/surf-2.1/config.mk b/surf-2.1/config.mk deleted file mode 100644 index 2eb9fb0..0000000 --- a/surf-2.1/config.mk +++ /dev/null @@ -1,32 +0,0 @@ -# surf version -VERSION = 2.1 - -# Customize below to fit your system - -# paths -PREFIX = /usr/local -MANPREFIX = $(PREFIX)/share/man -LIBPREFIX = $(PREFIX)/lib -LIBDIR = $(LIBPREFIX)/surf - -X11INC = `pkg-config --cflags x11` -X11LIB = `pkg-config --libs x11` - -GTKINC = `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0` -GTKLIB = `pkg-config --libs gtk+-3.0 gcr-3 webkit2gtk-4.0` -WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gio-2.0` -WEBEXTLIBS = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gio-2.0` - -# includes and libs -INCS = $(X11INC) $(GTKINC) -LIBS = $(X11LIB) $(GTKLIB) -lgthread-2.0 - -# flags -CPPFLAGS = -DVERSION=\"$(VERSION)\" -DGCR_API_SUBJECT_TO_CHANGE \ - -DLIBPREFIX=\"$(LIBPREFIX)\" -DWEBEXTDIR=\"$(LIBDIR)\" \ - -D_DEFAULT_SOURCE -SURFCFLAGS = -fPIC $(INCS) $(CPPFLAGS) -WEBEXTCFLAGS = -fPIC $(WEBEXTINC) - -# compiler -#CC = c99 diff --git a/surf-2.1/surf b/surf-2.1/surf deleted file mode 100755 index 13d69ac..0000000 Binary files a/surf-2.1/surf and /dev/null differ diff --git a/surf-2.1/surf-0.7-webkit2-searchengines.diff b/surf-2.1/surf-0.7-webkit2-searchengines.diff deleted file mode 100644 index ef94f53..0000000 --- a/surf-2.1/surf-0.7-webkit2-searchengines.diff +++ /dev/null @@ -1,63 +0,0 @@ -diff --git a/surf.c b/surf.c -index 9b4dbb9..bf54d84 100644 ---- a/surf.c -+++ b/surf.c -@@ -92,6 +92,12 @@ typedef struct { - } Button; - - typedef struct { -+ char *token; -+ char *uri; -+} SearchEngine; -+ -+ -+typedef struct { - char *regex; - char *style; - regex_t re; -@@ -124,6 +130,7 @@ static void newwindow(Client *c, const Arg *a, int noembed); - static void spawn(Client *c, const Arg *a); - static void destroyclient(Client *c); - static void cleanup(void); -+static gchar *parseuri(const gchar *uri); - - /* GTK/WebKit */ - static WebKitWebView *newview(Client *c, WebKitWebView *rv); -@@ -350,13 +357,13 @@ loaduri(Client *c, const Arg *a) - if (g_strcmp0(uri, "") == 0) - return; - -- if (g_strrstr(uri, "://") || g_str_has_prefix(uri, "about:")) { -+ if (g_str_has_prefix(uri, "about:")) { - url = g_strdup(uri); - } else if (!stat(uri, &st) && (path = realpath(uri, NULL))) { - url = g_strdup_printf("file://%s", path); - free(path); - } else { -- url = g_strdup_printf("http://%s", uri); -+ url = parseuri(uri); - } - - setatom(c, AtomUri, url); -@@ -1205,6 +1212,21 @@ destroywin(GtkWidget* w, Client *c) - gtk_main_quit(); - } - -+static gchar * -+parseuri(const gchar *uri) { -+ guint i; -+ -+ for (i = 0; i < LENGTH(searchengines); i++) { -+ if (searchengines[i].token == NULL || searchengines[i].uri == NULL || \ -+ *(uri + strlen(searchengines[i].token)) != ' ') -+ continue; -+ if (g_str_has_prefix(uri, searchengines[i].token)) -+ return g_strdup_printf(searchengines[i].uri, uri + strlen(searchengines[i].token) + 1); -+ } -+ -+ return g_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri); -+} -+ - void - pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) - { diff --git a/surf-2.1/surf-2.0-homepage.diff b/surf-2.1/surf-2.0-homepage.diff deleted file mode 100644 index f32016f..0000000 --- a/surf-2.1/surf-2.0-homepage.diff +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/config.def.h b/config.def.h ---- a/config.def.h -+++ b/config.def.h -@@ -164,3 +164,5 @@ static Button buttons[] = { - { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, - { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, - }; -+ -+#define HOMEPAGE "https://duckduckgo.com/" -diff --git a/surf.c b/surf.c ---- a/surf.c -+++ b/surf.c -@@ -1751,7 +1751,11 @@ main(int argc, char *argv[]) - if (argc > 0) - arg.v = argv[0]; - else -+#ifdef HOMEPAGE -+ arg.v = HOMEPAGE; -+#else - arg.v = "about:blank"; -+#endif - - setup(); - c = newclient(NULL); diff --git a/surf-2.1/surf-bookmarks-20170722-723ff26.diff b/surf-2.1/surf-bookmarks-20170722-723ff26.diff deleted file mode 100644 index 323ba55..0000000 --- a/surf-2.1/surf-bookmarks-20170722-723ff26.diff +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/config.def.h b/config.def.h -index 2e735bf..43ad9ab 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -69,8 +69,9 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | - #define SETPROP(r, s, p) { \ - .v = (const char *[]){ "/bin/sh", "-c", \ - "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \ -- "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \ -- "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ -+ "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \ -+ "| dmenu -l 10 -p \"$4\" -w $1)\" && " \ -+ "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ - "surf-setprop", winid, r, s, p, NULL \ - } \ - } -@@ -101,6 +102,17 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | - } \ - } - -+/* BM_ADD(readprop) */ -+#define BM_ADD(r) {\ -+ .v = (const char *[]){ "/bin/sh", "-c", \ -+ "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \ -+ "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \ -+ "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \ -+ "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \ -+ winid, r, NULL \ -+ } \ -+} -+ - /* styles */ - /* - * The iteration will stop at the first match, beginning at the beginning of -@@ -132,6 +144,7 @@ static Key keys[] = { - { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, - { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, - { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, -+ { MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") }, - - { 0, GDK_KEY_Escape, stop, { 0 } }, - { MODKEY, GDK_KEY_c, stop, { 0 } }, diff --git a/surf-2.1/surf-cachedir-20200831-2188894.diff b/surf-2.1/surf-cachedir-20200831-2188894.diff deleted file mode 100644 index 0d147a7..0000000 --- a/surf-2.1/surf-cachedir-20200831-2188894.diff +++ /dev/null @@ -1,36 +0,0 @@ -From 2188894f8e6b1d2232a77b06d07776bdd6bdb4f3 Mon Sep 17 00:00:00 2001 -From: David Carey -Date: Mon, 31 Aug 2020 14:03:17 -0500 -Subject: [PATCH] Allow custom cache directory via CLI argument. - ---- - surf.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/surf.c b/surf.c -index 2b54e3c..8436ded 100644 ---- a/surf.c -+++ b/surf.c -@@ -306,7 +306,8 @@ usage(void) - { - die("usage: surf [-bBdDfFgGiIkKmMnNpPsStTvwxX]\n" - "[-a cookiepolicies ] [-c cookiefile] [-C stylefile] [-e xid]\n" -- "[-r scriptfile] [-u useragent] [-z zoomlevel] [uri]\n"); -+ "[-h cachedir] [-r scriptfile] [-u useragent]\n" -+ "[-z zoomlevel] [uri]\n"); - } - - void -@@ -2026,6 +2027,9 @@ main(int argc, char *argv[]) - defconfig[Geolocation].val.i = 1; - defconfig[Geolocation].prio = 2; - break; -+ case 'h': -+ cachedir = EARGF(usage()); -+ break; - case 'i': - defconfig[LoadImages].val.i = 0; - defconfig[LoadImages].prio = 2; --- -2.28.0 - diff --git a/surf-2.1/surf-open.sh b/surf-2.1/surf-open.sh deleted file mode 100755 index c22edc2..0000000 --- a/surf-2.1/surf-open.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# See the LICENSE file for copyright and license details. -# - -xidfile="$HOME/tmp/tabbed-surf.xid" -uri="" - -if [ "$#" -gt 0 ]; -then - uri="$1" -fi - -runtabbed() { - tabbed -dn tabbed-surf -r 2 surf -e '' "$uri" >"$xidfile" \ - 2>/dev/null & -} - -if [ ! -r "$xidfile" ]; -then - runtabbed -else - xid=$(cat "$xidfile") - xprop -id "$xid" >/dev/null 2>&1 - if [ $? -gt 0 ]; - then - runtabbed - else - surf -e "$xid" "$uri" >/dev/null 2>&1 & - fi -fi - diff --git a/surf-2.1/surf.1 b/surf-2.1/surf.1 deleted file mode 100644 index f747157..0000000 --- a/surf-2.1/surf.1 +++ /dev/null @@ -1,305 +0,0 @@ -.TH SURF 1 surf\-VERSION -.SH NAME -surf \- simple webkit-based browser -.SH SYNOPSIS -.B surf -.RB [-bBdDfFgGiIkKmMnNpPsStTvwxX] -.RB [-a\ cookiepolicies] -.RB [-c\ cookiefile] -.RB [-C\ stylefile] -.RB [-e\ xid] -.RB [-r\ scriptfile] -.RB [-u\ useragent] -.RB [-z\ zoomlevel] -.RB [URI] -.SH DESCRIPTION -surf is a simple Web browser based on WebKit/GTK+. It is able -to display websites and follow links. It supports the XEmbed protocol -which makes it possible to embed it in another application. Furthermore, -one can point surf to another URI by setting its XProperties. -.SH OPTIONS -.TP -.B \-a cookiepolicies -Define the order of -.I cookie policies\fR. -The default is "@Aa" but could be -redefined in the -.IR config.h , -with "A" meaning to -accept all cookies, "a" to deny all cookies and "@", which tells surf to -accept no third party cookies. -.TP -.B \-b -Disable Scrollbars. -.TP -.B \-B -Enable Scrollbars. -.TP -.B \-c cookiefile -Specify the -.I cookiefile -to use. -.TP -.B \-C stylefile -Specify the user -.IR stylefile . -This does disable the site-specific styles. -.TP -.B \-d -Disable the disk cache. -.TP -.B \-D -Enable the disk cache. -.TP -.B \-e xid -Reparents to window specified by -.IR xid . -.TP -.B \-f -Start surf in windowed mode (not fullscreen). -.TP -.B \-F -Start surf in fullscreen mode. -.TP -.B \-g -Disable giving the geolocation to websites. -.TP -.B \-G -Enable giving the geolocation to websites. -.TP -.B \-i -Disable Images. -.TP -.B \-I -Enable Images. -.TP -.B \-k -Disable kiosk mode (disable key strokes and right click). -.TP -.B \-K -Enable kiosk mode (disable key strokes and right click). -.TP -.B \-m -Disable application of user style sheets. -.TP -.B \-M -Enable application of user style sheets. -.TP -.B \-n -Disable the Web Inspector (Developer Tools). -.TP -.B \-N -Enable the Web Inspector (Developer Tools). -.TP -.B \-r scriptfile -Specify the user -.IR scriptfile . -.TP -.B \-s -Disable Javascript. -.TP -.B \-S -Enable Javascript. -.TP -.B \-t -Disable strict TLS check. -.TP -.B \-T -Enable strict TLS check. -.TP -.B \-u useragent -Specify the -.I useragent -which surf should use. -.TP -.B \-v -Prints version information to standard output, then exits. -.TP -.B \-w -Prints xid to standard output. This can be used to script the browser in for -example -.BR xdotool(1) . -.TP -.B -x -Disable custom certificates. -.TP -.B -X -Enable custom certificates. -.TP -.B \-z zoomlevel -Specify the -.I zoomlevel -which surf should use. -.SH USAGE -.B Escape -Stops loading current page or stops download. -.TP -.B Ctrl\-h -Walks back the history. -.TP -.B Ctrl\-l -Walks forward the history. -.TP -.B Ctrl\-k -Scrolls page upwards. -.TP -.B Ctrl\-j -Scrolls page downwards. -.TP -.B Ctrl\-b -Scroll up one whole page view. -.TP -.B Ctrl\-Space -Scroll down one whole page view. -.TP -.B Ctrl\-i -Scroll horizontally to the right. -.TP -.B Ctrl\-u -Scroll horizontally to the left. -.TP -.B Ctrl\-z or Ctrl\-Shift\-k or Ctrl\-+ -Zooms page in. -.TP -.B Ctrl\-Shift\-j or Ctrl\-- -Zooms page out. -.TP -.B Ctrl\-Shift\-q -Resets Zoom. -.TP -.B Ctrl\-f and Ctrl\-/ -Opens the search-bar. -.TP -.B Ctrl\-n -Go to next search result. -.TP -.B Ctrl\-Shift\-n -Go to previous search result. -.TP -.B Ctrl\-g -Opens the URL-bar (requires dmenu installed). -.TP -.B Ctrl\-p -Loads URI from primary selection. -.TP -.B Ctrl\-Shift\-p -Calls Printpage Dialog. -.TP -.B Ctrl\-r -Reloads the website. -.TP -.B Ctrl\-Shift\-r -Reloads the website without using the cache. -.TP -.B Ctrl\-y -Copies current URI to primary selection. -.TP -.B Ctrl\-t -Display the current TLS certificate in a popup window. -.TP -.B Ctrl\-Shift\-a -Toggle through the the -.I cookie policies\fR. -This will not reload the page. -.TP -.B Ctrl\-Shift\-b -Toggle scrollbars. This will reload the page. -.TP -.B Ctrl\-Shift\-c -Toggle caret browsing. This will reload the page. -.TP -.B Ctrl\-Shift\-i -Toggle auto-loading of images. This will reload the page. -.TP -.B Ctrl\-Shift\-m -Toggle if the -.I stylefile -file should be loaded. This will reload the page. -.TP -.B Ctrl\-Shift\-o -Open the Web Inspector (Developer Tools) window for the current page. -.TP -.B Ctrl\-Shift\-s -Toggle script execution. This will reload the page. -.TP -.B Ctrl\-Shift\-t -Toggle strict TLS check. This will reload the page. -.TP -.B F11 -Toggle fullscreen mode. -.SH INDICATORS OF OPERATION -Surf is showing indicators of operation in front of the site title. -For all indicators, unless otherwise specified, a lower case letter means disabled and an upper case letter means enabled. -.TP -.B A -all cookies accepted -.TP -.B a -no cookies accepted -.TP -.B @ -all except third-party cookies accepted -.TP -.B c C -caret browsing -.TP -.B g G -geolocation -.TP -.B d D -disk cache -.TP -.B i I -images -.TP -.B s S -scripts -.TP -.B m M -styles -.TP -.B f F -frame flattening -.TP -.B x X -custom certificates -.TP -.B t T -strict TLS -.SH INDICATORS OF WEB PAGE -The second part of the indicators specifies modes of the web page itself. -.SS First character: encryption -.TP -.B - -unencrypted -.TP -.B T -encrypted (TLS) -.TP -.B U -attempted encryption but failed -.SS Second character: proxying -.TP -.B - -no proxy -.TP -.B P -using proxy -.SH ENVIRONMENT -.B SURF_USERAGENT -If this variable is set upon startup, surf will use it as the -.I useragent -string. -.TP -.B http_proxy -If this variable is set and not empty upon startup, surf will use it as the http proxy. -.SH SIGNALS -Surf will reload the current page on -.BR SIGHUP . -.SH SEE ALSO -.BR dmenu(1), -.BR xprop(1), -.BR tabbed(1), -.BR xdotool(1) -.SH BUGS -Please report them! diff --git a/surf-2.1/surf.c b/surf-2.1/surf.c deleted file mode 100644 index d8c82d5..0000000 --- a/surf-2.1/surf.c +++ /dev/null @@ -1,2141 +0,0 @@ -/* See LICENSE file for copyright and license details. - * - * To understand surf, start reading main(). - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "arg.h" -#include "common.h" - -#define LENGTH(x) (sizeof(x) / sizeof(x[0])) -#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) - -enum { AtomFind, AtomGo, AtomUri, AtomLast }; - -enum { - OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT, - OnLink = WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK, - OnImg = WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE, - OnMedia = WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA, - OnEdit = WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE, - OnBar = WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR, - OnSel = WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION, - OnAny = OnDoc | OnLink | OnImg | OnMedia | OnEdit | OnBar | OnSel, -}; - -typedef enum { - AccessMicrophone, - AccessWebcam, - CaretBrowsing, - Certificate, - CookiePolicies, - DiskCache, - DefaultCharset, - DNSPrefetch, - Ephemeral, - FileURLsCrossAccess, - FontSize, - FrameFlattening, - Geolocation, - HideBackground, - Inspector, - Java, - JavaScript, - KioskMode, - LoadImages, - MediaManualPlay, - PreferredLanguages, - RunInFullscreen, - ScrollBars, - ShowIndicators, - SiteQuirks, - SmoothScrolling, - SpellChecking, - SpellLanguages, - StrictTLS, - Style, - WebGL, - ZoomLevel, - ParameterLast -} ParamName; - -typedef union { - int i; - float f; - const void *v; -} Arg; - -typedef struct { - Arg val; - int prio; -} Parameter; - -typedef struct Client { - GtkWidget *win; - WebKitWebView *view; - WebKitWebInspector *inspector; - WebKitFindController *finder; - WebKitHitTestResult *mousepos; - GTlsCertificate *cert, *failedcert; - GTlsCertificateFlags tlserr; - Window xid; - guint64 pageid; - int progress, fullscreen, https, insecure, errorpage; - const char *title, *overtitle, *targeturi; - const char *needle; - struct Client *next; -} Client; - -typedef struct { - guint mod; - guint keyval; - void (*func)(Client *c, const Arg *a); - const Arg arg; -} Key; - -typedef struct { - unsigned int target; - unsigned int mask; - guint button; - void (*func)(Client *c, const Arg *a, WebKitHitTestResult *h); - const Arg arg; - unsigned int stopevent; -} Button; - -typedef struct { - const char *uri; - Parameter config[ParameterLast]; - regex_t re; -} UriParameters; - -typedef struct { - char *regex; - char *file; - regex_t re; -} SiteSpecific; - -/* Surf */ -static void die(const char *errstr, ...); -static void usage(void); -static void setup(void); -static void sigchld(int unused); -static void sighup(int unused); -static char *buildfile(const char *path); -static char *buildpath(const char *path); -static char *untildepath(const char *path); -static const char *getuserhomedir(const char *user); -static const char *getcurrentuserhomedir(void); -static Client *newclient(Client *c); -static void loaduri(Client *c, const Arg *a); -static const char *geturi(Client *c); -static void setatom(Client *c, int a, const char *v); -static const char *getatom(Client *c, int a); -static void updatetitle(Client *c); -static void gettogglestats(Client *c); -static void getpagestats(Client *c); -static WebKitCookieAcceptPolicy cookiepolicy_get(void); -static char cookiepolicy_set(const WebKitCookieAcceptPolicy p); -static void seturiparameters(Client *c, const char *uri, ParamName *params); -static void setparameter(Client *c, int refresh, ParamName p, const Arg *a); -static const char *getcert(const char *uri); -static void setcert(Client *c, const char *file); -static const char *getstyle(const char *uri); -static void setstyle(Client *c, const char *file); -static void runscript(Client *c); -static void evalscript(Client *c, const char *jsstr, ...); -static void updatewinid(Client *c); -static void handleplumb(Client *c, const char *uri); -static void newwindow(Client *c, const Arg *a, int noembed); -static void spawn(Client *c, const Arg *a); -static void msgext(Client *c, char type, const Arg *a); -static void destroyclient(Client *c); -static void cleanup(void); - -/* GTK/WebKit */ -static WebKitWebView *newview(Client *c, WebKitWebView *rv); -static void initwebextensions(WebKitWebContext *wc, Client *c); -static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a, - Client *c); -static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c); -static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, - gpointer d); -static gboolean winevent(GtkWidget *w, GdkEvent *e, Client *c); -static gboolean readsock(GIOChannel *s, GIOCondition ioc, gpointer unused); -static void showview(WebKitWebView *v, Client *c); -static GtkWidget *createwindow(Client *c); -static gboolean loadfailedtls(WebKitWebView *v, gchar *uri, - GTlsCertificate *cert, - GTlsCertificateFlags err, Client *c); -static void loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c); -static void progresschanged(WebKitWebView *v, GParamSpec *ps, Client *c); -static void titlechanged(WebKitWebView *view, GParamSpec *ps, Client *c); -static void mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, - guint modifiers, Client *c); -static gboolean permissionrequested(WebKitWebView *v, - WebKitPermissionRequest *r, Client *c); -static gboolean decidepolicy(WebKitWebView *v, WebKitPolicyDecision *d, - WebKitPolicyDecisionType dt, Client *c); -static void decidenavigation(WebKitPolicyDecision *d, Client *c); -static void decidenewwindow(WebKitPolicyDecision *d, Client *c); -static void decideresource(WebKitPolicyDecision *d, Client *c); -static void insecurecontent(WebKitWebView *v, WebKitInsecureContentEvent e, - Client *c); -static void downloadstarted(WebKitWebContext *wc, WebKitDownload *d, - Client *c); -static void responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c); -static void download(Client *c, WebKitURIResponse *r); -static void webprocessterminated(WebKitWebView *v, - WebKitWebProcessTerminationReason r, - Client *c); -static void closeview(WebKitWebView *v, Client *c); -static void destroywin(GtkWidget* w, Client *c); - -/* Hotkeys */ -static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); -static void reload(Client *c, const Arg *a); -static void print(Client *c, const Arg *a); -static void showcert(Client *c, const Arg *a); -static void clipboard(Client *c, const Arg *a); -static void zoom(Client *c, const Arg *a); -static void scrollv(Client *c, const Arg *a); -static void scrollh(Client *c, const Arg *a); -static void navigate(Client *c, const Arg *a); -static void stop(Client *c, const Arg *a); -static void toggle(Client *c, const Arg *a); -static void togglefullscreen(Client *c, const Arg *a); -static void togglecookiepolicy(Client *c, const Arg *a); -static void toggleinspector(Client *c, const Arg *a); -static void find(Client *c, const Arg *a); - -/* Buttons */ -static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h); -static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h); -static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h); - -static char winid[64]; -static char togglestats[12]; -static char pagestats[2]; -static Atom atoms[AtomLast]; -static Window embed; -static int showxid; -static int cookiepolicy; -static Display *dpy; -static Client *clients; -static GdkDevice *gdkkb; -static char *stylefile; -static const char *useragent; -static Parameter *curconfig; -static int modparams[ParameterLast]; -static int spair[2]; -char *argv0; - -static ParamName loadtransient[] = { - Certificate, - CookiePolicies, - DiskCache, - DNSPrefetch, - FileURLsCrossAccess, - JavaScript, - LoadImages, - PreferredLanguages, - ShowIndicators, - StrictTLS, - ParameterLast -}; - -static ParamName loadcommitted[] = { -// AccessMicrophone, -// AccessWebcam, - CaretBrowsing, - DefaultCharset, - FontSize, - FrameFlattening, - Geolocation, - HideBackground, - Inspector, - Java, -// KioskMode, - MediaManualPlay, - RunInFullscreen, - ScrollBars, - SiteQuirks, - SmoothScrolling, - SpellChecking, - SpellLanguages, - Style, - ZoomLevel, - ParameterLast -}; - -static ParamName loadfinished[] = { - ParameterLast -}; - -/* configuration, allows nested code to access above variables */ -#include "config.h" - -void -die(const char *errstr, ...) -{ - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(1); -} - -void -usage(void) -{ - die("usage: surf [-bBdDfFgGiIkKmMnNpPsStTvwxX]\n" - "[-a cookiepolicies ] [-c cookiefile] [-C stylefile] [-e xid]\n" - "[-h cachedir] [-r scriptfile] [-u useragent]\n" - "[-z zoomlevel] [uri]\n"); -} - -void -setup(void) -{ - GIOChannel *gchanin; - GdkDisplay *gdpy; - int i, j; - - /* clean up any zombies immediately */ - sigchld(0); - if (signal(SIGHUP, sighup) == SIG_ERR) - die("Can't install SIGHUP handler"); - - if (!(dpy = XOpenDisplay(NULL))) - die("Can't open default display"); - - /* atoms */ - atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); - atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); - atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); - - gtk_init(NULL, NULL); - - gdpy = gdk_display_get_default(); - - curconfig = defconfig; - - /* dirs and files */ - cookiefile = buildfile(cookiefile); - scriptfile = buildfile(scriptfile); - certdir = buildpath(certdir); - if (curconfig[Ephemeral].val.i) - cachedir = NULL; - else - cachedir = buildpath(cachedir); - - gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy)); - - if (socketpair(AF_UNIX, SOCK_DGRAM, 0, spair) < 0) { - fputs("Unable to create sockets\n", stderr); - spair[0] = spair[1] = -1; - } else { - gchanin = g_io_channel_unix_new(spair[0]); - g_io_channel_set_encoding(gchanin, NULL, NULL); - g_io_channel_set_flags(gchanin, g_io_channel_get_flags(gchanin) - | G_IO_FLAG_NONBLOCK, NULL); - g_io_channel_set_close_on_unref(gchanin, TRUE); - g_io_add_watch(gchanin, G_IO_IN, readsock, NULL); - } - - - for (i = 0; i < LENGTH(certs); ++i) { - if (!regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) { - certs[i].file = g_strconcat(certdir, "/", certs[i].file, - NULL); - } else { - fprintf(stderr, "Could not compile regex: %s\n", - certs[i].regex); - certs[i].regex = NULL; - } - } - - if (!stylefile) { - styledir = buildpath(styledir); - for (i = 0; i < LENGTH(styles); ++i) { - if (!regcomp(&(styles[i].re), styles[i].regex, - REG_EXTENDED)) { - styles[i].file = g_strconcat(styledir, "/", - styles[i].file, NULL); - } else { - fprintf(stderr, "Could not compile regex: %s\n", - styles[i].regex); - styles[i].regex = NULL; - } - } - g_free(styledir); - } else { - stylefile = buildfile(stylefile); - } - - for (i = 0; i < LENGTH(uriparams); ++i) { - if (regcomp(&(uriparams[i].re), uriparams[i].uri, - REG_EXTENDED)) { - fprintf(stderr, "Could not compile regex: %s\n", - uriparams[i].uri); - uriparams[i].uri = NULL; - continue; - } - - /* copy default parameters with higher priority */ - for (j = 0; j < ParameterLast; ++j) { - if (defconfig[j].prio >= uriparams[i].config[j].prio) - uriparams[i].config[j] = defconfig[j]; - } - } -} - -void -sigchld(int unused) -{ - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("Can't install SIGCHLD handler"); - while (waitpid(-1, NULL, WNOHANG) > 0) - ; -} - -void -sighup(int unused) -{ - Arg a = { .i = 0 }; - Client *c; - - for (c = clients; c; c = c->next) - reload(c, &a); -} - -char * -buildfile(const char *path) -{ - char *dname, *bname, *bpath, *fpath; - FILE *f; - - dname = g_path_get_dirname(path); - bname = g_path_get_basename(path); - - bpath = buildpath(dname); - g_free(dname); - - fpath = g_build_filename(bpath, bname, NULL); - g_free(bpath); - g_free(bname); - - if (!(f = fopen(fpath, "a"))) - die("Could not open file: %s\n", fpath); - - g_chmod(fpath, 0600); /* always */ - fclose(f); - - return fpath; -} - -static const char* -getuserhomedir(const char *user) -{ - struct passwd *pw = getpwnam(user); - - if (!pw) - die("Can't get user %s login information.\n", user); - - return pw->pw_dir; -} - -static const char* -getcurrentuserhomedir(void) -{ - const char *homedir; - const char *user; - struct passwd *pw; - - homedir = getenv("HOME"); - if (homedir) - return homedir; - - user = getenv("USER"); - if (user) - return getuserhomedir(user); - - pw = getpwuid(getuid()); - if (!pw) - die("Can't get current user home directory\n"); - - return pw->pw_dir; -} - -char * -buildpath(const char *path) -{ - char *apath, *fpath; - - if (path[0] == '~') - apath = untildepath(path); - else - apath = g_strdup(path); - - /* creating directory */ - if (g_mkdir_with_parents(apath, 0700) < 0) - die("Could not access directory: %s\n", apath); - - fpath = realpath(apath, NULL); - g_free(apath); - - return fpath; -} - -char * -untildepath(const char *path) -{ - char *apath, *name, *p; - const char *homedir; - - if (path[1] == '/' || path[1] == '\0') { - p = (char *)&path[1]; - homedir = getcurrentuserhomedir(); - } else { - if ((p = strchr(path, '/'))) - name = g_strndup(&path[1], p - (path + 1)); - else - name = g_strdup(&path[1]); - - homedir = getuserhomedir(name); - g_free(name); - } - apath = g_build_filename(homedir, p, NULL); - return apath; -} - -Client * -newclient(Client *rc) -{ - Client *c; - - if (!(c = calloc(1, sizeof(Client)))) - die("Cannot malloc!\n"); - - c->next = clients; - clients = c; - - c->progress = 100; - c->view = newview(c, rc ? rc->view : NULL); - - return c; -} - -void -loaduri(Client *c, const Arg *a) -{ - struct stat st; - char *url, *path, *apath; - const char *uri = a->v; - - if (g_strcmp0(uri, "") == 0) - return; - - if (g_str_has_prefix(uri, "http://") || - g_str_has_prefix(uri, "https://") || - g_str_has_prefix(uri, "file://") || - g_str_has_prefix(uri, "about:")) { - url = g_strdup(uri); - } else { - if (uri[0] == '~') - apath = untildepath(uri); - else - apath = (char *)uri; - if (!stat(apath, &st) && (path = realpath(apath, NULL))) { - url = g_strdup_printf("file://%s", path); - free(path); - } else { - url = g_strdup_printf("http://%s", uri); - } - if (apath != uri) - free(apath); - } - - setatom(c, AtomUri, url); - - if (strcmp(url, geturi(c)) == 0) { - reload(c, a); - } else { - webkit_web_view_load_uri(c->view, url); - updatetitle(c); - } - - g_free(url); -} - -const char * -geturi(Client *c) -{ - const char *uri; - - if (!(uri = webkit_web_view_get_uri(c->view))) - uri = "about:blank"; - return uri; -} - -void -setatom(Client *c, int a, const char *v) -{ - XChangeProperty(dpy, c->xid, - atoms[a], XA_STRING, 8, PropModeReplace, - (unsigned char *)v, strlen(v) + 1); - XSync(dpy, False); -} - -const char * -getatom(Client *c, int a) -{ - static char buf[BUFSIZ]; - Atom adummy; - int idummy; - unsigned long ldummy; - unsigned char *p = NULL; - - XSync(dpy, False); - XGetWindowProperty(dpy, c->xid, atoms[a], 0L, BUFSIZ, False, XA_STRING, - &adummy, &idummy, &ldummy, &ldummy, &p); - if (p) - strncpy(buf, (char *)p, LENGTH(buf) - 1); - else - buf[0] = '\0'; - XFree(p); - - return buf; -} - -void -updatetitle(Client *c) -{ - char *title; - const char *name = c->overtitle ? c->overtitle : - c->title ? c->title : ""; - - if (curconfig[ShowIndicators].val.i) { - gettogglestats(c); - getpagestats(c); - - if (c->progress != 100) - title = g_strdup_printf("[%i%%] %s:%s | %s", - c->progress, togglestats, pagestats, name); - else - title = g_strdup_printf("%s:%s | %s", - togglestats, pagestats, name); - - gtk_window_set_title(GTK_WINDOW(c->win), title); - g_free(title); - } else { - gtk_window_set_title(GTK_WINDOW(c->win), name); - } -} - -void -gettogglestats(Client *c) -{ - togglestats[0] = cookiepolicy_set(cookiepolicy_get()); - togglestats[1] = curconfig[CaretBrowsing].val.i ? 'C' : 'c'; - togglestats[2] = curconfig[Geolocation].val.i ? 'G' : 'g'; - togglestats[3] = curconfig[DiskCache].val.i ? 'D' : 'd'; - togglestats[4] = curconfig[LoadImages].val.i ? 'I' : 'i'; - togglestats[5] = curconfig[JavaScript].val.i ? 'S' : 's'; - togglestats[7] = curconfig[Style].val.i ? 'M' : 'm'; - togglestats[8] = curconfig[FrameFlattening].val.i ? 'F' : 'f'; - togglestats[9] = curconfig[Certificate].val.i ? 'X' : 'x'; - togglestats[10] = curconfig[StrictTLS].val.i ? 'T' : 't'; - togglestats[11] = '\0'; -} - -void -getpagestats(Client *c) -{ - if (c->https) - pagestats[0] = (c->tlserr || c->insecure) ? 'U' : 'T'; - else - pagestats[0] = '-'; - pagestats[1] = '\0'; -} - -WebKitCookieAcceptPolicy -cookiepolicy_get(void) -{ - switch (((char *)curconfig[CookiePolicies].val.v)[cookiepolicy]) { - case 'a': - return WEBKIT_COOKIE_POLICY_ACCEPT_NEVER; - case '@': - return WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY; - default: /* fallthrough */ - case 'A': - return WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS; - } -} - -char -cookiepolicy_set(const WebKitCookieAcceptPolicy p) -{ - switch (p) { - case WEBKIT_COOKIE_POLICY_ACCEPT_NEVER: - return 'a'; - case WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY: - return '@'; - default: /* fallthrough */ - case WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS: - return 'A'; - } -} - -void -seturiparameters(Client *c, const char *uri, ParamName *params) -{ - Parameter *config, *uriconfig = NULL; - int i, p; - - for (i = 0; i < LENGTH(uriparams); ++i) { - if (uriparams[i].uri && - !regexec(&(uriparams[i].re), uri, 0, NULL, 0)) { - uriconfig = uriparams[i].config; - break; - } - } - - curconfig = uriconfig ? uriconfig : defconfig; - - for (i = 0; (p = params[i]) != ParameterLast; ++i) { - switch(p) { - default: /* FALLTHROUGH */ - if (!(defconfig[p].prio < curconfig[p].prio || - defconfig[p].prio < modparams[p])) - continue; - case Certificate: - case CookiePolicies: - case Style: - setparameter(c, 0, p, &curconfig[p].val); - } - } -} - -void -setparameter(Client *c, int refresh, ParamName p, const Arg *a) -{ - GdkRGBA bgcolor = { 0 }; - WebKitSettings *s = webkit_web_view_get_settings(c->view); - - modparams[p] = curconfig[p].prio; - - switch (p) { - case AccessMicrophone: - return; /* do nothing */ - case AccessWebcam: - return; /* do nothing */ - case CaretBrowsing: - webkit_settings_set_enable_caret_browsing(s, a->i); - refresh = 0; - break; - case Certificate: - if (a->i) - setcert(c, geturi(c)); - return; /* do not update */ - case CookiePolicies: - webkit_cookie_manager_set_accept_policy( - webkit_web_context_get_cookie_manager( - webkit_web_view_get_context(c->view)), - cookiepolicy_get()); - refresh = 0; - break; - case DiskCache: - webkit_web_context_set_cache_model( - webkit_web_view_get_context(c->view), a->i ? - WEBKIT_CACHE_MODEL_WEB_BROWSER : - WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); - return; /* do not update */ - case DefaultCharset: - webkit_settings_set_default_charset(s, a->v); - return; /* do not update */ - case DNSPrefetch: - webkit_settings_set_enable_dns_prefetching(s, a->i); - return; /* do not update */ - case FileURLsCrossAccess: - webkit_settings_set_allow_file_access_from_file_urls(s, a->i); - webkit_settings_set_allow_universal_access_from_file_urls(s, a->i); - return; /* do not update */ - case FontSize: - webkit_settings_set_default_font_size(s, a->i); - return; /* do not update */ - case FrameFlattening: - webkit_settings_set_enable_frame_flattening(s, a->i); - break; - case Geolocation: - refresh = 0; - break; - case HideBackground: - if (a->i) - webkit_web_view_set_background_color(c->view, &bgcolor); - return; /* do not update */ - case Inspector: - webkit_settings_set_enable_developer_extras(s, a->i); - return; /* do not update */ - case Java: - webkit_settings_set_enable_java(s, a->i); - return; /* do not update */ - case JavaScript: - webkit_settings_set_enable_javascript(s, a->i); - break; - case KioskMode: - return; /* do nothing */ - case LoadImages: - webkit_settings_set_auto_load_images(s, a->i); - break; - case MediaManualPlay: - webkit_settings_set_media_playback_requires_user_gesture(s, a->i); - break; - case PreferredLanguages: - return; /* do nothing */ - case RunInFullscreen: - return; /* do nothing */ - case ScrollBars: - /* Disabled until we write some WebKitWebExtension for - * manipulating the DOM directly. - enablescrollbars = !enablescrollbars; - evalscript(c, "document.documentElement.style.overflow = '%s'", - enablescrollbars ? "auto" : "hidden"); - */ - return; /* do not update */ - case ShowIndicators: - break; - case SmoothScrolling: - webkit_settings_set_enable_smooth_scrolling(s, a->i); - return; /* do not update */ - case SiteQuirks: - webkit_settings_set_enable_site_specific_quirks(s, a->i); - break; - case SpellChecking: - webkit_web_context_set_spell_checking_enabled( - webkit_web_view_get_context(c->view), a->i); - return; /* do not update */ - case SpellLanguages: - return; /* do nothing */ - case StrictTLS: - webkit_web_context_set_tls_errors_policy( - webkit_web_view_get_context(c->view), a->i ? - WEBKIT_TLS_ERRORS_POLICY_FAIL : - WEBKIT_TLS_ERRORS_POLICY_IGNORE); - break; - case Style: - webkit_user_content_manager_remove_all_style_sheets( - webkit_web_view_get_user_content_manager(c->view)); - if (a->i) - setstyle(c, getstyle(geturi(c))); - refresh = 0; - break; - case WebGL: - webkit_settings_set_enable_webgl(s, a->i); - break; - case ZoomLevel: - webkit_web_view_set_zoom_level(c->view, a->f); - return; /* do not update */ - default: - return; /* do nothing */ - } - - updatetitle(c); - if (refresh) - reload(c, a); -} - -const char * -getcert(const char *uri) -{ - int i; - - for (i = 0; i < LENGTH(certs); ++i) { - if (certs[i].regex && - !regexec(&(certs[i].re), uri, 0, NULL, 0)) - return certs[i].file; - } - - return NULL; -} - -void -setcert(Client *c, const char *uri) -{ - const char *file = getcert(uri); - char *host; - GTlsCertificate *cert; - - if (!file) - return; - - if (!(cert = g_tls_certificate_new_from_file(file, NULL))) { - fprintf(stderr, "Could not read certificate file: %s\n", file); - return; - } - - if ((uri = strstr(uri, "https://"))) { - uri += sizeof("https://") - 1; - host = g_strndup(uri, strchr(uri, '/') - uri); - webkit_web_context_allow_tls_certificate_for_host( - webkit_web_view_get_context(c->view), cert, host); - g_free(host); - } - - g_object_unref(cert); - -} - -const char * -getstyle(const char *uri) -{ - int i; - - if (stylefile) - return stylefile; - - for (i = 0; i < LENGTH(styles); ++i) { - if (styles[i].regex && - !regexec(&(styles[i].re), uri, 0, NULL, 0)) - return styles[i].file; - } - - return ""; -} - -void -setstyle(Client *c, const char *file) -{ - gchar *style; - - if (!g_file_get_contents(file, &style, NULL, NULL)) { - fprintf(stderr, "Could not read style file: %s\n", file); - return; - } - - webkit_user_content_manager_add_style_sheet( - webkit_web_view_get_user_content_manager(c->view), - webkit_user_style_sheet_new(style, - WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, - WEBKIT_USER_STYLE_LEVEL_USER, - NULL, NULL)); - - g_free(style); -} - -void -runscript(Client *c) -{ - gchar *script; - gsize l; - - if (g_file_get_contents(scriptfile, &script, &l, NULL) && l) - evalscript(c, "%s", script); - g_free(script); -} - -void -evalscript(Client *c, const char *jsstr, ...) -{ - va_list ap; - gchar *script; - - va_start(ap, jsstr); - script = g_strdup_vprintf(jsstr, ap); - va_end(ap); - - webkit_web_view_run_javascript(c->view, script, NULL, NULL, NULL); - g_free(script); -} - -void -updatewinid(Client *c) -{ - snprintf(winid, LENGTH(winid), "%lu", c->xid); -} - -void -handleplumb(Client *c, const char *uri) -{ - Arg a = (Arg)PLUMB(uri); - spawn(c, &a); -} - -void -newwindow(Client *c, const Arg *a, int noembed) -{ - int i = 0; - char tmp[64]; - const char *cmd[29], *uri; - const Arg arg = { .v = cmd }; - - cmd[i++] = argv0; - cmd[i++] = "-a"; - cmd[i++] = curconfig[CookiePolicies].val.v; - cmd[i++] = curconfig[ScrollBars].val.i ? "-B" : "-b"; - if (cookiefile && g_strcmp0(cookiefile, "")) { - cmd[i++] = "-c"; - cmd[i++] = cookiefile; - } - if (stylefile && g_strcmp0(stylefile, "")) { - cmd[i++] = "-C"; - cmd[i++] = stylefile; - } - cmd[i++] = curconfig[DiskCache].val.i ? "-D" : "-d"; - if (embed && !noembed) { - cmd[i++] = "-e"; - snprintf(tmp, LENGTH(tmp), "%lu", embed); - cmd[i++] = tmp; - } - cmd[i++] = curconfig[RunInFullscreen].val.i ? "-F" : "-f" ; - cmd[i++] = curconfig[Geolocation].val.i ? "-G" : "-g" ; - cmd[i++] = curconfig[LoadImages].val.i ? "-I" : "-i" ; - cmd[i++] = curconfig[KioskMode].val.i ? "-K" : "-k" ; - cmd[i++] = curconfig[Style].val.i ? "-M" : "-m" ; - cmd[i++] = curconfig[Inspector].val.i ? "-N" : "-n" ; - if (scriptfile && g_strcmp0(scriptfile, "")) { - cmd[i++] = "-r"; - cmd[i++] = scriptfile; - } - cmd[i++] = curconfig[JavaScript].val.i ? "-S" : "-s"; - cmd[i++] = curconfig[StrictTLS].val.i ? "-T" : "-t"; - if (fulluseragent && g_strcmp0(fulluseragent, "")) { - cmd[i++] = "-u"; - cmd[i++] = fulluseragent; - } - if (showxid) - cmd[i++] = "-w"; - cmd[i++] = curconfig[Certificate].val.i ? "-X" : "-x" ; - /* do not keep zoom level */ - cmd[i++] = "--"; - if ((uri = a->v)) - cmd[i++] = uri; - cmd[i] = NULL; - - spawn(c, &arg); -} - -void -spawn(Client *c, const Arg *a) -{ - if (fork() == 0) { - if (dpy) - close(ConnectionNumber(dpy)); - close(spair[0]); - close(spair[1]); - setsid(); - execvp(((char **)a->v)[0], (char **)a->v); - fprintf(stderr, "%s: execvp %s", argv0, ((char **)a->v)[0]); - perror(" failed"); - exit(1); - } -} - -void -destroyclient(Client *c) -{ - Client *p; - - webkit_web_view_stop_loading(c->view); - /* Not needed, has already been called - gtk_widget_destroy(c->win); - */ - - for (p = clients; p && p->next != c; p = p->next) - ; - if (p) - p->next = c->next; - else - clients = c->next; - free(c); -} - -void -cleanup(void) -{ - while (clients) - destroyclient(clients); - - close(spair[0]); - close(spair[1]); - g_free(cookiefile); - g_free(scriptfile); - g_free(stylefile); - g_free(cachedir); - XCloseDisplay(dpy); -} - -WebKitWebView * -newview(Client *c, WebKitWebView *rv) -{ - WebKitWebView *v; - WebKitSettings *settings; - WebKitWebContext *context; - WebKitCookieManager *cookiemanager; - WebKitUserContentManager *contentmanager; - - /* Webview */ - if (rv) { - v = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(rv)); - } else { - settings = webkit_settings_new_with_settings( - "allow-file-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i, - "allow-universal-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i, - "auto-load-images", curconfig[LoadImages].val.i, - "default-charset", curconfig[DefaultCharset].val.v, - "default-font-size", curconfig[FontSize].val.i, - "enable-caret-browsing", curconfig[CaretBrowsing].val.i, - "enable-developer-extras", curconfig[Inspector].val.i, - "enable-dns-prefetching", curconfig[DNSPrefetch].val.i, - "enable-frame-flattening", curconfig[FrameFlattening].val.i, - "enable-html5-database", curconfig[DiskCache].val.i, - "enable-html5-local-storage", curconfig[DiskCache].val.i, - "enable-java", curconfig[Java].val.i, - "enable-javascript", curconfig[JavaScript].val.i, - "enable-site-specific-quirks", curconfig[SiteQuirks].val.i, - "enable-smooth-scrolling", curconfig[SmoothScrolling].val.i, - "enable-webgl", curconfig[WebGL].val.i, - "media-playback-requires-user-gesture", curconfig[MediaManualPlay].val.i, - NULL); -/* For more interesting settings, have a look at - * http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html */ - - if (strcmp(fulluseragent, "")) { - webkit_settings_set_user_agent(settings, fulluseragent); - } else if (surfuseragent) { - webkit_settings_set_user_agent_with_application_details( - settings, "Surf", VERSION); - } - useragent = webkit_settings_get_user_agent(settings); - - contentmanager = webkit_user_content_manager_new(); - - if (curconfig[Ephemeral].val.i) { - context = webkit_web_context_new_ephemeral(); - } else { - context = webkit_web_context_new_with_website_data_manager( - webkit_website_data_manager_new( - "base-cache-directory", cachedir, - "base-data-directory", cachedir, - NULL)); - } - - - cookiemanager = webkit_web_context_get_cookie_manager(context); - - /* rendering process model, can be a shared unique one - * or one for each view */ - webkit_web_context_set_process_model(context, - WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); - /* TLS */ - webkit_web_context_set_tls_errors_policy(context, - curconfig[StrictTLS].val.i ? WEBKIT_TLS_ERRORS_POLICY_FAIL : - WEBKIT_TLS_ERRORS_POLICY_IGNORE); - /* disk cache */ - webkit_web_context_set_cache_model(context, - curconfig[DiskCache].val.i ? WEBKIT_CACHE_MODEL_WEB_BROWSER : - WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); - - /* Currently only works with text file to be compatible with curl */ - if (!curconfig[Ephemeral].val.i) - webkit_cookie_manager_set_persistent_storage(cookiemanager, - cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); - /* cookie policy */ - webkit_cookie_manager_set_accept_policy(cookiemanager, - cookiepolicy_get()); - /* languages */ - webkit_web_context_set_preferred_languages(context, - curconfig[PreferredLanguages].val.v); - webkit_web_context_set_spell_checking_languages(context, - curconfig[SpellLanguages].val.v); - webkit_web_context_set_spell_checking_enabled(context, - curconfig[SpellChecking].val.i); - - g_signal_connect(G_OBJECT(context), "download-started", - G_CALLBACK(downloadstarted), c); - g_signal_connect(G_OBJECT(context), "initialize-web-extensions", - G_CALLBACK(initwebextensions), c); - - v = g_object_new(WEBKIT_TYPE_WEB_VIEW, - "settings", settings, - "user-content-manager", contentmanager, - "web-context", context, - NULL); - } - - g_signal_connect(G_OBJECT(v), "notify::estimated-load-progress", - G_CALLBACK(progresschanged), c); - g_signal_connect(G_OBJECT(v), "notify::title", - G_CALLBACK(titlechanged), c); - g_signal_connect(G_OBJECT(v), "button-release-event", - G_CALLBACK(buttonreleased), c); - g_signal_connect(G_OBJECT(v), "close", - G_CALLBACK(closeview), c); - g_signal_connect(G_OBJECT(v), "create", - G_CALLBACK(createview), c); - g_signal_connect(G_OBJECT(v), "decide-policy", - G_CALLBACK(decidepolicy), c); - g_signal_connect(G_OBJECT(v), "insecure-content-detected", - G_CALLBACK(insecurecontent), c); - g_signal_connect(G_OBJECT(v), "load-failed-with-tls-errors", - G_CALLBACK(loadfailedtls), c); - g_signal_connect(G_OBJECT(v), "load-changed", - G_CALLBACK(loadchanged), c); - g_signal_connect(G_OBJECT(v), "mouse-target-changed", - G_CALLBACK(mousetargetchanged), c); - g_signal_connect(G_OBJECT(v), "permission-request", - G_CALLBACK(permissionrequested), c); - g_signal_connect(G_OBJECT(v), "ready-to-show", - G_CALLBACK(showview), c); - g_signal_connect(G_OBJECT(v), "web-process-terminated", - G_CALLBACK(webprocessterminated), c); - - return v; -} - -static gboolean -readsock(GIOChannel *s, GIOCondition ioc, gpointer unused) -{ - static char msg[MSGBUFSZ]; - GError *gerr = NULL; - gsize msgsz; - - if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) != - G_IO_STATUS_NORMAL) { - if (gerr) { - fprintf(stderr, "surf: error reading socket: %s\n", - gerr->message); - g_error_free(gerr); - } - return TRUE; - } - if (msgsz < 2) { - fprintf(stderr, "surf: message too short: %d\n", msgsz); - return TRUE; - } - - return TRUE; -} - -void -initwebextensions(WebKitWebContext *wc, Client *c) -{ - GVariant *gv; - - if (spair[1] < 0) - return; - - gv = g_variant_new("i", spair[1]); - - webkit_web_context_set_web_extensions_initialization_user_data(wc, gv); - webkit_web_context_set_web_extensions_directory(wc, WEBEXTDIR); -} - -GtkWidget * -createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c) -{ - Client *n; - - switch (webkit_navigation_action_get_navigation_type(a)) { - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - /* - * popup windows of type “other” are almost always triggered - * by user gesture, so inverse the logic here - */ -/* instead of this, compare destination uri to mouse-over uri for validating window */ - if (webkit_navigation_action_is_user_gesture(a)) - return NULL; - case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - n = newclient(c); - break; - default: - return NULL; - } - - return GTK_WIDGET(n->view); -} - -gboolean -buttonreleased(GtkWidget *w, GdkEvent *e, Client *c) -{ - WebKitHitTestResultContext element; - int i; - - element = webkit_hit_test_result_get_context(c->mousepos); - - for (i = 0; i < LENGTH(buttons); ++i) { - if (element & buttons[i].target && - e->button.button == buttons[i].button && - CLEANMASK(e->button.state) == CLEANMASK(buttons[i].mask) && - buttons[i].func) { - buttons[i].func(c, &buttons[i].arg, c->mousepos); - return buttons[i].stopevent; - } - } - - return FALSE; -} - -GdkFilterReturn -processx(GdkXEvent *e, GdkEvent *event, gpointer d) -{ - Client *c = (Client *)d; - XPropertyEvent *ev; - Arg a; - - if (((XEvent *)e)->type == PropertyNotify) { - ev = &((XEvent *)e)->xproperty; - if (ev->state == PropertyNewValue) { - if (ev->atom == atoms[AtomFind]) { - find(c, NULL); - - return GDK_FILTER_REMOVE; - } else if (ev->atom == atoms[AtomGo]) { - a.v = getatom(c, AtomGo); - loaduri(c, &a); - - return GDK_FILTER_REMOVE; - } - } - } - return GDK_FILTER_CONTINUE; -} - -gboolean -winevent(GtkWidget *w, GdkEvent *e, Client *c) -{ - int i; - - switch (e->type) { - case GDK_ENTER_NOTIFY: - c->overtitle = c->targeturi; - updatetitle(c); - break; - case GDK_KEY_PRESS: - if (!curconfig[KioskMode].val.i) { - for (i = 0; i < LENGTH(keys); ++i) { - if (gdk_keyval_to_lower(e->key.keyval) == - keys[i].keyval && - CLEANMASK(e->key.state) == keys[i].mod && - keys[i].func) { - updatewinid(c); - keys[i].func(c, &(keys[i].arg)); - return TRUE; - } - } - } - case GDK_LEAVE_NOTIFY: - c->overtitle = NULL; - updatetitle(c); - break; - case GDK_WINDOW_STATE: - if (e->window_state.changed_mask == - GDK_WINDOW_STATE_FULLSCREEN) - c->fullscreen = e->window_state.new_window_state & - GDK_WINDOW_STATE_FULLSCREEN; - break; - default: - break; - } - - return FALSE; -} - -void -showview(WebKitWebView *v, Client *c) -{ - GdkRGBA bgcolor = { 0 }; - GdkWindow *gwin; - - c->finder = webkit_web_view_get_find_controller(c->view); - c->inspector = webkit_web_view_get_inspector(c->view); - - c->pageid = webkit_web_view_get_page_id(c->view); - c->win = createwindow(c); - - gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view)); - gtk_widget_show_all(c->win); - gtk_widget_grab_focus(GTK_WIDGET(c->view)); - - gwin = gtk_widget_get_window(GTK_WIDGET(c->win)); - c->xid = gdk_x11_window_get_xid(gwin); - updatewinid(c); - if (showxid) { - gdk_display_sync(gtk_widget_get_display(c->win)); - puts(winid); - fflush(stdout); - } - - if (curconfig[HideBackground].val.i) - webkit_web_view_set_background_color(c->view, &bgcolor); - - if (!curconfig[KioskMode].val.i) { - gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK); - gdk_window_add_filter(gwin, processx, c); - } - - if (curconfig[RunInFullscreen].val.i) - togglefullscreen(c, NULL); - - if (curconfig[ZoomLevel].val.f != 1.0) - webkit_web_view_set_zoom_level(c->view, - curconfig[ZoomLevel].val.f); - - setatom(c, AtomFind, ""); - setatom(c, AtomUri, "about:blank"); -} - -GtkWidget * -createwindow(Client *c) -{ - char *wmstr; - GtkWidget *w; - - if (embed) { - w = gtk_plug_new(embed); - } else { - w = gtk_window_new(GTK_WINDOW_TOPLEVEL); - - wmstr = g_path_get_basename(argv0); - gtk_window_set_wmclass(GTK_WINDOW(w), wmstr, "Surf"); - g_free(wmstr); - - wmstr = g_strdup_printf("%s[%"PRIu64"]", "Surf", c->pageid); - gtk_window_set_role(GTK_WINDOW(w), wmstr); - g_free(wmstr); - - gtk_window_set_default_size(GTK_WINDOW(w), winsize[0], winsize[1]); - } - - g_signal_connect(G_OBJECT(w), "destroy", - G_CALLBACK(destroywin), c); - g_signal_connect(G_OBJECT(w), "enter-notify-event", - G_CALLBACK(winevent), c); - g_signal_connect(G_OBJECT(w), "key-press-event", - G_CALLBACK(winevent), c); - g_signal_connect(G_OBJECT(w), "leave-notify-event", - G_CALLBACK(winevent), c); - g_signal_connect(G_OBJECT(w), "window-state-event", - G_CALLBACK(winevent), c); - - return w; -} - -gboolean -loadfailedtls(WebKitWebView *v, gchar *uri, GTlsCertificate *cert, - GTlsCertificateFlags err, Client *c) -{ - GString *errmsg = g_string_new(NULL); - gchar *html, *pem; - - c->failedcert = g_object_ref(cert); - c->tlserr = err; - c->errorpage = 1; - - if (err & G_TLS_CERTIFICATE_UNKNOWN_CA) - g_string_append(errmsg, - "The signing certificate authority is not known.
"); - if (err & G_TLS_CERTIFICATE_BAD_IDENTITY) - g_string_append(errmsg, - "The certificate does not match the expected identity " - "of the site that it was retrieved from.
"); - if (err & G_TLS_CERTIFICATE_NOT_ACTIVATED) - g_string_append(errmsg, - "The certificate's activation time " - "is still in the future.
"); - if (err & G_TLS_CERTIFICATE_EXPIRED) - g_string_append(errmsg, "The certificate has expired.
"); - if (err & G_TLS_CERTIFICATE_REVOKED) - g_string_append(errmsg, - "The certificate has been revoked according to " - "the GTlsConnection's certificate revocation list.
"); - if (err & G_TLS_CERTIFICATE_INSECURE) - g_string_append(errmsg, - "The certificate's algorithm is considered insecure.
"); - if (err & G_TLS_CERTIFICATE_GENERIC_ERROR) - g_string_append(errmsg, - "Some error occurred validating the certificate.
"); - - g_object_get(cert, "certificate-pem", &pem, NULL); - html = g_strdup_printf("

Could not validate TLS for “%s”
%s

" - "

You can inspect the following certificate " - "with Ctrl-t (default keybinding).

" - "

%s

", uri, errmsg->str, pem); - g_free(pem); - g_string_free(errmsg, TRUE); - - webkit_web_view_load_alternate_html(c->view, html, uri, NULL); - g_free(html); - - return TRUE; -} - -void -loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c) -{ - const char *uri = geturi(c); - - switch (e) { - case WEBKIT_LOAD_STARTED: - setatom(c, AtomUri, uri); - c->title = uri; - c->https = c->insecure = 0; - seturiparameters(c, uri, loadtransient); - if (c->errorpage) - c->errorpage = 0; - else - g_clear_object(&c->failedcert); - break; - case WEBKIT_LOAD_REDIRECTED: - setatom(c, AtomUri, uri); - c->title = uri; - seturiparameters(c, uri, loadtransient); - break; - case WEBKIT_LOAD_COMMITTED: - setatom(c, AtomUri, uri); - c->title = uri; - seturiparameters(c, uri, loadcommitted); - c->https = webkit_web_view_get_tls_info(c->view, &c->cert, - &c->tlserr); - break; - case WEBKIT_LOAD_FINISHED: - seturiparameters(c, uri, loadfinished); - /* Disabled until we write some WebKitWebExtension for - * manipulating the DOM directly. - evalscript(c, "document.documentElement.style.overflow = '%s'", - enablescrollbars ? "auto" : "hidden"); - */ - runscript(c); - break; - } - updatetitle(c); -} - -void -progresschanged(WebKitWebView *v, GParamSpec *ps, Client *c) -{ - c->progress = webkit_web_view_get_estimated_load_progress(c->view) * - 100; - updatetitle(c); -} - -void -titlechanged(WebKitWebView *view, GParamSpec *ps, Client *c) -{ - c->title = webkit_web_view_get_title(c->view); - updatetitle(c); -} - -void -mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers, - Client *c) -{ - WebKitHitTestResultContext hc = webkit_hit_test_result_get_context(h); - - /* Keep the hit test to know where is the pointer on the next click */ - c->mousepos = h; - - if (hc & OnLink) - c->targeturi = webkit_hit_test_result_get_link_uri(h); - else if (hc & OnImg) - c->targeturi = webkit_hit_test_result_get_image_uri(h); - else if (hc & OnMedia) - c->targeturi = webkit_hit_test_result_get_media_uri(h); - else - c->targeturi = NULL; - - c->overtitle = c->targeturi; - updatetitle(c); -} - -gboolean -permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c) -{ - ParamName param = ParameterLast; - - if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) { - param = Geolocation; - } else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(r)) { - if (webkit_user_media_permission_is_for_audio_device( - WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r))) - param = AccessMicrophone; - else if (webkit_user_media_permission_is_for_video_device( - WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r))) - param = AccessWebcam; - } else { - return FALSE; - } - - if (curconfig[param].val.i) - webkit_permission_request_allow(r); - else - webkit_permission_request_deny(r); - - return TRUE; -} - -gboolean -decidepolicy(WebKitWebView *v, WebKitPolicyDecision *d, - WebKitPolicyDecisionType dt, Client *c) -{ - switch (dt) { - case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: - decidenavigation(d, c); - break; - case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: - decidenewwindow(d, c); - break; - case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: - decideresource(d, c); - break; - default: - webkit_policy_decision_ignore(d); - break; - } - return TRUE; -} - -void -decidenavigation(WebKitPolicyDecision *d, Client *c) -{ - WebKitNavigationAction *a = - webkit_navigation_policy_decision_get_navigation_action( - WEBKIT_NAVIGATION_POLICY_DECISION(d)); - - switch (webkit_navigation_action_get_navigation_type(a)) { - case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - default: - /* Do not navigate to links with a "_blank" target (popup) */ - if (webkit_navigation_policy_decision_get_frame_name( - WEBKIT_NAVIGATION_POLICY_DECISION(d))) { - webkit_policy_decision_ignore(d); - } else { - /* Filter out navigation to different domain ? */ - /* get action→urirequest, copy and load in new window+view - * on Ctrl+Click ? */ - webkit_policy_decision_use(d); - } - break; - } -} - -void -decidenewwindow(WebKitPolicyDecision *d, Client *c) -{ - Arg arg; - WebKitNavigationAction *a = - webkit_navigation_policy_decision_get_navigation_action( - WEBKIT_NAVIGATION_POLICY_DECISION(d)); - - - switch (webkit_navigation_action_get_navigation_type(a)) { - case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - /* Filter domains here */ -/* If the value of “mouse-button” is not 0, then the navigation was triggered by a mouse event. - * test for link clicked but no button ? */ - arg.v = webkit_uri_request_get_uri( - webkit_navigation_action_get_request(a)); - newwindow(c, &arg, 0); - break; - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - default: - break; - } - - webkit_policy_decision_ignore(d); -} - -void -decideresource(WebKitPolicyDecision *d, Client *c) -{ - int i, isascii = 1; - WebKitResponsePolicyDecision *r = WEBKIT_RESPONSE_POLICY_DECISION(d); - WebKitURIResponse *res = - webkit_response_policy_decision_get_response(r); - const gchar *uri = webkit_uri_response_get_uri(res); - - if (g_str_has_suffix(uri, "/favicon.ico")) { - webkit_policy_decision_ignore(d); - return; - } - - if (!g_str_has_prefix(uri, "http://") - && !g_str_has_prefix(uri, "https://") - && !g_str_has_prefix(uri, "about:") - && !g_str_has_prefix(uri, "file://") - && !g_str_has_prefix(uri, "data:") - && !g_str_has_prefix(uri, "blob:") - && strlen(uri) > 0) { - for (i = 0; i < strlen(uri); i++) { - if (!g_ascii_isprint(uri[i])) { - isascii = 0; - break; - } - } - if (isascii) { - handleplumb(c, uri); - webkit_policy_decision_ignore(d); - return; - } - } - - if (webkit_response_policy_decision_is_mime_type_supported(r)) { - webkit_policy_decision_use(d); - } else { - webkit_policy_decision_ignore(d); - download(c, res); - } -} - -void -insecurecontent(WebKitWebView *v, WebKitInsecureContentEvent e, Client *c) -{ - c->insecure = 1; -} - -void -downloadstarted(WebKitWebContext *wc, WebKitDownload *d, Client *c) -{ - g_signal_connect(G_OBJECT(d), "notify::response", - G_CALLBACK(responsereceived), c); -} - -void -responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c) -{ - download(c, webkit_download_get_response(d)); - webkit_download_cancel(d); -} - -void -download(Client *c, WebKitURIResponse *r) -{ - Arg a = (Arg)DOWNLOAD(webkit_uri_response_get_uri(r), geturi(c)); - spawn(c, &a); -} - -void -webprocessterminated(WebKitWebView *v, WebKitWebProcessTerminationReason r, - Client *c) -{ - fprintf(stderr, "web process terminated: %s\n", - r == WEBKIT_WEB_PROCESS_CRASHED ? "crashed" : "no memory"); - closeview(v, c); -} - -void -closeview(WebKitWebView *v, Client *c) -{ - gtk_widget_destroy(c->win); -} - -void -destroywin(GtkWidget* w, Client *c) -{ - destroyclient(c); - if (!clients) - gtk_main_quit(); -} - -void -pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) -{ - Arg a = {.v = text }; - if (text) - loaduri((Client *) d, &a); -} - -void -reload(Client *c, const Arg *a) -{ - if (a->i) - webkit_web_view_reload_bypass_cache(c->view); - else - webkit_web_view_reload(c->view); -} - -void -print(Client *c, const Arg *a) -{ - webkit_print_operation_run_dialog(webkit_print_operation_new(c->view), - GTK_WINDOW(c->win)); -} - -void -showcert(Client *c, const Arg *a) -{ - GTlsCertificate *cert = c->failedcert ? c->failedcert : c->cert; - GcrCertificate *gcrt; - GByteArray *crt; - GtkWidget *win; - GcrCertificateWidget *wcert; - - if (!cert) - return; - - g_object_get(cert, "certificate", &crt, NULL); - gcrt = gcr_simple_certificate_new(crt->data, crt->len); - g_byte_array_unref(crt); - - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - wcert = gcr_certificate_widget_new(gcrt); - g_object_unref(gcrt); - - gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(wcert)); - gtk_widget_show_all(win); -} - -void -clipboard(Client *c, const Arg *a) -{ - if (a->i) { /* load clipboard uri */ - gtk_clipboard_request_text(gtk_clipboard_get( - GDK_SELECTION_PRIMARY), - pasteuri, c); - } else { /* copy uri */ - gtk_clipboard_set_text(gtk_clipboard_get( - GDK_SELECTION_PRIMARY), c->targeturi - ? c->targeturi : geturi(c), -1); - } -} - -void -zoom(Client *c, const Arg *a) -{ - if (a->i > 0) - webkit_web_view_set_zoom_level(c->view, - curconfig[ZoomLevel].val.f + 0.1); - else if (a->i < 0) - webkit_web_view_set_zoom_level(c->view, - curconfig[ZoomLevel].val.f - 0.1); - else - webkit_web_view_set_zoom_level(c->view, 1.0); - - curconfig[ZoomLevel].val.f = webkit_web_view_get_zoom_level(c->view); -} - -static void -msgext(Client *c, char type, const Arg *a) -{ - static char msg[MSGBUFSZ]; - int ret; - - if (spair[0] < 0) - return; - - if ((ret = snprintf(msg, sizeof(msg), "%c%c%c", c->pageid, type, a->i)) - >= sizeof(msg)) { - fprintf(stderr, "surf: message too long: %d\n", ret); - return; - } - - if (send(spair[0], msg, ret, 0) != ret) - fprintf(stderr, "surf: error sending: %u%c%d (%d)\n", - c->pageid, type, a->i, ret); -} - -void -scrollv(Client *c, const Arg *a) -{ - msgext(c, 'v', a); -} - -void -scrollh(Client *c, const Arg *a) -{ - msgext(c, 'h', a); -} - -void -navigate(Client *c, const Arg *a) -{ - if (a->i < 0) - webkit_web_view_go_back(c->view); - else if (a->i > 0) - webkit_web_view_go_forward(c->view); -} - -void -stop(Client *c, const Arg *a) -{ - webkit_web_view_stop_loading(c->view); -} - -void -toggle(Client *c, const Arg *a) -{ - curconfig[a->i].val.i ^= 1; - setparameter(c, 1, (ParamName)a->i, &curconfig[a->i].val); -} - -void -togglefullscreen(Client *c, const Arg *a) -{ - /* toggling value is handled in winevent() */ - if (c->fullscreen) - gtk_window_unfullscreen(GTK_WINDOW(c->win)); - else - gtk_window_fullscreen(GTK_WINDOW(c->win)); -} - -void -togglecookiepolicy(Client *c, const Arg *a) -{ - ++cookiepolicy; - cookiepolicy %= strlen(curconfig[CookiePolicies].val.v); - - setparameter(c, 0, CookiePolicies, NULL); -} - -void -toggleinspector(Client *c, const Arg *a) -{ - if (webkit_web_inspector_is_attached(c->inspector)) - webkit_web_inspector_close(c->inspector); - else if (curconfig[Inspector].val.i) - webkit_web_inspector_show(c->inspector); -} - -void -find(Client *c, const Arg *a) -{ - const char *s, *f; - - if (a && a->i) { - if (a->i > 0) - webkit_find_controller_search_next(c->finder); - else - webkit_find_controller_search_previous(c->finder); - } else { - s = getatom(c, AtomFind); - f = webkit_find_controller_get_search_text(c->finder); - - if (g_strcmp0(f, s) == 0) /* reset search */ - webkit_find_controller_search(c->finder, "", findopts, - G_MAXUINT); - - webkit_find_controller_search(c->finder, s, findopts, - G_MAXUINT); - - if (strcmp(s, "") == 0) - webkit_find_controller_search_finish(c->finder); - } -} - -void -clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h) -{ - navigate(c, a); -} - -void -clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h) -{ - Arg arg; - - arg.v = webkit_hit_test_result_get_link_uri(h); - newwindow(c, &arg, a->i); -} - -void -clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h) -{ - Arg arg; - - arg = (Arg)VIDEOPLAY(webkit_hit_test_result_get_media_uri(h)); - spawn(c, &arg); -} - -int -main(int argc, char *argv[]) -{ - Arg arg; - Client *c; - - memset(&arg, 0, sizeof(arg)); - - /* command line args */ - ARGBEGIN { - case 'a': - defconfig[CookiePolicies].val.v = EARGF(usage()); - defconfig[CookiePolicies].prio = 2; - break; - case 'b': - defconfig[ScrollBars].val.i = 0; - defconfig[ScrollBars].prio = 2; - break; - case 'B': - defconfig[ScrollBars].val.i = 1; - defconfig[ScrollBars].prio = 2; - break; - case 'c': - cookiefile = EARGF(usage()); - break; - case 'C': - stylefile = EARGF(usage()); - break; - case 'd': - defconfig[DiskCache].val.i = 0; - defconfig[DiskCache].prio = 2; - break; - case 'D': - defconfig[DiskCache].val.i = 1; - defconfig[DiskCache].prio = 2; - break; - case 'e': - embed = strtol(EARGF(usage()), NULL, 0); - break; - case 'f': - defconfig[RunInFullscreen].val.i = 0; - defconfig[RunInFullscreen].prio = 2; - break; - case 'F': - defconfig[RunInFullscreen].val.i = 1; - defconfig[RunInFullscreen].prio = 2; - break; - case 'g': - defconfig[Geolocation].val.i = 0; - defconfig[Geolocation].prio = 2; - break; - case 'G': - defconfig[Geolocation].val.i = 1; - defconfig[Geolocation].prio = 2; - break; - case 'h': - cachedir = EARGF(usage()); - break; - case 'i': - defconfig[LoadImages].val.i = 0; - defconfig[LoadImages].prio = 2; - break; - case 'I': - defconfig[LoadImages].val.i = 1; - defconfig[LoadImages].prio = 2; - break; - case 'k': - defconfig[KioskMode].val.i = 0; - defconfig[KioskMode].prio = 2; - break; - case 'K': - defconfig[KioskMode].val.i = 1; - defconfig[KioskMode].prio = 2; - break; - case 'm': - defconfig[Style].val.i = 0; - defconfig[Style].prio = 2; - break; - case 'M': - defconfig[Style].val.i = 1; - defconfig[Style].prio = 2; - break; - case 'n': - defconfig[Inspector].val.i = 0; - defconfig[Inspector].prio = 2; - break; - case 'N': - defconfig[Inspector].val.i = 1; - defconfig[Inspector].prio = 2; - break; - case 'r': - scriptfile = EARGF(usage()); - break; - case 's': - defconfig[JavaScript].val.i = 0; - defconfig[JavaScript].prio = 2; - break; - case 'S': - defconfig[JavaScript].val.i = 1; - defconfig[JavaScript].prio = 2; - break; - case 't': - defconfig[StrictTLS].val.i = 0; - defconfig[StrictTLS].prio = 2; - break; - case 'T': - defconfig[StrictTLS].val.i = 1; - defconfig[StrictTLS].prio = 2; - break; - case 'u': - fulluseragent = EARGF(usage()); - break; - case 'v': - die("surf-"VERSION", see LICENSE for © details\n"); - case 'w': - showxid = 1; - break; - case 'x': - defconfig[Certificate].val.i = 0; - defconfig[Certificate].prio = 2; - break; - case 'X': - defconfig[Certificate].val.i = 1; - defconfig[Certificate].prio = 2; - break; - case 'z': - defconfig[ZoomLevel].val.f = strtof(EARGF(usage()), NULL); - defconfig[ZoomLevel].prio = 2; - break; - default: - usage(); - } ARGEND; - if (argc > 0) - arg.v = argv[0]; - else -#ifdef HOMEPAGE - arg.v = HOMEPAGE; -#else - arg.v = "about:blank"; -#endif - - setup(); - c = newclient(NULL); - showview(NULL, c); - - loaduri(c, &arg); - updatetitle(c); - - gtk_main(); - cleanup(); - - return 0; -} diff --git a/surf-2.1/surf.c.orig b/surf-2.1/surf.c.orig deleted file mode 100644 index 58dca79..0000000 --- a/surf-2.1/surf.c.orig +++ /dev/null @@ -1,2137 +0,0 @@ -/* See LICENSE file for copyright and license details. - * - * To understand surf, start reading main(). - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "arg.h" -#include "common.h" - -#define LENGTH(x) (sizeof(x) / sizeof(x[0])) -#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) - -enum { AtomFind, AtomGo, AtomUri, AtomLast }; - -enum { - OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT, - OnLink = WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK, - OnImg = WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE, - OnMedia = WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA, - OnEdit = WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE, - OnBar = WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR, - OnSel = WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION, - OnAny = OnDoc | OnLink | OnImg | OnMedia | OnEdit | OnBar | OnSel, -}; - -typedef enum { - AccessMicrophone, - AccessWebcam, - CaretBrowsing, - Certificate, - CookiePolicies, - DiskCache, - DefaultCharset, - DNSPrefetch, - Ephemeral, - FileURLsCrossAccess, - FontSize, - FrameFlattening, - Geolocation, - HideBackground, - Inspector, - Java, - JavaScript, - KioskMode, - LoadImages, - MediaManualPlay, - PreferredLanguages, - RunInFullscreen, - ScrollBars, - ShowIndicators, - SiteQuirks, - SmoothScrolling, - SpellChecking, - SpellLanguages, - StrictTLS, - Style, - WebGL, - ZoomLevel, - ParameterLast -} ParamName; - -typedef union { - int i; - float f; - const void *v; -} Arg; - -typedef struct { - Arg val; - int prio; -} Parameter; - -typedef struct Client { - GtkWidget *win; - WebKitWebView *view; - WebKitWebInspector *inspector; - WebKitFindController *finder; - WebKitHitTestResult *mousepos; - GTlsCertificate *cert, *failedcert; - GTlsCertificateFlags tlserr; - Window xid; - guint64 pageid; - int progress, fullscreen, https, insecure, errorpage; - const char *title, *overtitle, *targeturi; - const char *needle; - struct Client *next; -} Client; - -typedef struct { - guint mod; - guint keyval; - void (*func)(Client *c, const Arg *a); - const Arg arg; -} Key; - -typedef struct { - unsigned int target; - unsigned int mask; - guint button; - void (*func)(Client *c, const Arg *a, WebKitHitTestResult *h); - const Arg arg; - unsigned int stopevent; -} Button; - -typedef struct { - const char *uri; - Parameter config[ParameterLast]; - regex_t re; -} UriParameters; - -typedef struct { - char *regex; - char *file; - regex_t re; -} SiteSpecific; - -/* Surf */ -static void die(const char *errstr, ...); -static void usage(void); -static void setup(void); -static void sigchld(int unused); -static void sighup(int unused); -static char *buildfile(const char *path); -static char *buildpath(const char *path); -static char *untildepath(const char *path); -static const char *getuserhomedir(const char *user); -static const char *getcurrentuserhomedir(void); -static Client *newclient(Client *c); -static void loaduri(Client *c, const Arg *a); -static const char *geturi(Client *c); -static void setatom(Client *c, int a, const char *v); -static const char *getatom(Client *c, int a); -static void updatetitle(Client *c); -static void gettogglestats(Client *c); -static void getpagestats(Client *c); -static WebKitCookieAcceptPolicy cookiepolicy_get(void); -static char cookiepolicy_set(const WebKitCookieAcceptPolicy p); -static void seturiparameters(Client *c, const char *uri, ParamName *params); -static void setparameter(Client *c, int refresh, ParamName p, const Arg *a); -static const char *getcert(const char *uri); -static void setcert(Client *c, const char *file); -static const char *getstyle(const char *uri); -static void setstyle(Client *c, const char *file); -static void runscript(Client *c); -static void evalscript(Client *c, const char *jsstr, ...); -static void updatewinid(Client *c); -static void handleplumb(Client *c, const char *uri); -static void newwindow(Client *c, const Arg *a, int noembed); -static void spawn(Client *c, const Arg *a); -static void msgext(Client *c, char type, const Arg *a); -static void destroyclient(Client *c); -static void cleanup(void); - -/* GTK/WebKit */ -static WebKitWebView *newview(Client *c, WebKitWebView *rv); -static void initwebextensions(WebKitWebContext *wc, Client *c); -static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a, - Client *c); -static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c); -static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, - gpointer d); -static gboolean winevent(GtkWidget *w, GdkEvent *e, Client *c); -static gboolean readsock(GIOChannel *s, GIOCondition ioc, gpointer unused); -static void showview(WebKitWebView *v, Client *c); -static GtkWidget *createwindow(Client *c); -static gboolean loadfailedtls(WebKitWebView *v, gchar *uri, - GTlsCertificate *cert, - GTlsCertificateFlags err, Client *c); -static void loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c); -static void progresschanged(WebKitWebView *v, GParamSpec *ps, Client *c); -static void titlechanged(WebKitWebView *view, GParamSpec *ps, Client *c); -static void mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, - guint modifiers, Client *c); -static gboolean permissionrequested(WebKitWebView *v, - WebKitPermissionRequest *r, Client *c); -static gboolean decidepolicy(WebKitWebView *v, WebKitPolicyDecision *d, - WebKitPolicyDecisionType dt, Client *c); -static void decidenavigation(WebKitPolicyDecision *d, Client *c); -static void decidenewwindow(WebKitPolicyDecision *d, Client *c); -static void decideresource(WebKitPolicyDecision *d, Client *c); -static void insecurecontent(WebKitWebView *v, WebKitInsecureContentEvent e, - Client *c); -static void downloadstarted(WebKitWebContext *wc, WebKitDownload *d, - Client *c); -static void responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c); -static void download(Client *c, WebKitURIResponse *r); -static void webprocessterminated(WebKitWebView *v, - WebKitWebProcessTerminationReason r, - Client *c); -static void closeview(WebKitWebView *v, Client *c); -static void destroywin(GtkWidget* w, Client *c); - -/* Hotkeys */ -static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); -static void reload(Client *c, const Arg *a); -static void print(Client *c, const Arg *a); -static void showcert(Client *c, const Arg *a); -static void clipboard(Client *c, const Arg *a); -static void zoom(Client *c, const Arg *a); -static void scrollv(Client *c, const Arg *a); -static void scrollh(Client *c, const Arg *a); -static void navigate(Client *c, const Arg *a); -static void stop(Client *c, const Arg *a); -static void toggle(Client *c, const Arg *a); -static void togglefullscreen(Client *c, const Arg *a); -static void togglecookiepolicy(Client *c, const Arg *a); -static void toggleinspector(Client *c, const Arg *a); -static void find(Client *c, const Arg *a); - -/* Buttons */ -static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h); -static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h); -static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h); - -static char winid[64]; -static char togglestats[12]; -static char pagestats[2]; -static Atom atoms[AtomLast]; -static Window embed; -static int showxid; -static int cookiepolicy; -static Display *dpy; -static Client *clients; -static GdkDevice *gdkkb; -static char *stylefile; -static const char *useragent; -static Parameter *curconfig; -static int modparams[ParameterLast]; -static int spair[2]; -char *argv0; - -static ParamName loadtransient[] = { - Certificate, - CookiePolicies, - DiskCache, - DNSPrefetch, - FileURLsCrossAccess, - JavaScript, - LoadImages, - PreferredLanguages, - ShowIndicators, - StrictTLS, - ParameterLast -}; - -static ParamName loadcommitted[] = { -// AccessMicrophone, -// AccessWebcam, - CaretBrowsing, - DefaultCharset, - FontSize, - FrameFlattening, - Geolocation, - HideBackground, - Inspector, - Java, -// KioskMode, - MediaManualPlay, - RunInFullscreen, - ScrollBars, - SiteQuirks, - SmoothScrolling, - SpellChecking, - SpellLanguages, - Style, - ZoomLevel, - ParameterLast -}; - -static ParamName loadfinished[] = { - ParameterLast -}; - -/* configuration, allows nested code to access above variables */ -#include "config.h" - -void -die(const char *errstr, ...) -{ - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(1); -} - -void -usage(void) -{ - die("usage: surf [-bBdDfFgGiIkKmMnNpPsStTvwxX]\n" - "[-a cookiepolicies ] [-c cookiefile] [-C stylefile] [-e xid]\n" - "[-r scriptfile] [-u useragent] [-z zoomlevel] [uri]\n"); -} - -void -setup(void) -{ - GIOChannel *gchanin; - GdkDisplay *gdpy; - int i, j; - - /* clean up any zombies immediately */ - sigchld(0); - if (signal(SIGHUP, sighup) == SIG_ERR) - die("Can't install SIGHUP handler"); - - if (!(dpy = XOpenDisplay(NULL))) - die("Can't open default display"); - - /* atoms */ - atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); - atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); - atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); - - gtk_init(NULL, NULL); - - gdpy = gdk_display_get_default(); - - curconfig = defconfig; - - /* dirs and files */ - cookiefile = buildfile(cookiefile); - scriptfile = buildfile(scriptfile); - certdir = buildpath(certdir); - if (curconfig[Ephemeral].val.i) - cachedir = NULL; - else - cachedir = buildpath(cachedir); - - gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy)); - - if (socketpair(AF_UNIX, SOCK_DGRAM, 0, spair) < 0) { - fputs("Unable to create sockets\n", stderr); - spair[0] = spair[1] = -1; - } else { - gchanin = g_io_channel_unix_new(spair[0]); - g_io_channel_set_encoding(gchanin, NULL, NULL); - g_io_channel_set_flags(gchanin, g_io_channel_get_flags(gchanin) - | G_IO_FLAG_NONBLOCK, NULL); - g_io_channel_set_close_on_unref(gchanin, TRUE); - g_io_add_watch(gchanin, G_IO_IN, readsock, NULL); - } - - - for (i = 0; i < LENGTH(certs); ++i) { - if (!regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) { - certs[i].file = g_strconcat(certdir, "/", certs[i].file, - NULL); - } else { - fprintf(stderr, "Could not compile regex: %s\n", - certs[i].regex); - certs[i].regex = NULL; - } - } - - if (!stylefile) { - styledir = buildpath(styledir); - for (i = 0; i < LENGTH(styles); ++i) { - if (!regcomp(&(styles[i].re), styles[i].regex, - REG_EXTENDED)) { - styles[i].file = g_strconcat(styledir, "/", - styles[i].file, NULL); - } else { - fprintf(stderr, "Could not compile regex: %s\n", - styles[i].regex); - styles[i].regex = NULL; - } - } - g_free(styledir); - } else { - stylefile = buildfile(stylefile); - } - - for (i = 0; i < LENGTH(uriparams); ++i) { - if (regcomp(&(uriparams[i].re), uriparams[i].uri, - REG_EXTENDED)) { - fprintf(stderr, "Could not compile regex: %s\n", - uriparams[i].uri); - uriparams[i].uri = NULL; - continue; - } - - /* copy default parameters with higher priority */ - for (j = 0; j < ParameterLast; ++j) { - if (defconfig[j].prio >= uriparams[i].config[j].prio) - uriparams[i].config[j] = defconfig[j]; - } - } -} - -void -sigchld(int unused) -{ - if (signal(SIGCHLD, sigchld) == SIG_ERR) - die("Can't install SIGCHLD handler"); - while (waitpid(-1, NULL, WNOHANG) > 0) - ; -} - -void -sighup(int unused) -{ - Arg a = { .i = 0 }; - Client *c; - - for (c = clients; c; c = c->next) - reload(c, &a); -} - -char * -buildfile(const char *path) -{ - char *dname, *bname, *bpath, *fpath; - FILE *f; - - dname = g_path_get_dirname(path); - bname = g_path_get_basename(path); - - bpath = buildpath(dname); - g_free(dname); - - fpath = g_build_filename(bpath, bname, NULL); - g_free(bpath); - g_free(bname); - - if (!(f = fopen(fpath, "a"))) - die("Could not open file: %s\n", fpath); - - g_chmod(fpath, 0600); /* always */ - fclose(f); - - return fpath; -} - -static const char* -getuserhomedir(const char *user) -{ - struct passwd *pw = getpwnam(user); - - if (!pw) - die("Can't get user %s login information.\n", user); - - return pw->pw_dir; -} - -static const char* -getcurrentuserhomedir(void) -{ - const char *homedir; - const char *user; - struct passwd *pw; - - homedir = getenv("HOME"); - if (homedir) - return homedir; - - user = getenv("USER"); - if (user) - return getuserhomedir(user); - - pw = getpwuid(getuid()); - if (!pw) - die("Can't get current user home directory\n"); - - return pw->pw_dir; -} - -char * -buildpath(const char *path) -{ - char *apath, *fpath; - - if (path[0] == '~') - apath = untildepath(path); - else - apath = g_strdup(path); - - /* creating directory */ - if (g_mkdir_with_parents(apath, 0700) < 0) - die("Could not access directory: %s\n", apath); - - fpath = realpath(apath, NULL); - g_free(apath); - - return fpath; -} - -char * -untildepath(const char *path) -{ - char *apath, *name, *p; - const char *homedir; - - if (path[1] == '/' || path[1] == '\0') { - p = (char *)&path[1]; - homedir = getcurrentuserhomedir(); - } else { - if ((p = strchr(path, '/'))) - name = g_strndup(&path[1], p - (path + 1)); - else - name = g_strdup(&path[1]); - - homedir = getuserhomedir(name); - g_free(name); - } - apath = g_build_filename(homedir, p, NULL); - return apath; -} - -Client * -newclient(Client *rc) -{ - Client *c; - - if (!(c = calloc(1, sizeof(Client)))) - die("Cannot malloc!\n"); - - c->next = clients; - clients = c; - - c->progress = 100; - c->view = newview(c, rc ? rc->view : NULL); - - return c; -} - -void -loaduri(Client *c, const Arg *a) -{ - struct stat st; - char *url, *path, *apath; - const char *uri = a->v; - - if (g_strcmp0(uri, "") == 0) - return; - - if (g_str_has_prefix(uri, "http://") || - g_str_has_prefix(uri, "https://") || - g_str_has_prefix(uri, "file://") || - g_str_has_prefix(uri, "about:")) { - url = g_strdup(uri); - } else { - if (uri[0] == '~') - apath = untildepath(uri); - else - apath = (char *)uri; - if (!stat(apath, &st) && (path = realpath(apath, NULL))) { - url = g_strdup_printf("file://%s", path); - free(path); - } else { - url = g_strdup_printf("http://%s", uri); - } - if (apath != uri) - free(apath); - } - - setatom(c, AtomUri, url); - - if (strcmp(url, geturi(c)) == 0) { - reload(c, a); - } else { - webkit_web_view_load_uri(c->view, url); - updatetitle(c); - } - - g_free(url); -} - -const char * -geturi(Client *c) -{ - const char *uri; - - if (!(uri = webkit_web_view_get_uri(c->view))) - uri = "about:blank"; - return uri; -} - -void -setatom(Client *c, int a, const char *v) -{ - XChangeProperty(dpy, c->xid, - atoms[a], XA_STRING, 8, PropModeReplace, - (unsigned char *)v, strlen(v) + 1); - XSync(dpy, False); -} - -const char * -getatom(Client *c, int a) -{ - static char buf[BUFSIZ]; - Atom adummy; - int idummy; - unsigned long ldummy; - unsigned char *p = NULL; - - XSync(dpy, False); - XGetWindowProperty(dpy, c->xid, atoms[a], 0L, BUFSIZ, False, XA_STRING, - &adummy, &idummy, &ldummy, &ldummy, &p); - if (p) - strncpy(buf, (char *)p, LENGTH(buf) - 1); - else - buf[0] = '\0'; - XFree(p); - - return buf; -} - -void -updatetitle(Client *c) -{ - char *title; - const char *name = c->overtitle ? c->overtitle : - c->title ? c->title : ""; - - if (curconfig[ShowIndicators].val.i) { - gettogglestats(c); - getpagestats(c); - - if (c->progress != 100) - title = g_strdup_printf("[%i%%] %s:%s | %s", - c->progress, togglestats, pagestats, name); - else - title = g_strdup_printf("%s:%s | %s", - togglestats, pagestats, name); - - gtk_window_set_title(GTK_WINDOW(c->win), title); - g_free(title); - } else { - gtk_window_set_title(GTK_WINDOW(c->win), name); - } -} - -void -gettogglestats(Client *c) -{ - togglestats[0] = cookiepolicy_set(cookiepolicy_get()); - togglestats[1] = curconfig[CaretBrowsing].val.i ? 'C' : 'c'; - togglestats[2] = curconfig[Geolocation].val.i ? 'G' : 'g'; - togglestats[3] = curconfig[DiskCache].val.i ? 'D' : 'd'; - togglestats[4] = curconfig[LoadImages].val.i ? 'I' : 'i'; - togglestats[5] = curconfig[JavaScript].val.i ? 'S' : 's'; - togglestats[7] = curconfig[Style].val.i ? 'M' : 'm'; - togglestats[8] = curconfig[FrameFlattening].val.i ? 'F' : 'f'; - togglestats[9] = curconfig[Certificate].val.i ? 'X' : 'x'; - togglestats[10] = curconfig[StrictTLS].val.i ? 'T' : 't'; - togglestats[11] = '\0'; -} - -void -getpagestats(Client *c) -{ - if (c->https) - pagestats[0] = (c->tlserr || c->insecure) ? 'U' : 'T'; - else - pagestats[0] = '-'; - pagestats[1] = '\0'; -} - -WebKitCookieAcceptPolicy -cookiepolicy_get(void) -{ - switch (((char *)curconfig[CookiePolicies].val.v)[cookiepolicy]) { - case 'a': - return WEBKIT_COOKIE_POLICY_ACCEPT_NEVER; - case '@': - return WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY; - default: /* fallthrough */ - case 'A': - return WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS; - } -} - -char -cookiepolicy_set(const WebKitCookieAcceptPolicy p) -{ - switch (p) { - case WEBKIT_COOKIE_POLICY_ACCEPT_NEVER: - return 'a'; - case WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY: - return '@'; - default: /* fallthrough */ - case WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS: - return 'A'; - } -} - -void -seturiparameters(Client *c, const char *uri, ParamName *params) -{ - Parameter *config, *uriconfig = NULL; - int i, p; - - for (i = 0; i < LENGTH(uriparams); ++i) { - if (uriparams[i].uri && - !regexec(&(uriparams[i].re), uri, 0, NULL, 0)) { - uriconfig = uriparams[i].config; - break; - } - } - - curconfig = uriconfig ? uriconfig : defconfig; - - for (i = 0; (p = params[i]) != ParameterLast; ++i) { - switch(p) { - default: /* FALLTHROUGH */ - if (!(defconfig[p].prio < curconfig[p].prio || - defconfig[p].prio < modparams[p])) - continue; - case Certificate: - case CookiePolicies: - case Style: - setparameter(c, 0, p, &curconfig[p].val); - } - } -} - -void -setparameter(Client *c, int refresh, ParamName p, const Arg *a) -{ - GdkRGBA bgcolor = { 0 }; - WebKitSettings *s = webkit_web_view_get_settings(c->view); - - modparams[p] = curconfig[p].prio; - - switch (p) { - case AccessMicrophone: - return; /* do nothing */ - case AccessWebcam: - return; /* do nothing */ - case CaretBrowsing: - webkit_settings_set_enable_caret_browsing(s, a->i); - refresh = 0; - break; - case Certificate: - if (a->i) - setcert(c, geturi(c)); - return; /* do not update */ - case CookiePolicies: - webkit_cookie_manager_set_accept_policy( - webkit_web_context_get_cookie_manager( - webkit_web_view_get_context(c->view)), - cookiepolicy_get()); - refresh = 0; - break; - case DiskCache: - webkit_web_context_set_cache_model( - webkit_web_view_get_context(c->view), a->i ? - WEBKIT_CACHE_MODEL_WEB_BROWSER : - WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); - return; /* do not update */ - case DefaultCharset: - webkit_settings_set_default_charset(s, a->v); - return; /* do not update */ - case DNSPrefetch: - webkit_settings_set_enable_dns_prefetching(s, a->i); - return; /* do not update */ - case FileURLsCrossAccess: - webkit_settings_set_allow_file_access_from_file_urls(s, a->i); - webkit_settings_set_allow_universal_access_from_file_urls(s, a->i); - return; /* do not update */ - case FontSize: - webkit_settings_set_default_font_size(s, a->i); - return; /* do not update */ - case FrameFlattening: - webkit_settings_set_enable_frame_flattening(s, a->i); - break; - case Geolocation: - refresh = 0; - break; - case HideBackground: - if (a->i) - webkit_web_view_set_background_color(c->view, &bgcolor); - return; /* do not update */ - case Inspector: - webkit_settings_set_enable_developer_extras(s, a->i); - return; /* do not update */ - case Java: - webkit_settings_set_enable_java(s, a->i); - return; /* do not update */ - case JavaScript: - webkit_settings_set_enable_javascript(s, a->i); - break; - case KioskMode: - return; /* do nothing */ - case LoadImages: - webkit_settings_set_auto_load_images(s, a->i); - break; - case MediaManualPlay: - webkit_settings_set_media_playback_requires_user_gesture(s, a->i); - break; - case PreferredLanguages: - return; /* do nothing */ - case RunInFullscreen: - return; /* do nothing */ - case ScrollBars: - /* Disabled until we write some WebKitWebExtension for - * manipulating the DOM directly. - enablescrollbars = !enablescrollbars; - evalscript(c, "document.documentElement.style.overflow = '%s'", - enablescrollbars ? "auto" : "hidden"); - */ - return; /* do not update */ - case ShowIndicators: - break; - case SmoothScrolling: - webkit_settings_set_enable_smooth_scrolling(s, a->i); - return; /* do not update */ - case SiteQuirks: - webkit_settings_set_enable_site_specific_quirks(s, a->i); - break; - case SpellChecking: - webkit_web_context_set_spell_checking_enabled( - webkit_web_view_get_context(c->view), a->i); - return; /* do not update */ - case SpellLanguages: - return; /* do nothing */ - case StrictTLS: - webkit_web_context_set_tls_errors_policy( - webkit_web_view_get_context(c->view), a->i ? - WEBKIT_TLS_ERRORS_POLICY_FAIL : - WEBKIT_TLS_ERRORS_POLICY_IGNORE); - break; - case Style: - webkit_user_content_manager_remove_all_style_sheets( - webkit_web_view_get_user_content_manager(c->view)); - if (a->i) - setstyle(c, getstyle(geturi(c))); - refresh = 0; - break; - case WebGL: - webkit_settings_set_enable_webgl(s, a->i); - break; - case ZoomLevel: - webkit_web_view_set_zoom_level(c->view, a->f); - return; /* do not update */ - default: - return; /* do nothing */ - } - - updatetitle(c); - if (refresh) - reload(c, a); -} - -const char * -getcert(const char *uri) -{ - int i; - - for (i = 0; i < LENGTH(certs); ++i) { - if (certs[i].regex && - !regexec(&(certs[i].re), uri, 0, NULL, 0)) - return certs[i].file; - } - - return NULL; -} - -void -setcert(Client *c, const char *uri) -{ - const char *file = getcert(uri); - char *host; - GTlsCertificate *cert; - - if (!file) - return; - - if (!(cert = g_tls_certificate_new_from_file(file, NULL))) { - fprintf(stderr, "Could not read certificate file: %s\n", file); - return; - } - - if ((uri = strstr(uri, "https://"))) { - uri += sizeof("https://") - 1; - host = g_strndup(uri, strchr(uri, '/') - uri); - webkit_web_context_allow_tls_certificate_for_host( - webkit_web_view_get_context(c->view), cert, host); - g_free(host); - } - - g_object_unref(cert); - -} - -const char * -getstyle(const char *uri) -{ - int i; - - if (stylefile) - return stylefile; - - for (i = 0; i < LENGTH(styles); ++i) { - if (styles[i].regex && - !regexec(&(styles[i].re), uri, 0, NULL, 0)) - return styles[i].file; - } - - return ""; -} - -void -setstyle(Client *c, const char *file) -{ - gchar *style; - - if (!g_file_get_contents(file, &style, NULL, NULL)) { - fprintf(stderr, "Could not read style file: %s\n", file); - return; - } - - webkit_user_content_manager_add_style_sheet( - webkit_web_view_get_user_content_manager(c->view), - webkit_user_style_sheet_new(style, - WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, - WEBKIT_USER_STYLE_LEVEL_USER, - NULL, NULL)); - - g_free(style); -} - -void -runscript(Client *c) -{ - gchar *script; - gsize l; - - if (g_file_get_contents(scriptfile, &script, &l, NULL) && l) - evalscript(c, "%s", script); - g_free(script); -} - -void -evalscript(Client *c, const char *jsstr, ...) -{ - va_list ap; - gchar *script; - - va_start(ap, jsstr); - script = g_strdup_vprintf(jsstr, ap); - va_end(ap); - - webkit_web_view_run_javascript(c->view, script, NULL, NULL, NULL); - g_free(script); -} - -void -updatewinid(Client *c) -{ - snprintf(winid, LENGTH(winid), "%lu", c->xid); -} - -void -handleplumb(Client *c, const char *uri) -{ - Arg a = (Arg)PLUMB(uri); - spawn(c, &a); -} - -void -newwindow(Client *c, const Arg *a, int noembed) -{ - int i = 0; - char tmp[64]; - const char *cmd[29], *uri; - const Arg arg = { .v = cmd }; - - cmd[i++] = argv0; - cmd[i++] = "-a"; - cmd[i++] = curconfig[CookiePolicies].val.v; - cmd[i++] = curconfig[ScrollBars].val.i ? "-B" : "-b"; - if (cookiefile && g_strcmp0(cookiefile, "")) { - cmd[i++] = "-c"; - cmd[i++] = cookiefile; - } - if (stylefile && g_strcmp0(stylefile, "")) { - cmd[i++] = "-C"; - cmd[i++] = stylefile; - } - cmd[i++] = curconfig[DiskCache].val.i ? "-D" : "-d"; - if (embed && !noembed) { - cmd[i++] = "-e"; - snprintf(tmp, LENGTH(tmp), "%lu", embed); - cmd[i++] = tmp; - } - cmd[i++] = curconfig[RunInFullscreen].val.i ? "-F" : "-f" ; - cmd[i++] = curconfig[Geolocation].val.i ? "-G" : "-g" ; - cmd[i++] = curconfig[LoadImages].val.i ? "-I" : "-i" ; - cmd[i++] = curconfig[KioskMode].val.i ? "-K" : "-k" ; - cmd[i++] = curconfig[Style].val.i ? "-M" : "-m" ; - cmd[i++] = curconfig[Inspector].val.i ? "-N" : "-n" ; - if (scriptfile && g_strcmp0(scriptfile, "")) { - cmd[i++] = "-r"; - cmd[i++] = scriptfile; - } - cmd[i++] = curconfig[JavaScript].val.i ? "-S" : "-s"; - cmd[i++] = curconfig[StrictTLS].val.i ? "-T" : "-t"; - if (fulluseragent && g_strcmp0(fulluseragent, "")) { - cmd[i++] = "-u"; - cmd[i++] = fulluseragent; - } - if (showxid) - cmd[i++] = "-w"; - cmd[i++] = curconfig[Certificate].val.i ? "-X" : "-x" ; - /* do not keep zoom level */ - cmd[i++] = "--"; - if ((uri = a->v)) - cmd[i++] = uri; - cmd[i] = NULL; - - spawn(c, &arg); -} - -void -spawn(Client *c, const Arg *a) -{ - if (fork() == 0) { - if (dpy) - close(ConnectionNumber(dpy)); - close(spair[0]); - close(spair[1]); - setsid(); - execvp(((char **)a->v)[0], (char **)a->v); - fprintf(stderr, "%s: execvp %s", argv0, ((char **)a->v)[0]); - perror(" failed"); - exit(1); - } -} - -void -destroyclient(Client *c) -{ - Client *p; - - webkit_web_view_stop_loading(c->view); - /* Not needed, has already been called - gtk_widget_destroy(c->win); - */ - - for (p = clients; p && p->next != c; p = p->next) - ; - if (p) - p->next = c->next; - else - clients = c->next; - free(c); -} - -void -cleanup(void) -{ - while (clients) - destroyclient(clients); - - close(spair[0]); - close(spair[1]); - g_free(cookiefile); - g_free(scriptfile); - g_free(stylefile); - g_free(cachedir); - XCloseDisplay(dpy); -} - -WebKitWebView * -newview(Client *c, WebKitWebView *rv) -{ - WebKitWebView *v; - WebKitSettings *settings; - WebKitWebContext *context; - WebKitCookieManager *cookiemanager; - WebKitUserContentManager *contentmanager; - - /* Webview */ - if (rv) { - v = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(rv)); - } else { - settings = webkit_settings_new_with_settings( - "allow-file-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i, - "allow-universal-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i, - "auto-load-images", curconfig[LoadImages].val.i, - "default-charset", curconfig[DefaultCharset].val.v, - "default-font-size", curconfig[FontSize].val.i, - "enable-caret-browsing", curconfig[CaretBrowsing].val.i, - "enable-developer-extras", curconfig[Inspector].val.i, - "enable-dns-prefetching", curconfig[DNSPrefetch].val.i, - "enable-frame-flattening", curconfig[FrameFlattening].val.i, - "enable-html5-database", curconfig[DiskCache].val.i, - "enable-html5-local-storage", curconfig[DiskCache].val.i, - "enable-java", curconfig[Java].val.i, - "enable-javascript", curconfig[JavaScript].val.i, - "enable-site-specific-quirks", curconfig[SiteQuirks].val.i, - "enable-smooth-scrolling", curconfig[SmoothScrolling].val.i, - "enable-webgl", curconfig[WebGL].val.i, - "media-playback-requires-user-gesture", curconfig[MediaManualPlay].val.i, - NULL); -/* For more interesting settings, have a look at - * http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html */ - - if (strcmp(fulluseragent, "")) { - webkit_settings_set_user_agent(settings, fulluseragent); - } else if (surfuseragent) { - webkit_settings_set_user_agent_with_application_details( - settings, "Surf", VERSION); - } - useragent = webkit_settings_get_user_agent(settings); - - contentmanager = webkit_user_content_manager_new(); - - if (curconfig[Ephemeral].val.i) { - context = webkit_web_context_new_ephemeral(); - } else { - context = webkit_web_context_new_with_website_data_manager( - webkit_website_data_manager_new( - "base-cache-directory", cachedir, - "base-data-directory", cachedir, - NULL)); - } - - - cookiemanager = webkit_web_context_get_cookie_manager(context); - - /* rendering process model, can be a shared unique one - * or one for each view */ - webkit_web_context_set_process_model(context, - WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); - /* TLS */ - webkit_web_context_set_tls_errors_policy(context, - curconfig[StrictTLS].val.i ? WEBKIT_TLS_ERRORS_POLICY_FAIL : - WEBKIT_TLS_ERRORS_POLICY_IGNORE); - /* disk cache */ - webkit_web_context_set_cache_model(context, - curconfig[DiskCache].val.i ? WEBKIT_CACHE_MODEL_WEB_BROWSER : - WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER); - - /* Currently only works with text file to be compatible with curl */ - if (!curconfig[Ephemeral].val.i) - webkit_cookie_manager_set_persistent_storage(cookiemanager, - cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); - /* cookie policy */ - webkit_cookie_manager_set_accept_policy(cookiemanager, - cookiepolicy_get()); - /* languages */ - webkit_web_context_set_preferred_languages(context, - curconfig[PreferredLanguages].val.v); - webkit_web_context_set_spell_checking_languages(context, - curconfig[SpellLanguages].val.v); - webkit_web_context_set_spell_checking_enabled(context, - curconfig[SpellChecking].val.i); - - g_signal_connect(G_OBJECT(context), "download-started", - G_CALLBACK(downloadstarted), c); - g_signal_connect(G_OBJECT(context), "initialize-web-extensions", - G_CALLBACK(initwebextensions), c); - - v = g_object_new(WEBKIT_TYPE_WEB_VIEW, - "settings", settings, - "user-content-manager", contentmanager, - "web-context", context, - NULL); - } - - g_signal_connect(G_OBJECT(v), "notify::estimated-load-progress", - G_CALLBACK(progresschanged), c); - g_signal_connect(G_OBJECT(v), "notify::title", - G_CALLBACK(titlechanged), c); - g_signal_connect(G_OBJECT(v), "button-release-event", - G_CALLBACK(buttonreleased), c); - g_signal_connect(G_OBJECT(v), "close", - G_CALLBACK(closeview), c); - g_signal_connect(G_OBJECT(v), "create", - G_CALLBACK(createview), c); - g_signal_connect(G_OBJECT(v), "decide-policy", - G_CALLBACK(decidepolicy), c); - g_signal_connect(G_OBJECT(v), "insecure-content-detected", - G_CALLBACK(insecurecontent), c); - g_signal_connect(G_OBJECT(v), "load-failed-with-tls-errors", - G_CALLBACK(loadfailedtls), c); - g_signal_connect(G_OBJECT(v), "load-changed", - G_CALLBACK(loadchanged), c); - g_signal_connect(G_OBJECT(v), "mouse-target-changed", - G_CALLBACK(mousetargetchanged), c); - g_signal_connect(G_OBJECT(v), "permission-request", - G_CALLBACK(permissionrequested), c); - g_signal_connect(G_OBJECT(v), "ready-to-show", - G_CALLBACK(showview), c); - g_signal_connect(G_OBJECT(v), "web-process-terminated", - G_CALLBACK(webprocessterminated), c); - - return v; -} - -static gboolean -readsock(GIOChannel *s, GIOCondition ioc, gpointer unused) -{ - static char msg[MSGBUFSZ]; - GError *gerr = NULL; - gsize msgsz; - - if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) != - G_IO_STATUS_NORMAL) { - if (gerr) { - fprintf(stderr, "surf: error reading socket: %s\n", - gerr->message); - g_error_free(gerr); - } - return TRUE; - } - if (msgsz < 2) { - fprintf(stderr, "surf: message too short: %d\n", msgsz); - return TRUE; - } - - return TRUE; -} - -void -initwebextensions(WebKitWebContext *wc, Client *c) -{ - GVariant *gv; - - if (spair[1] < 0) - return; - - gv = g_variant_new("i", spair[1]); - - webkit_web_context_set_web_extensions_initialization_user_data(wc, gv); - webkit_web_context_set_web_extensions_directory(wc, WEBEXTDIR); -} - -GtkWidget * -createview(WebKitWebView *v, WebKitNavigationAction *a, Client *c) -{ - Client *n; - - switch (webkit_navigation_action_get_navigation_type(a)) { - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - /* - * popup windows of type “other” are almost always triggered - * by user gesture, so inverse the logic here - */ -/* instead of this, compare destination uri to mouse-over uri for validating window */ - if (webkit_navigation_action_is_user_gesture(a)) - return NULL; - case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - n = newclient(c); - break; - default: - return NULL; - } - - return GTK_WIDGET(n->view); -} - -gboolean -buttonreleased(GtkWidget *w, GdkEvent *e, Client *c) -{ - WebKitHitTestResultContext element; - int i; - - element = webkit_hit_test_result_get_context(c->mousepos); - - for (i = 0; i < LENGTH(buttons); ++i) { - if (element & buttons[i].target && - e->button.button == buttons[i].button && - CLEANMASK(e->button.state) == CLEANMASK(buttons[i].mask) && - buttons[i].func) { - buttons[i].func(c, &buttons[i].arg, c->mousepos); - return buttons[i].stopevent; - } - } - - return FALSE; -} - -GdkFilterReturn -processx(GdkXEvent *e, GdkEvent *event, gpointer d) -{ - Client *c = (Client *)d; - XPropertyEvent *ev; - Arg a; - - if (((XEvent *)e)->type == PropertyNotify) { - ev = &((XEvent *)e)->xproperty; - if (ev->state == PropertyNewValue) { - if (ev->atom == atoms[AtomFind]) { - find(c, NULL); - - return GDK_FILTER_REMOVE; - } else if (ev->atom == atoms[AtomGo]) { - a.v = getatom(c, AtomGo); - loaduri(c, &a); - - return GDK_FILTER_REMOVE; - } - } - } - return GDK_FILTER_CONTINUE; -} - -gboolean -winevent(GtkWidget *w, GdkEvent *e, Client *c) -{ - int i; - - switch (e->type) { - case GDK_ENTER_NOTIFY: - c->overtitle = c->targeturi; - updatetitle(c); - break; - case GDK_KEY_PRESS: - if (!curconfig[KioskMode].val.i) { - for (i = 0; i < LENGTH(keys); ++i) { - if (gdk_keyval_to_lower(e->key.keyval) == - keys[i].keyval && - CLEANMASK(e->key.state) == keys[i].mod && - keys[i].func) { - updatewinid(c); - keys[i].func(c, &(keys[i].arg)); - return TRUE; - } - } - } - case GDK_LEAVE_NOTIFY: - c->overtitle = NULL; - updatetitle(c); - break; - case GDK_WINDOW_STATE: - if (e->window_state.changed_mask == - GDK_WINDOW_STATE_FULLSCREEN) - c->fullscreen = e->window_state.new_window_state & - GDK_WINDOW_STATE_FULLSCREEN; - break; - default: - break; - } - - return FALSE; -} - -void -showview(WebKitWebView *v, Client *c) -{ - GdkRGBA bgcolor = { 0 }; - GdkWindow *gwin; - - c->finder = webkit_web_view_get_find_controller(c->view); - c->inspector = webkit_web_view_get_inspector(c->view); - - c->pageid = webkit_web_view_get_page_id(c->view); - c->win = createwindow(c); - - gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view)); - gtk_widget_show_all(c->win); - gtk_widget_grab_focus(GTK_WIDGET(c->view)); - - gwin = gtk_widget_get_window(GTK_WIDGET(c->win)); - c->xid = gdk_x11_window_get_xid(gwin); - updatewinid(c); - if (showxid) { - gdk_display_sync(gtk_widget_get_display(c->win)); - puts(winid); - fflush(stdout); - } - - if (curconfig[HideBackground].val.i) - webkit_web_view_set_background_color(c->view, &bgcolor); - - if (!curconfig[KioskMode].val.i) { - gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK); - gdk_window_add_filter(gwin, processx, c); - } - - if (curconfig[RunInFullscreen].val.i) - togglefullscreen(c, NULL); - - if (curconfig[ZoomLevel].val.f != 1.0) - webkit_web_view_set_zoom_level(c->view, - curconfig[ZoomLevel].val.f); - - setatom(c, AtomFind, ""); - setatom(c, AtomUri, "about:blank"); -} - -GtkWidget * -createwindow(Client *c) -{ - char *wmstr; - GtkWidget *w; - - if (embed) { - w = gtk_plug_new(embed); - } else { - w = gtk_window_new(GTK_WINDOW_TOPLEVEL); - - wmstr = g_path_get_basename(argv0); - gtk_window_set_wmclass(GTK_WINDOW(w), wmstr, "Surf"); - g_free(wmstr); - - wmstr = g_strdup_printf("%s[%"PRIu64"]", "Surf", c->pageid); - gtk_window_set_role(GTK_WINDOW(w), wmstr); - g_free(wmstr); - - gtk_window_set_default_size(GTK_WINDOW(w), winsize[0], winsize[1]); - } - - g_signal_connect(G_OBJECT(w), "destroy", - G_CALLBACK(destroywin), c); - g_signal_connect(G_OBJECT(w), "enter-notify-event", - G_CALLBACK(winevent), c); - g_signal_connect(G_OBJECT(w), "key-press-event", - G_CALLBACK(winevent), c); - g_signal_connect(G_OBJECT(w), "leave-notify-event", - G_CALLBACK(winevent), c); - g_signal_connect(G_OBJECT(w), "window-state-event", - G_CALLBACK(winevent), c); - - return w; -} - -gboolean -loadfailedtls(WebKitWebView *v, gchar *uri, GTlsCertificate *cert, - GTlsCertificateFlags err, Client *c) -{ - GString *errmsg = g_string_new(NULL); - gchar *html, *pem; - - c->failedcert = g_object_ref(cert); - c->tlserr = err; - c->errorpage = 1; - - if (err & G_TLS_CERTIFICATE_UNKNOWN_CA) - g_string_append(errmsg, - "The signing certificate authority is not known.
"); - if (err & G_TLS_CERTIFICATE_BAD_IDENTITY) - g_string_append(errmsg, - "The certificate does not match the expected identity " - "of the site that it was retrieved from.
"); - if (err & G_TLS_CERTIFICATE_NOT_ACTIVATED) - g_string_append(errmsg, - "The certificate's activation time " - "is still in the future.
"); - if (err & G_TLS_CERTIFICATE_EXPIRED) - g_string_append(errmsg, "The certificate has expired.
"); - if (err & G_TLS_CERTIFICATE_REVOKED) - g_string_append(errmsg, - "The certificate has been revoked according to " - "the GTlsConnection's certificate revocation list.
"); - if (err & G_TLS_CERTIFICATE_INSECURE) - g_string_append(errmsg, - "The certificate's algorithm is considered insecure.
"); - if (err & G_TLS_CERTIFICATE_GENERIC_ERROR) - g_string_append(errmsg, - "Some error occurred validating the certificate.
"); - - g_object_get(cert, "certificate-pem", &pem, NULL); - html = g_strdup_printf("

Could not validate TLS for “%s”
%s

" - "

You can inspect the following certificate " - "with Ctrl-t (default keybinding).

" - "

%s

", uri, errmsg->str, pem); - g_free(pem); - g_string_free(errmsg, TRUE); - - webkit_web_view_load_alternate_html(c->view, html, uri, NULL); - g_free(html); - - return TRUE; -} - -void -loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c) -{ - const char *uri = geturi(c); - - switch (e) { - case WEBKIT_LOAD_STARTED: - setatom(c, AtomUri, uri); - c->title = uri; - c->https = c->insecure = 0; - seturiparameters(c, uri, loadtransient); - if (c->errorpage) - c->errorpage = 0; - else - g_clear_object(&c->failedcert); - break; - case WEBKIT_LOAD_REDIRECTED: - setatom(c, AtomUri, uri); - c->title = uri; - seturiparameters(c, uri, loadtransient); - break; - case WEBKIT_LOAD_COMMITTED: - setatom(c, AtomUri, uri); - c->title = uri; - seturiparameters(c, uri, loadcommitted); - c->https = webkit_web_view_get_tls_info(c->view, &c->cert, - &c->tlserr); - break; - case WEBKIT_LOAD_FINISHED: - seturiparameters(c, uri, loadfinished); - /* Disabled until we write some WebKitWebExtension for - * manipulating the DOM directly. - evalscript(c, "document.documentElement.style.overflow = '%s'", - enablescrollbars ? "auto" : "hidden"); - */ - runscript(c); - break; - } - updatetitle(c); -} - -void -progresschanged(WebKitWebView *v, GParamSpec *ps, Client *c) -{ - c->progress = webkit_web_view_get_estimated_load_progress(c->view) * - 100; - updatetitle(c); -} - -void -titlechanged(WebKitWebView *view, GParamSpec *ps, Client *c) -{ - c->title = webkit_web_view_get_title(c->view); - updatetitle(c); -} - -void -mousetargetchanged(WebKitWebView *v, WebKitHitTestResult *h, guint modifiers, - Client *c) -{ - WebKitHitTestResultContext hc = webkit_hit_test_result_get_context(h); - - /* Keep the hit test to know where is the pointer on the next click */ - c->mousepos = h; - - if (hc & OnLink) - c->targeturi = webkit_hit_test_result_get_link_uri(h); - else if (hc & OnImg) - c->targeturi = webkit_hit_test_result_get_image_uri(h); - else if (hc & OnMedia) - c->targeturi = webkit_hit_test_result_get_media_uri(h); - else - c->targeturi = NULL; - - c->overtitle = c->targeturi; - updatetitle(c); -} - -gboolean -permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c) -{ - ParamName param = ParameterLast; - - if (WEBKIT_IS_GEOLOCATION_PERMISSION_REQUEST(r)) { - param = Geolocation; - } else if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(r)) { - if (webkit_user_media_permission_is_for_audio_device( - WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r))) - param = AccessMicrophone; - else if (webkit_user_media_permission_is_for_video_device( - WEBKIT_USER_MEDIA_PERMISSION_REQUEST(r))) - param = AccessWebcam; - } else { - return FALSE; - } - - if (curconfig[param].val.i) - webkit_permission_request_allow(r); - else - webkit_permission_request_deny(r); - - return TRUE; -} - -gboolean -decidepolicy(WebKitWebView *v, WebKitPolicyDecision *d, - WebKitPolicyDecisionType dt, Client *c) -{ - switch (dt) { - case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: - decidenavigation(d, c); - break; - case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: - decidenewwindow(d, c); - break; - case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: - decideresource(d, c); - break; - default: - webkit_policy_decision_ignore(d); - break; - } - return TRUE; -} - -void -decidenavigation(WebKitPolicyDecision *d, Client *c) -{ - WebKitNavigationAction *a = - webkit_navigation_policy_decision_get_navigation_action( - WEBKIT_NAVIGATION_POLICY_DECISION(d)); - - switch (webkit_navigation_action_get_navigation_type(a)) { - case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - default: - /* Do not navigate to links with a "_blank" target (popup) */ - if (webkit_navigation_policy_decision_get_frame_name( - WEBKIT_NAVIGATION_POLICY_DECISION(d))) { - webkit_policy_decision_ignore(d); - } else { - /* Filter out navigation to different domain ? */ - /* get action→urirequest, copy and load in new window+view - * on Ctrl+Click ? */ - webkit_policy_decision_use(d); - } - break; - } -} - -void -decidenewwindow(WebKitPolicyDecision *d, Client *c) -{ - Arg arg; - WebKitNavigationAction *a = - webkit_navigation_policy_decision_get_navigation_action( - WEBKIT_NAVIGATION_POLICY_DECISION(d)); - - - switch (webkit_navigation_action_get_navigation_type(a)) { - case WEBKIT_NAVIGATION_TYPE_LINK_CLICKED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_BACK_FORWARD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_RELOAD: /* fallthrough */ - case WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED: - /* Filter domains here */ -/* If the value of “mouse-button” is not 0, then the navigation was triggered by a mouse event. - * test for link clicked but no button ? */ - arg.v = webkit_uri_request_get_uri( - webkit_navigation_action_get_request(a)); - newwindow(c, &arg, 0); - break; - case WEBKIT_NAVIGATION_TYPE_OTHER: /* fallthrough */ - default: - break; - } - - webkit_policy_decision_ignore(d); -} - -void -decideresource(WebKitPolicyDecision *d, Client *c) -{ - int i, isascii = 1; - WebKitResponsePolicyDecision *r = WEBKIT_RESPONSE_POLICY_DECISION(d); - WebKitURIResponse *res = - webkit_response_policy_decision_get_response(r); - const gchar *uri = webkit_uri_response_get_uri(res); - - if (g_str_has_suffix(uri, "/favicon.ico")) { - webkit_policy_decision_ignore(d); - return; - } - - if (!g_str_has_prefix(uri, "http://") - && !g_str_has_prefix(uri, "https://") - && !g_str_has_prefix(uri, "about:") - && !g_str_has_prefix(uri, "file://") - && !g_str_has_prefix(uri, "data:") - && !g_str_has_prefix(uri, "blob:") - && strlen(uri) > 0) { - for (i = 0; i < strlen(uri); i++) { - if (!g_ascii_isprint(uri[i])) { - isascii = 0; - break; - } - } - if (isascii) { - handleplumb(c, uri); - webkit_policy_decision_ignore(d); - return; - } - } - - if (webkit_response_policy_decision_is_mime_type_supported(r)) { - webkit_policy_decision_use(d); - } else { - webkit_policy_decision_ignore(d); - download(c, res); - } -} - -void -insecurecontent(WebKitWebView *v, WebKitInsecureContentEvent e, Client *c) -{ - c->insecure = 1; -} - -void -downloadstarted(WebKitWebContext *wc, WebKitDownload *d, Client *c) -{ - g_signal_connect(G_OBJECT(d), "notify::response", - G_CALLBACK(responsereceived), c); -} - -void -responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c) -{ - download(c, webkit_download_get_response(d)); - webkit_download_cancel(d); -} - -void -download(Client *c, WebKitURIResponse *r) -{ - Arg a = (Arg)DOWNLOAD(webkit_uri_response_get_uri(r), geturi(c)); - spawn(c, &a); -} - -void -webprocessterminated(WebKitWebView *v, WebKitWebProcessTerminationReason r, - Client *c) -{ - fprintf(stderr, "web process terminated: %s\n", - r == WEBKIT_WEB_PROCESS_CRASHED ? "crashed" : "no memory"); - closeview(v, c); -} - -void -closeview(WebKitWebView *v, Client *c) -{ - gtk_widget_destroy(c->win); -} - -void -destroywin(GtkWidget* w, Client *c) -{ - destroyclient(c); - if (!clients) - gtk_main_quit(); -} - -void -pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) -{ - Arg a = {.v = text }; - if (text) - loaduri((Client *) d, &a); -} - -void -reload(Client *c, const Arg *a) -{ - if (a->i) - webkit_web_view_reload_bypass_cache(c->view); - else - webkit_web_view_reload(c->view); -} - -void -print(Client *c, const Arg *a) -{ - webkit_print_operation_run_dialog(webkit_print_operation_new(c->view), - GTK_WINDOW(c->win)); -} - -void -showcert(Client *c, const Arg *a) -{ - GTlsCertificate *cert = c->failedcert ? c->failedcert : c->cert; - GcrCertificate *gcrt; - GByteArray *crt; - GtkWidget *win; - GcrCertificateWidget *wcert; - - if (!cert) - return; - - g_object_get(cert, "certificate", &crt, NULL); - gcrt = gcr_simple_certificate_new(crt->data, crt->len); - g_byte_array_unref(crt); - - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - wcert = gcr_certificate_widget_new(gcrt); - g_object_unref(gcrt); - - gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(wcert)); - gtk_widget_show_all(win); -} - -void -clipboard(Client *c, const Arg *a) -{ - if (a->i) { /* load clipboard uri */ - gtk_clipboard_request_text(gtk_clipboard_get( - GDK_SELECTION_PRIMARY), - pasteuri, c); - } else { /* copy uri */ - gtk_clipboard_set_text(gtk_clipboard_get( - GDK_SELECTION_PRIMARY), c->targeturi - ? c->targeturi : geturi(c), -1); - } -} - -void -zoom(Client *c, const Arg *a) -{ - if (a->i > 0) - webkit_web_view_set_zoom_level(c->view, - curconfig[ZoomLevel].val.f + 0.1); - else if (a->i < 0) - webkit_web_view_set_zoom_level(c->view, - curconfig[ZoomLevel].val.f - 0.1); - else - webkit_web_view_set_zoom_level(c->view, 1.0); - - curconfig[ZoomLevel].val.f = webkit_web_view_get_zoom_level(c->view); -} - -static void -msgext(Client *c, char type, const Arg *a) -{ - static char msg[MSGBUFSZ]; - int ret; - - if (spair[0] < 0) - return; - - if ((ret = snprintf(msg, sizeof(msg), "%c%c%c", c->pageid, type, a->i)) - >= sizeof(msg)) { - fprintf(stderr, "surf: message too long: %d\n", ret); - return; - } - - if (send(spair[0], msg, ret, 0) != ret) - fprintf(stderr, "surf: error sending: %u%c%d (%d)\n", - c->pageid, type, a->i, ret); -} - -void -scrollv(Client *c, const Arg *a) -{ - msgext(c, 'v', a); -} - -void -scrollh(Client *c, const Arg *a) -{ - msgext(c, 'h', a); -} - -void -navigate(Client *c, const Arg *a) -{ - if (a->i < 0) - webkit_web_view_go_back(c->view); - else if (a->i > 0) - webkit_web_view_go_forward(c->view); -} - -void -stop(Client *c, const Arg *a) -{ - webkit_web_view_stop_loading(c->view); -} - -void -toggle(Client *c, const Arg *a) -{ - curconfig[a->i].val.i ^= 1; - setparameter(c, 1, (ParamName)a->i, &curconfig[a->i].val); -} - -void -togglefullscreen(Client *c, const Arg *a) -{ - /* toggling value is handled in winevent() */ - if (c->fullscreen) - gtk_window_unfullscreen(GTK_WINDOW(c->win)); - else - gtk_window_fullscreen(GTK_WINDOW(c->win)); -} - -void -togglecookiepolicy(Client *c, const Arg *a) -{ - ++cookiepolicy; - cookiepolicy %= strlen(curconfig[CookiePolicies].val.v); - - setparameter(c, 0, CookiePolicies, NULL); -} - -void -toggleinspector(Client *c, const Arg *a) -{ - if (webkit_web_inspector_is_attached(c->inspector)) - webkit_web_inspector_close(c->inspector); - else if (curconfig[Inspector].val.i) - webkit_web_inspector_show(c->inspector); -} - -void -find(Client *c, const Arg *a) -{ - const char *s, *f; - - if (a && a->i) { - if (a->i > 0) - webkit_find_controller_search_next(c->finder); - else - webkit_find_controller_search_previous(c->finder); - } else { - s = getatom(c, AtomFind); - f = webkit_find_controller_get_search_text(c->finder); - - if (g_strcmp0(f, s) == 0) /* reset search */ - webkit_find_controller_search(c->finder, "", findopts, - G_MAXUINT); - - webkit_find_controller_search(c->finder, s, findopts, - G_MAXUINT); - - if (strcmp(s, "") == 0) - webkit_find_controller_search_finish(c->finder); - } -} - -void -clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h) -{ - navigate(c, a); -} - -void -clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h) -{ - Arg arg; - - arg.v = webkit_hit_test_result_get_link_uri(h); - newwindow(c, &arg, a->i); -} - -void -clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h) -{ - Arg arg; - - arg = (Arg)VIDEOPLAY(webkit_hit_test_result_get_media_uri(h)); - spawn(c, &arg); -} - -int -main(int argc, char *argv[]) -{ - Arg arg; - Client *c; - - memset(&arg, 0, sizeof(arg)); - - /* command line args */ - ARGBEGIN { - case 'a': - defconfig[CookiePolicies].val.v = EARGF(usage()); - defconfig[CookiePolicies].prio = 2; - break; - case 'b': - defconfig[ScrollBars].val.i = 0; - defconfig[ScrollBars].prio = 2; - break; - case 'B': - defconfig[ScrollBars].val.i = 1; - defconfig[ScrollBars].prio = 2; - break; - case 'c': - cookiefile = EARGF(usage()); - break; - case 'C': - stylefile = EARGF(usage()); - break; - case 'd': - defconfig[DiskCache].val.i = 0; - defconfig[DiskCache].prio = 2; - break; - case 'D': - defconfig[DiskCache].val.i = 1; - defconfig[DiskCache].prio = 2; - break; - case 'e': - embed = strtol(EARGF(usage()), NULL, 0); - break; - case 'f': - defconfig[RunInFullscreen].val.i = 0; - defconfig[RunInFullscreen].prio = 2; - break; - case 'F': - defconfig[RunInFullscreen].val.i = 1; - defconfig[RunInFullscreen].prio = 2; - break; - case 'g': - defconfig[Geolocation].val.i = 0; - defconfig[Geolocation].prio = 2; - break; - case 'G': - defconfig[Geolocation].val.i = 1; - defconfig[Geolocation].prio = 2; - break; - case 'i': - defconfig[LoadImages].val.i = 0; - defconfig[LoadImages].prio = 2; - break; - case 'I': - defconfig[LoadImages].val.i = 1; - defconfig[LoadImages].prio = 2; - break; - case 'k': - defconfig[KioskMode].val.i = 0; - defconfig[KioskMode].prio = 2; - break; - case 'K': - defconfig[KioskMode].val.i = 1; - defconfig[KioskMode].prio = 2; - break; - case 'm': - defconfig[Style].val.i = 0; - defconfig[Style].prio = 2; - break; - case 'M': - defconfig[Style].val.i = 1; - defconfig[Style].prio = 2; - break; - case 'n': - defconfig[Inspector].val.i = 0; - defconfig[Inspector].prio = 2; - break; - case 'N': - defconfig[Inspector].val.i = 1; - defconfig[Inspector].prio = 2; - break; - case 'r': - scriptfile = EARGF(usage()); - break; - case 's': - defconfig[JavaScript].val.i = 0; - defconfig[JavaScript].prio = 2; - break; - case 'S': - defconfig[JavaScript].val.i = 1; - defconfig[JavaScript].prio = 2; - break; - case 't': - defconfig[StrictTLS].val.i = 0; - defconfig[StrictTLS].prio = 2; - break; - case 'T': - defconfig[StrictTLS].val.i = 1; - defconfig[StrictTLS].prio = 2; - break; - case 'u': - fulluseragent = EARGF(usage()); - break; - case 'v': - die("surf-"VERSION", see LICENSE for © details\n"); - case 'w': - showxid = 1; - break; - case 'x': - defconfig[Certificate].val.i = 0; - defconfig[Certificate].prio = 2; - break; - case 'X': - defconfig[Certificate].val.i = 1; - defconfig[Certificate].prio = 2; - break; - case 'z': - defconfig[ZoomLevel].val.f = strtof(EARGF(usage()), NULL); - defconfig[ZoomLevel].prio = 2; - break; - default: - usage(); - } ARGEND; - if (argc > 0) - arg.v = argv[0]; - else -#ifdef HOMEPAGE - arg.v = HOMEPAGE; -#else - arg.v = "about:blank"; -#endif - - setup(); - c = newclient(NULL); - showview(NULL, c); - - loaduri(c, &arg); - updatetitle(c); - - gtk_main(); - cleanup(); - - return 0; -} diff --git a/surf-2.1/surf.o b/surf-2.1/surf.o deleted file mode 100644 index 9ad2e8c..0000000 Binary files a/surf-2.1/surf.o and /dev/null differ diff --git a/surf-2.1/surf.png b/surf-2.1/surf.png deleted file mode 100644 index f5b2ab1..0000000 Binary files a/surf-2.1/surf.png and /dev/null differ diff --git a/surf-2.1/webext-surf.c b/surf-2.1/webext-surf.c deleted file mode 100644 index d087219..0000000 --- a/surf-2.1/webext-surf.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "common.h" - -#define LENGTH(x) (sizeof(x) / sizeof(x[0])) - -static WebKitWebExtension *webext; -static int sock; - -static void -msgsurf(guint64 pageid, const char *s) -{ - static char msg[MSGBUFSZ]; - size_t sln = strlen(s); - int ret; - - if ((ret = snprintf(msg, sizeof(msg), "%c%s", pageid, s)) - >= sizeof(msg)) { - fprintf(stderr, "webext: msg: message too long: %d\n", ret); - return; - } - - if (send(sock, msg, ret, 0) < 0) - fprintf(stderr, "webext: error sending: %s\n", msg+1); -} - -static gboolean -readsock(GIOChannel *s, GIOCondition c, gpointer unused) -{ - static char js[48], msg[MSGBUFSZ]; - WebKitWebPage *page; - JSCContext *jsc; - GError *gerr = NULL; - gsize msgsz; - - if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) != - G_IO_STATUS_NORMAL) { - if (gerr) { - fprintf(stderr, "webext: error reading socket: %s\n", - gerr->message); - g_error_free(gerr); - } - return TRUE; - } - - if (msgsz < 2) { - fprintf(stderr, "webext: readsock: message too short: %d\n", - msgsz); - return TRUE; - } - - if (!(page = webkit_web_extension_get_page(webext, msg[0]))) - return TRUE; - - jsc = webkit_frame_get_js_context(webkit_web_page_get_main_frame(page)); - - switch (msg[1]) { - case 'h': - if (msgsz != 3) - return TRUE; - snprintf(js, sizeof(js), - "window.scrollBy(window.innerWidth/100*%d,0);", - msg[2]); - jsc_context_evaluate(jsc, js, -1); - break; - case 'v': - if (msgsz != 3) - return TRUE; - snprintf(js, sizeof(js), - "window.scrollBy(0,window.innerHeight/100*%d);", - msg[2]); - jsc_context_evaluate(jsc, js, -1); - break; - } - - return TRUE; -} - -G_MODULE_EXPORT void -webkit_web_extension_initialize_with_user_data(WebKitWebExtension *e, - const GVariant *gv) -{ - GIOChannel *gchansock; - - webext = e; - - g_variant_get(gv, "i", &sock); - - gchansock = g_io_channel_unix_new(sock); - g_io_channel_set_encoding(gchansock, NULL, NULL); - g_io_channel_set_flags(gchansock, g_io_channel_get_flags(gchansock) - | G_IO_FLAG_NONBLOCK, NULL); - g_io_channel_set_close_on_unref(gchansock, TRUE); - g_io_add_watch(gchansock, G_IO_IN, readsock, NULL); -} diff --git a/surf-2.1/webext-surf.o b/surf-2.1/webext-surf.o deleted file mode 100644 index 03680a0..0000000 Binary files a/surf-2.1/webext-surf.o and /dev/null differ diff --git a/surf-2.1/webext-surf.so b/surf-2.1/webext-surf.so deleted file mode 100755 index 5d999c4..0000000 Binary files a/surf-2.1/webext-surf.so and /dev/null differ diff --git a/tabbed-0.6/LICENSE b/tabbed-0.6/LICENSE deleted file mode 100644 index add8a53..0000000 --- a/tabbed-0.6/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -MIT/X Consortium License - -© 2009-2011 Enno Boland -© 2011 Connor Lane Smith -© 2012 Christoph Lohmann <20h@r-36.net> - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/tabbed-0.6/Makefile b/tabbed-0.6/Makefile deleted file mode 100644 index 32cc25b..0000000 --- a/tabbed-0.6/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# tabbed - tabbing interface -# See LICENSE file for copyright and license details. - -include config.mk - -SRC = tabbed.c -OBJ = ${SRC:.c=.o} - -all: options tabbed - -options: - @echo tabbed build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "CC = ${CC}" - -.c.o: - @echo CC $< - @${CC} -c ${CFLAGS} $< - -${OBJ}: config.h config.mk - -config.h: - @echo creating $@ from config.def.h - @cp config.def.h $@ - -tabbed: tabbed.o - @echo CC -o $@ - @${CC} -o $@ tabbed.o ${LDFLAGS} - -clean: - @echo cleaning - @rm -f tabbed ${OBJ} tabbed-${VERSION}.tar.gz - -dist: clean - @echo creating dist tarball - @mkdir -p tabbed-${VERSION} - @cp -R LICENSE Makefile README config.def.h config.mk \ - tabbed.1 arg.h ${SRC} tabbed-${VERSION} - @tar -cf tabbed-${VERSION}.tar tabbed-${VERSION} - @gzip tabbed-${VERSION}.tar - @rm -rf tabbed-${VERSION} - -install: all - @echo installing executable file to ${DESTDIR}${PREFIX}/bin - @mkdir -p ${DESTDIR}${PREFIX}/bin - @cp -f tabbed ${DESTDIR}${PREFIX}/bin - @chmod 755 ${DESTDIR}${PREFIX}/bin/tabbed - @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 - @mkdir -p ${DESTDIR}${MANPREFIX}/man1 - @sed "s/VERSION/${VERSION}/g" < tabbed.1 > ${DESTDIR}${MANPREFIX}/man1/tabbed.1 - @chmod 644 ${DESTDIR}${MANPREFIX}/man1/tabbed.1 - -uninstall: - @echo removing executable file from ${DESTDIR}${PREFIX}/bin - @rm -f ${DESTDIR}${PREFIX}/bin/tabbed - @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 - @rm -f ${DESTDIR}${MANPREFIX}/man1/tabbed.1 - -.PHONY: all options clean dist install uninstall diff --git a/tabbed-0.6/README b/tabbed-0.6/README deleted file mode 100644 index 4ed6bbe..0000000 --- a/tabbed-0.6/README +++ /dev/null @@ -1,22 +0,0 @@ -tabbed - generic tabbed interface -================================= -tabbed is a simple tabbed X window container. - -Requirements ------------- -In order to build tabbed you need the Xlib header files. - -Installation ------------- -Edit config.mk to match your local setup (tabbed is installed into -the /usr/local namespace by default). - -Afterwards enter the following command to build and install tabbed -(if necessary as root): - - make clean install - -Running tabbed --------------- -See the man page for details. - diff --git a/tabbed-0.6/TODO b/tabbed-0.6/TODO deleted file mode 100644 index 8e1986d..0000000 --- a/tabbed-0.6/TODO +++ /dev/null @@ -1,4 +0,0 @@ -# TODO -* add some way to detach windows -* add some way to attach windows - diff --git a/tabbed-0.6/arg.h b/tabbed-0.6/arg.h deleted file mode 100644 index a345b0b..0000000 --- a/tabbed-0.6/arg.h +++ /dev/null @@ -1,52 +0,0 @@ -/* See the LICENSE file for copyright and license details. */ - -#ifndef __ARG_H__ -#define __ARG_H__ - -extern char *argv0; - -#define USED(x) ((void)(x)) - -/* use main(int argc, char *argv[]) */ -#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ - argv[0] && argv[0][1]\ - && argv[0][0] == '-';\ - argc--, argv++) {\ - char _argc;\ - char **_argv;\ - int brk;\ - if (argv[0][1] == '-' && argv[0][2] == '\0') {\ - argv++;\ - argc--;\ - break;\ - }\ - for (brk = 0, argv[0]++, _argv = argv;\ - argv[0][0] && !brk;\ - argv[0]++) {\ - if (_argv != argv)\ - break;\ - _argc = argv[0][0];\ - switch (_argc) - -#define ARGEND }\ - USED(_argc);\ - }\ - USED(argv);\ - USED(argc); - -#define ARGC() _argc - -#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ - ((x), abort(), (char *)0) :\ - (brk = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ - (char *)0 :\ - (brk = 1, (argv[0][1] != '\0')?\ - (&argv[0][1]) :\ - (argc--, argv++, argv[0]))) - -#endif - diff --git a/tabbed-0.6/config.def.h b/tabbed-0.6/config.def.h deleted file mode 100644 index ceda9f7..0000000 --- a/tabbed-0.6/config.def.h +++ /dev/null @@ -1,58 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const char font[] = "-*-*-medium-*-*-*-14-*-*-*-*-*-*-*"; -static const char* normbgcolor = "#222222"; -static const char* normfgcolor = "#cccccc"; -static const char* selbgcolor = "#555555"; -static const char* selfgcolor = "#ffffff"; -static const char before[] = "<"; -static const char after[] = ">"; -static const int tabwidth = 200; -static const Bool foreground = True; - -/* - * Where to place a new tab when it is opened. When npisrelative is True, - * then the current position is changed + newposition. If npisrelative - * is False, then newposition is an absolute position. - */ -static int newposition = 0; -static Bool npisrelative = False; - -#define SETPROP(p) { \ - .v = (char *[]){ "/bin/sh", "-c", \ - "prop=\"`xwininfo -children -id $1 | grep '^ 0x' | sed -e's@^ *\\(0x[0-9a-f]*\\) \"\\([^\"]*\\)\".*@\\1 \\2@' | xargs -0 printf %b | dmenu -l 10`\" &&" \ - "xprop -id $1 -f $0 8s -set $0 \"$prop\"", \ - p, winid, NULL \ - } \ -} - -#define MODKEY ControlMask -static Key keys[] = { \ - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Return, focusonce, { 0 } }, - { MODKEY|ShiftMask, XK_Return, spawn, { 0 } }, - { MODKEY, XK_t, spawn, SETPROP("_TABBED_SELECT_TAB") }, - - { MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } }, - { MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } }, - { MODKEY|ShiftMask, XK_j, movetab, { .i = -1 } }, - { MODKEY|ShiftMask, XK_k, movetab, { .i = +1 } }, - { MODKEY, XK_Tab, rotate, { .i = 0 } }, - - { MODKEY, XK_1, move, { .i = 0 } }, - { MODKEY, XK_2, move, { .i = 1 } }, - { MODKEY, XK_3, move, { .i = 2 } }, - { MODKEY, XK_4, move, { .i = 3 } }, - { MODKEY, XK_5, move, { .i = 4 } }, - { MODKEY, XK_6, move, { .i = 5 } }, - { MODKEY, XK_7, move, { .i = 6 } }, - { MODKEY, XK_8, move, { .i = 7 } }, - { MODKEY, XK_9, move, { .i = 8 } }, - { MODKEY, XK_0, move, { .i = 9 } }, - - { MODKEY, XK_q, killclient, { 0 } }, - - { 0, XK_F11, fullscreen, { 0 } }, -}; - diff --git a/tabbed-0.6/config.h b/tabbed-0.6/config.h deleted file mode 100644 index 2e36e4b..0000000 --- a/tabbed-0.6/config.h +++ /dev/null @@ -1,58 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const char font[] = "Source Code Pro:size=12"; -static const char* normbgcolor = "#222222"; -static const char* normfgcolor = "#cccccc"; -static const char* selbgcolor = "#3f3f3f"; -static const char* selfgcolor = "#ffffff"; -static const char before[] = "<"; -static const char after[] = ">"; -static const int tabwidth = 200; -static const Bool foreground = True; - -/* - * Where to place a new tab when it is opened. When npisrelative is True, - * then the current position is changed + newposition. If npisrelative - * is False, then newposition is an absolute position. - */ -static int newposition = 0; -static Bool npisrelative = False; - -#define SETPROP(p) { \ - .v = (char *[]){ "/bin/sh", "-c", \ - "prop=\"`xwininfo -children -id $1 | grep '^ 0x' | sed -e's@^ *\\(0x[0-9a-f]*\\) \"\\([^\"]*\\)\".*@\\1 \\2@' | xargs -0 printf %b | dmenu -l 10`\" &&" \ - "xprop -id $1 -f $0 8s -set $0 \"$prop\"", \ - p, winid, NULL \ - } \ -} - -#define MODKEY ControlMask -static Key keys[] = { \ - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Return, focusonce, { 0 } }, - { MODKEY|ShiftMask, XK_Return, spawn, { 0 } }, - { MODKEY, XK_t, spawn, SETPROP("_TABBED_SELECT_TAB") }, - - { MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } }, - { MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } }, - { MODKEY|ShiftMask, XK_j, movetab, { .i = -1 } }, - { MODKEY|ShiftMask, XK_k, movetab, { .i = +1 } }, - { MODKEY, XK_Tab, rotate, { .i = 0 } }, - - { MODKEY, XK_1, move, { .i = 0 } }, - { MODKEY, XK_2, move, { .i = 1 } }, - { MODKEY, XK_3, move, { .i = 2 } }, - { MODKEY, XK_4, move, { .i = 3 } }, - { MODKEY, XK_5, move, { .i = 4 } }, - { MODKEY, XK_6, move, { .i = 5 } }, - { MODKEY, XK_7, move, { .i = 6 } }, - { MODKEY, XK_8, move, { .i = 7 } }, - { MODKEY, XK_9, move, { .i = 8 } }, - { MODKEY, XK_0, move, { .i = 9 } }, - - { MODKEY, XK_q, killclient, { 0 } }, - - { 0, XK_F11, fullscreen, { 0 } }, -}; - diff --git a/tabbed-0.6/config.mk b/tabbed-0.6/config.mk deleted file mode 100644 index 5279711..0000000 --- a/tabbed-0.6/config.mk +++ /dev/null @@ -1,25 +0,0 @@ -# tabbed version -VERSION = 0.6 - -# Customize below to fit your system - -# paths -PREFIX = /usr/local -MANPREFIX = ${PREFIX}/share/man - -# includes and libs -INCS = -I. -I/usr/include -LIBS = -L/usr/lib -lc -lX11 - -# flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -CFLAGS = -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} -LDFLAGS = -s ${LIBS} - -# Solaris -#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" -#LDFLAGS = ${LIBS} - -# compiler and linker -CC = cc - diff --git a/tabbed-0.6/config.old b/tabbed-0.6/config.old deleted file mode 100644 index ceda9f7..0000000 --- a/tabbed-0.6/config.old +++ /dev/null @@ -1,58 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const char font[] = "-*-*-medium-*-*-*-14-*-*-*-*-*-*-*"; -static const char* normbgcolor = "#222222"; -static const char* normfgcolor = "#cccccc"; -static const char* selbgcolor = "#555555"; -static const char* selfgcolor = "#ffffff"; -static const char before[] = "<"; -static const char after[] = ">"; -static const int tabwidth = 200; -static const Bool foreground = True; - -/* - * Where to place a new tab when it is opened. When npisrelative is True, - * then the current position is changed + newposition. If npisrelative - * is False, then newposition is an absolute position. - */ -static int newposition = 0; -static Bool npisrelative = False; - -#define SETPROP(p) { \ - .v = (char *[]){ "/bin/sh", "-c", \ - "prop=\"`xwininfo -children -id $1 | grep '^ 0x' | sed -e's@^ *\\(0x[0-9a-f]*\\) \"\\([^\"]*\\)\".*@\\1 \\2@' | xargs -0 printf %b | dmenu -l 10`\" &&" \ - "xprop -id $1 -f $0 8s -set $0 \"$prop\"", \ - p, winid, NULL \ - } \ -} - -#define MODKEY ControlMask -static Key keys[] = { \ - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Return, focusonce, { 0 } }, - { MODKEY|ShiftMask, XK_Return, spawn, { 0 } }, - { MODKEY, XK_t, spawn, SETPROP("_TABBED_SELECT_TAB") }, - - { MODKEY|ShiftMask, XK_l, rotate, { .i = +1 } }, - { MODKEY|ShiftMask, XK_h, rotate, { .i = -1 } }, - { MODKEY|ShiftMask, XK_j, movetab, { .i = -1 } }, - { MODKEY|ShiftMask, XK_k, movetab, { .i = +1 } }, - { MODKEY, XK_Tab, rotate, { .i = 0 } }, - - { MODKEY, XK_1, move, { .i = 0 } }, - { MODKEY, XK_2, move, { .i = 1 } }, - { MODKEY, XK_3, move, { .i = 2 } }, - { MODKEY, XK_4, move, { .i = 3 } }, - { MODKEY, XK_5, move, { .i = 4 } }, - { MODKEY, XK_6, move, { .i = 5 } }, - { MODKEY, XK_7, move, { .i = 6 } }, - { MODKEY, XK_8, move, { .i = 7 } }, - { MODKEY, XK_9, move, { .i = 8 } }, - { MODKEY, XK_0, move, { .i = 9 } }, - - { MODKEY, XK_q, killclient, { 0 } }, - - { 0, XK_F11, fullscreen, { 0 } }, -}; - diff --git a/tabbed-0.6/tabbed b/tabbed-0.6/tabbed deleted file mode 100755 index e7e4e53..0000000 Binary files a/tabbed-0.6/tabbed and /dev/null differ diff --git a/tabbed-0.6/tabbed.1 b/tabbed-0.6/tabbed.1 deleted file mode 100644 index 0ae29ce..0000000 --- a/tabbed-0.6/tabbed.1 +++ /dev/null @@ -1,144 +0,0 @@ -.TH TABBED 1 tabbed\-VERSION -.SH NAME -tabbed \- generic tabbed interface -.SH SYNOPSIS -.B tabbed -.RB [ \-c ] -.RB [ \-d ] -.RB [ \-h ] -.RB [ \-s ] -.RB [ \-v ] -.RB [ \-g -.IR geometry ] -.RB [ \-n -.IR name ] -.RB [ \-p -.IR [ s +/- ] pos ] -.RB [ \-r -.IR narg ] -.IR [ command ... ] -.SH DESCRIPTION -.B tabbed -is a simple tabbed container for applications which support XEmbed. Tabbed -will then run the provided command with the xid of tabbed as appended -argument. (See EXAMPLES.) The automatic spawning of the command can be -disabled by providing the -s parameter. If no command is provided -tabbed will just print its xid and run no command. -.SH OPTIONS -.TP -.B \-c -close tabbed when the last tab is closed. Mutually exclusive with -f. -.TP -.B \-d -detaches tabbed from the terminal and prints its XID to stdout. -.TP -.B \-f -fill up tabbed again by spawning the provided command, when the last tab is -closed. Mutually exclusive with -c. -.TP -.B \-h -will print the usage of tabbed. -.TP -.BI \-g " geometry" -defines the X11 geometry string, which will fixate the height and width of -tabbed. -Them form is [=][{xX}][{+-}{+-}]. See -.BR XParseGeometry (3) -for further details. -.TP -.BI \-n " name" -will set the WM_CLASS attribute to -.I name. -.TP -.BI \-p " [ s +/-] pos" -will set the absolute or relative position of where to start a new tab. When -.I pos -is is given without 's' in front it is an absolute position. Then negative -numbers will be the position from the last tab, where -1 is the last tab. -If 's' is given, then -.I pos -is a relative position to the current selected tab. If this reaches the limits -of the tabs; those limits then apply. -.TP -.BI \-r " narg" -will replace the -.I narg -th argument in -.I command -with the window id, rather than appending it to the end. -.TP -.B \-s -will disable automatic spawning of the command. -.TP -.BI \-t " color" -defines the selected background color. -.IR #RGB , -.IR #RRGGBB , -and X color names are supported. -.TP -.BI \-T " color" -defines the selected foreground color. -.TP -.BI \-u " color" -defines the normal background color. -.TP -.BI \-U " color" -defines the normal foreground color. -.TP -.B \-v -prints version information to stderr, then exits. -.SH USAGE -.TP -.B Ctrl\-Shift\-Return -open new tab -.TP -.B Ctrl\-Shift\-h -previous tab -.TP -.B Ctrl\-Shift\-l -next tab -.TP -.B Ctrl\-Shift\-j -move selected tab one to the left -.TP -.B Ctrl\-Shift\-k -move selected tab one to the right -.TP -.B Ctrl\-Tab -toggle between the selected and last selected tab -.TP -.B Ctrl\-t -open dmenu to either create a new tab appending the entered string or select -an already existing tab. -.TP -.B Ctrl\-q -close tab -.TP -.B Ctrl\-[0..9] -jumps to nth tab -.TP -.B F11 -Toggle fullscreen mode. -.SH EXAMPLES -$ tabbed surf -e -.TP -$ tabbed urxvt -embed -.TP -$ tabbed xterm -into -.TP -$ $(tabbed -d >/tmp/tabbed.xid); urxvt -embed $( -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "arg.h" - -/* XEMBED messages */ -#define XEMBED_EMBEDDED_NOTIFY 0 -#define XEMBED_WINDOW_ACTIVATE 1 -#define XEMBED_WINDOW_DEACTIVATE 2 -#define XEMBED_REQUEST_FOCUS 3 -#define XEMBED_FOCUS_IN 4 -#define XEMBED_FOCUS_OUT 5 -#define XEMBED_FOCUS_NEXT 6 -#define XEMBED_FOCUS_PREV 7 -/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */ -#define XEMBED_MODALITY_ON 10 -#define XEMBED_MODALITY_OFF 11 -#define XEMBED_REGISTER_ACCELERATOR 12 -#define XEMBED_UNREGISTER_ACCELERATOR 13 -#define XEMBED_ACTIVATE_ACCELERATOR 14 - -/* Details for XEMBED_FOCUS_IN: */ -#define XEMBED_FOCUS_CURRENT 0 -#define XEMBED_FOCUS_FIRST 1 -#define XEMBED_FOCUS_LAST 2 - -/* Macros */ -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define LENGTH(x) (sizeof((x)) / sizeof(*(x))) -#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) -#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) - -enum { ColFG, ColBG, ColLast }; /* color */ -enum { WMProtocols, WMDelete, WMName, WMState, WMFullscreen, - XEmbed, WMSelectTab, WMLast }; /* default atoms */ - -typedef union { - int i; - const void *v; -} Arg; - -typedef struct { - unsigned int mod; - KeySym keysym; - void (*func)(const Arg *); - const Arg arg; -} Key; - -typedef struct { - int x, y, w, h; - unsigned long norm[ColLast]; - unsigned long sel[ColLast]; - Drawable drawable; - GC gc; - struct { - int ascent; - int descent; - int height; - XFontSet set; - XFontStruct *xfont; - } font; -} DC; /* draw context */ - -typedef struct Client { - char name[256]; - Window win; - int tabx; - Bool mapped; - Bool closed; -} Client; - -/* function declarations */ -static void buttonpress(const XEvent *e); -static void cleanup(void); -static void clientmessage(const XEvent *e); -static void configurenotify(const XEvent *e); -static void configurerequest(const XEvent *e); -static void createnotify(const XEvent *e); -static void destroynotify(const XEvent *e); -static void die(const char *errstr, ...); -static void drawbar(void); -static void drawtext(const char *text, unsigned long col[ColLast]); -static void *emallocz(size_t size); -static void *erealloc(void *o, size_t size); -static void expose(const XEvent *e); -static void focus(int c); -static void focusin(const XEvent *e); -static void focusonce(const Arg *arg); -static void fullscreen(const Arg *arg); -static char* getatom(int a); -static int getclient(Window w); -static unsigned long getcolor(const char *colstr); -static int getfirsttab(void); -static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); -static void initfont(const char *fontstr); -static Bool isprotodel(int c); -static void keypress(const XEvent *e); -static void killclient(const Arg *arg); -static void manage(Window win); -static void maprequest(const XEvent *e); -static void move(const Arg *arg); -static void movetab(const Arg *arg); -static void propertynotify(const XEvent *e); -static void resize(int c, int w, int h); -static void rotate(const Arg *arg); -static void run(void); -static void sendxembed(int c, long msg, long detail, long d1, long d2); -static void setup(void); -static void setcmd(int argc, char *argv[], int); -static void sigchld(int unused); -static void spawn(const Arg *arg); -static int textnw(const char *text, unsigned int len); -static void unmanage(int c); -static void updatenumlockmask(void); -static void updatetitle(int c); -static int xerror(Display *dpy, XErrorEvent *ee); -static void xsettitle(Window w, const char *str); - -/* variables */ -static int screen; -static void (*handler[LASTEvent]) (const XEvent *) = { - [ButtonPress] = buttonpress, - [ClientMessage] = clientmessage, - [ConfigureNotify] = configurenotify, - [ConfigureRequest] = configurerequest, - [CreateNotify] = createnotify, - [DestroyNotify] = destroynotify, - [Expose] = expose, - [FocusIn] = focusin, - [KeyPress] = keypress, - [MapRequest] = maprequest, - [PropertyNotify] = propertynotify, -}; -static int bh, wx, wy, ww, wh; -static unsigned int numlockmask = 0; -static Bool running = True, nextfocus, doinitspawn = True, - fillagain = False, closelastclient = False; -static Display *dpy; -static DC dc; -static Atom wmatom[WMLast]; -static Window root, win; -static Client **clients = NULL; -static int nclients = 0, sel = -1, lastsel = -1; -static int (*xerrorxlib)(Display *, XErrorEvent *); -static int cmd_append_pos = 0; -static char winid[64]; -static char **cmd = NULL; -static char *wmname = "tabbed"; -static const char *geometry = NULL; - -char *argv0; - -/* configuration, allows nested code to access above variables */ -#include "config.h" - -void -buttonpress(const XEvent *e) { - const XButtonPressedEvent *ev = &e->xbutton; - int i; - int fc; - Arg arg; - - fc = getfirsttab(); - - if((fc > 0 && ev->x < TEXTW(before)) || ev->x < 0) - return; - - if(ev->y < 0 || ev-> y > bh) - return; - - for(i = (fc > 0) ? fc : 0; i < nclients; i++) { - if(clients[i]->tabx > ev->x) { - switch(ev->button) { - case Button1: - focus(i); - break; - case Button2: - focus(i); - killclient(NULL); - break; - case Button4: - case Button5: - arg.i = ev->button == Button4 ? -1 : 1; - rotate(&arg); - break; - } - break; - } - } -} - -void -cleanup(void) { - int i; - - for(i = 0; i < nclients; i++) { - focus(i); - killclient(NULL); - killclient(NULL); - XReparentWindow(dpy, clients[i]->win, root, 0, 0); - unmanage(i); - } - free(clients); - clients = NULL; - - if(dc.font.set) { - XFreeFontSet(dpy, dc.font.set); - } else { - XFreeFont(dpy, dc.font.xfont); - } - - XFreePixmap(dpy, dc.drawable); - XFreeGC(dpy, dc.gc); - XDestroyWindow(dpy, win); - XSync(dpy, False); - free(cmd); -} - -void -clientmessage(const XEvent *e) { - const XClientMessageEvent *ev = &e->xclient; - - if(ev->message_type == wmatom[WMProtocols] - && ev->data.l[0] == wmatom[WMDelete]) { - running = False; - } -} - -void -configurenotify(const XEvent *e) { - const XConfigureEvent *ev = &e->xconfigure; - - if(ev->window == win && (ev->width != ww || ev->height != wh)) { - ww = ev->width; - wh = ev->height; - XFreePixmap(dpy, dc.drawable); - dc.drawable = XCreatePixmap(dpy, root, ww, wh, - DefaultDepth(dpy, screen)); - if(sel > -1) - resize(sel, ww, wh - bh); - XSync(dpy, False); - } -} - -void -configurerequest(const XEvent *e) { - const XConfigureRequestEvent *ev = &e->xconfigurerequest; - XWindowChanges wc; - int c; - - if((c = getclient(ev->window)) > -1) { - wc.x = 0; - wc.y = bh; - wc.width = ww; - wc.height = wh - bh; - wc.border_width = 0; - wc.sibling = ev->above; - wc.stack_mode = ev->detail; - XConfigureWindow(dpy, clients[c]->win, ev->value_mask, &wc); - } -} - -void -createnotify(const XEvent *e) { - const XCreateWindowEvent *ev = &e->xcreatewindow; - - if(ev->window != win && getclient(ev->window) < 0) - manage(ev->window); -} - -void -destroynotify(const XEvent *e) { - const XDestroyWindowEvent *ev = &e->xdestroywindow; - int c; - - if((c = getclient(ev->window)) > -1) - unmanage(c); -} - -void -die(const char *errstr, ...) { - va_list ap; - - va_start(ap, errstr); - vfprintf(stderr, errstr, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - -void -drawbar(void) { - unsigned long *col; - int c, fc, width, n = 0; - char *name = NULL; - - if(nclients == 0) { - dc.x = 0; - dc.w = ww; - XFetchName(dpy, win, &name); - drawtext(name ? name : "", dc.norm); - XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, bh, 0, 0); - XSync(dpy, False); - - return; - } - - width = ww; - clients[nclients-1]->tabx = -1; - fc = getfirsttab(); - if(fc > -1) - n = nclients - fc; - - if((n * tabwidth) > width) { - dc.w = TEXTW(after); - dc.x = width - dc.w; - drawtext(after, dc.sel); - width -= dc.w; - } - dc.x = 0; - - if(fc > 0) { - dc.w = TEXTW(before); - drawtext(before, dc.sel); - dc.x += dc.w; - width -= dc.w; - } - - for(c = (fc > 0)? fc : 0; c < nclients && dc.x < width; c++) { - dc.w = tabwidth; - if(c == sel) { - col = dc.sel; - if((n * tabwidth) > width) { - dc.w += width % tabwidth; - } else { - dc.w = width - (n - 1) * tabwidth; - } - } else { - col = dc.norm; - } - drawtext(clients[c]->name, col); - dc.x += dc.w; - clients[c]->tabx = dc.x; - } - XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, bh, 0, 0); - XSync(dpy, False); -} - -void -drawtext(const char *text, unsigned long col[ColLast]) { - int i, x, y, h, len, olen; - char buf[256]; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - - XSetForeground(dpy, dc.gc, col[ColBG]); - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - if(!text) - return; - - olen = strlen(text); - h = dc.font.ascent + dc.font.descent; - y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; - x = dc.x + (h / 2); - - /* shorten text if necessary */ - for(len = MIN(olen, sizeof(buf)); - len && textnw(text, len) > dc.w - h; len--); - if(!len) - return; - - memcpy(buf, text, len); - if(len < olen) { - for(i = len; i && i > len - 3; buf[--i] = '.'); - } - - XSetForeground(dpy, dc.gc, col[ColFG]); - if(dc.font.set) { - XmbDrawString(dpy, dc.drawable, dc.font.set, - dc.gc, x, y, buf, len); - } else { - XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); - } -} - -void * -emallocz(size_t size) { - void *p; - - if(!(p = calloc(1, size))) - die("tabbed: cannot malloc\n"); - return p; -} - -void * -erealloc(void *o, size_t size) { - void *p; - - if(!(p = realloc(o, size))) - die("tabbed: cannot realloc\n"); - return p; -} - -void -expose(const XEvent *e) { - const XExposeEvent *ev = &e->xexpose; - - if(ev->count == 0 && win == ev->window) - drawbar(); -} - -void -focus(int c) { - char buf[BUFSIZ] = "tabbed-"VERSION" ::"; - size_t i, n; - - /* If c, sel and clients are -1, raise tabbed-win itself */ - if(nclients == 0) { - cmd[cmd_append_pos] = NULL; - for(i = 0, n = strlen(buf); cmd[i] && n < sizeof(buf); i++) - n += snprintf(&buf[n], sizeof(buf) - n, " %s", cmd[i]); - - xsettitle(win, buf); - XRaiseWindow(dpy, win); - - return; - } - - if(c < 0 || c >= nclients) - return; - - resize(c, ww, wh - bh); - XRaiseWindow(dpy, clients[c]->win); - XSetInputFocus(dpy, clients[c]->win, RevertToParent, CurrentTime); - sendxembed(c, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0); - sendxembed(c, XEMBED_WINDOW_ACTIVATE, 0, 0, 0); - xsettitle(win, clients[c]->name); - - /* If sel is already c, change nothing. */ - if(sel != c) { - lastsel = sel; - sel = c; - } - - drawbar(); - XSync(dpy, False); -} - -void -focusin(const XEvent *e) { - const XFocusChangeEvent *ev = &e->xfocus; - int dummy; - Window focused; - - if(ev->mode != NotifyUngrab) { - XGetInputFocus(dpy, &focused, &dummy); - if(focused == win) - focus(sel); - } -} - -void -focusonce(const Arg *arg) { - nextfocus = True; -} - -void -fullscreen(const Arg *arg) { - XEvent e; - - e.type = ClientMessage; - e.xclient.window = win; - e.xclient.message_type = wmatom[WMState]; - e.xclient.format = 32; - e.xclient.data.l[0] = 2; - e.xclient.data.l[1] = wmatom[WMFullscreen]; - e.xclient.data.l[2] = 0; - XSendEvent(dpy, root, False, SubstructureNotifyMask, &e); -} - -char * -getatom(int a) { - static char buf[BUFSIZ]; - Atom adummy; - int idummy; - unsigned long ldummy; - unsigned char *p = NULL; - - XGetWindowProperty(dpy, win, wmatom[a], 0L, BUFSIZ, False, XA_STRING, - &adummy, &idummy, &ldummy, &ldummy, &p); - if(p) { - strncpy(buf, (char *)p, LENGTH(buf)-1); - } else { - buf[0] = '\0'; - } - XFree(p); - - return buf; -} - -int -getclient(Window w) { - int i; - - for(i = 0; i < nclients; i++) { - if(clients[i]->win == w) - return i; - } - - return -1; -} - -unsigned long -getcolor(const char *colstr) { - Colormap cmap = DefaultColormap(dpy, screen); - XColor color; - - if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) - die("tabbed: cannot allocate color '%s'\n", colstr); - - return color.pixel; -} - -int -getfirsttab(void) { - int c, n, fc; - - if(sel < 0) - return -1; - - c = sel; - fc = 0; - n = nclients; - if((n * tabwidth) > ww) { - for(; (c * tabwidth) > (ww / 2) - && (n * tabwidth) > ww; - c--, n--, fc++); - } - - return fc; -} - -Bool -gettextprop(Window w, Atom atom, char *text, unsigned int size) { - char **list = NULL; - int n; - XTextProperty name; - - if(!text || size == 0) - return False; - - text[0] = '\0'; - XGetTextProperty(dpy, w, &name, atom); - if(!name.nitems) - return False; - - if(name.encoding == XA_STRING) { - strncpy(text, (char *)name.value, size - 1); - } else { - if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success - && n > 0 && *list) { - strncpy(text, *list, size - 1); - XFreeStringList(list); - } - } - text[size - 1] = '\0'; - XFree(name.value); - - return True; -} - -void -initfont(const char *fontstr) { - char *def, **missing, **font_names; - int i, n; - XFontStruct **xfonts; - - missing = NULL; - if(dc.font.set) - XFreeFontSet(dpy, dc.font.set); - - dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); - if(missing) { - while(n--) - fprintf(stderr, "tabbed: missing fontset: %s\n", missing[n]); - XFreeStringList(missing); - } - - if(dc.font.set) { - dc.font.ascent = dc.font.descent = 0; - n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); - for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { - dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent); - dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent); - xfonts++; - } - } else { - if(dc.font.xfont) - XFreeFont(dpy, dc.font.xfont); - dc.font.xfont = NULL; - if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) - && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) { - die("tabbed: cannot load font: '%s'\n", fontstr); - } - - dc.font.ascent = dc.font.xfont->ascent; - dc.font.descent = dc.font.xfont->descent; - } - dc.font.height = dc.font.ascent + dc.font.descent; -} - -Bool -isprotodel(int c) { - int i, n; - Atom *protocols; - Bool ret = False; - - if(XGetWMProtocols(dpy, clients[c]->win, &protocols, &n)) { - for(i = 0; !ret && i < n; i++) { - if(protocols[i] == wmatom[WMDelete]) - ret = True; - } - XFree(protocols); - } - - return ret; -} - -void -keypress(const XEvent *e) { - const XKeyEvent *ev = &e->xkey; - unsigned int i; - KeySym keysym; - - keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0); - for(i = 0; i < LENGTH(keys); i++) { - if(keysym == keys[i].keysym - && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) - && keys[i].func) { - keys[i].func(&(keys[i].arg)); - } - } -} - -void -killclient(const Arg *arg) { - XEvent ev; - - if(sel < 0) - return; - - if(isprotodel(sel) && !clients[sel]->closed) { - ev.type = ClientMessage; - ev.xclient.window = clients[sel]->win; - ev.xclient.message_type = wmatom[WMProtocols]; - ev.xclient.format = 32; - ev.xclient.data.l[0] = wmatom[WMDelete]; - ev.xclient.data.l[1] = CurrentTime; - XSendEvent(dpy, clients[sel]->win, False, NoEventMask, &ev); - clients[sel]->closed = True; - } else { - XKillClient(dpy, clients[sel]->win); - } -} - -void -manage(Window w) { - updatenumlockmask(); - { - int i, j, nextpos; - unsigned int modifiers[] = { 0, LockMask, numlockmask, - numlockmask|LockMask }; - KeyCode code; - Client *c; - XEvent e; - - XWithdrawWindow(dpy, w, 0); - XReparentWindow(dpy, w, win, 0, bh); - XSelectInput(dpy, w, PropertyChangeMask - |StructureNotifyMask|EnterWindowMask); - XSync(dpy, False); - - for(i = 0; i < LENGTH(keys); i++) { - if((code = XKeysymToKeycode(dpy, keys[i].keysym))) { - for(j = 0; j < LENGTH(modifiers); j++) { - XGrabKey(dpy, code, keys[i].mod - | modifiers[j], w, - True, GrabModeAsync, - GrabModeAsync); - } - } - } - - c = emallocz(sizeof(*c)); - c->win = w; - - nclients++; - clients = erealloc(clients, sizeof(Client *) * nclients); - - if(npisrelative) { - nextpos = sel + newposition; - } else { - if(newposition < 0) { - nextpos = nclients - newposition; - } else { - nextpos = newposition; - } - } - if(nextpos >= nclients) - nextpos = nclients - 1; - if(nextpos < 0) - nextpos = 0; - - if(nclients > 1 && nextpos < nclients - 1) { - memmove(&clients[nextpos + 1], &clients[nextpos], - sizeof(Client *) * - (nclients - nextpos - 1)); - } - clients[nextpos] = c; - updatetitle(nextpos); - - XLowerWindow(dpy, w); - XMapWindow(dpy, w); - - e.xclient.window = w; - e.xclient.type = ClientMessage; - e.xclient.message_type = wmatom[XEmbed]; - e.xclient.format = 32; - e.xclient.data.l[0] = CurrentTime; - e.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY; - e.xclient.data.l[2] = 0; - e.xclient.data.l[3] = win; - e.xclient.data.l[4] = 0; - XSendEvent(dpy, root, False, NoEventMask, &e); - - XSync(dpy, False); - - /* Adjust sel before focus does set it to lastsel. */ - if(sel >= nextpos) - sel++; - focus((nextfocus)? nextpos : ((sel < 0)? 0 : sel)); - nextfocus = foreground; - } -} - -void -maprequest(const XEvent *e) { - const XMapRequestEvent *ev = &e->xmaprequest; - - if(getclient(ev->window) < 0) - manage(ev->window); -} - -void -move(const Arg *arg) { - if(arg->i >= 0 && arg->i < nclients) - focus(arg->i); -} - -void -movetab(const Arg *arg) { - int c; - Client *new; - - if(sel < 0 || (arg->i == 0)) - return; - - c = sel + arg->i; - while(c >= nclients) - c -= nclients; - while(c < 0) - c += nclients; - - new = clients[c]; - clients[c] = clients[sel]; - clients[sel] = new; - - sel = c; - - drawbar(); -} - -void -propertynotify(const XEvent *e) { - const XPropertyEvent *ev = &e->xproperty; - int c; - char* selection = NULL; - Arg arg; - - if(ev->state == PropertyNewValue && ev->atom == wmatom[WMSelectTab]) { - selection = getatom(WMSelectTab); - if(!strncmp(selection, "0x", 2)) { - arg.i = getclient(strtoul(selection, NULL, 0)); - move(&arg); - } else { - cmd[cmd_append_pos] = selection; - arg.v = cmd; - spawn(&arg); - } - } else if(ev->state != PropertyDelete && ev->atom == XA_WM_NAME - && (c = getclient(ev->window)) > -1) { - updatetitle(c); - } -} - -void -resize(int c, int w, int h) { - XConfigureEvent ce; - XWindowChanges wc; - - ce.x = 0; - ce.y = bh; - ce.width = wc.width = w; - ce.height = wc.height = h; - ce.type = ConfigureNotify; - ce.display = dpy; - ce.event = clients[c]->win; - ce.window = clients[c]->win; - ce.above = None; - ce.override_redirect = False; - ce.border_width = 0; - - XConfigureWindow(dpy, clients[c]->win, CWWidth|CWHeight, &wc); - XSendEvent(dpy, clients[c]->win, False, StructureNotifyMask, - (XEvent *)&ce); -} - -void -rotate(const Arg *arg) { - int nsel = -1; - - if(sel < 0) - return; - - if(arg->i == 0) { - if(lastsel > -1) - focus(lastsel); - } else if(sel > -1) { - /* Rotating in an arg->i step around the clients. */ - nsel = sel + arg->i; - while(nsel >= nclients) - nsel -= nclients; - while(nsel < 0) - nsel += nclients; - focus(nsel); - } -} - -void -run(void) { - XEvent ev; - - /* main event loop */ - XSync(dpy, False); - drawbar(); - if(doinitspawn == True) - spawn(NULL); - - while(running) { - XNextEvent(dpy, &ev); - if(handler[ev.type]) - (handler[ev.type])(&ev); /* call handler */ - } -} - -void -sendxembed(int c, long msg, long detail, long d1, long d2) { - XEvent e = { 0 }; - - e.xclient.window = clients[c]->win; - e.xclient.type = ClientMessage; - e.xclient.message_type = wmatom[XEmbed]; - e.xclient.format = 32; - e.xclient.data.l[0] = CurrentTime; - e.xclient.data.l[1] = msg; - e.xclient.data.l[2] = detail; - e.xclient.data.l[3] = d1; - e.xclient.data.l[4] = d2; - XSendEvent(dpy, clients[c]->win, False, NoEventMask, &e); -} - -void -setcmd(int argc, char *argv[], int replace) { - int i; - - cmd = emallocz((argc+3) * sizeof(*cmd)); - if (argc == 0) - return; - for(i = 0; i < argc; i++) - cmd[i] = argv[i]; - cmd[(replace > 0)? replace : argc] = winid; - cmd_append_pos = argc + !replace; - cmd[cmd_append_pos] = cmd[cmd_append_pos+1] = NULL; -} - -void -setup(void) { - int bitm, tx, ty, tw, th, dh, dw, isfixed; - XClassHint class_hint; - XSizeHints *size_hint; - - /* clean up any zombies immediately */ - sigchld(0); - - /* init screen */ - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); - initfont(font); - bh = dc.h = dc.font.height + 2; - - /* init atoms */ - wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); - wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); - wmatom[XEmbed] = XInternAtom(dpy, "_XEMBED", False); - wmatom[WMName] = XInternAtom(dpy, "_NET_WM_NAME", False); - wmatom[WMState] = XInternAtom(dpy, "_NET_WM_STATE", False); - wmatom[WMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); - wmatom[WMSelectTab] = XInternAtom(dpy, "_TABBED_SELECT_TAB", False); - - /* init appearance */ - wx = 0; - wy = 0; - ww = 800; - wh = 600; - isfixed = 0; - - if(geometry) { - tx = ty = tw = th = 0; - bitm = XParseGeometry(geometry, &tx, &ty, (unsigned *)&tw, - (unsigned *)&th); - if(bitm & XValue) - wx = tx; - if(bitm & YValue) - wy = ty; - if(bitm & WidthValue) - ww = tw; - if(bitm & HeightValue) - wh = th; - if(bitm & XNegative && wx == 0) - wx = -1; - if(bitm & YNegative && wy == 0) - wy = -1; - if(bitm & (HeightValue|WidthValue)) - isfixed = 1; - - dw = DisplayWidth(dpy, screen); - dh = DisplayHeight(dpy, screen); - if(wx < 0) - wx = dw + wx - ww - 1; - if(wy < 0) - wy = dh + wy - wh - 1; - } - - dc.norm[ColBG] = getcolor(normbgcolor); - dc.norm[ColFG] = getcolor(normfgcolor); - dc.sel[ColBG] = getcolor(selbgcolor); - dc.sel[ColFG] = getcolor(selfgcolor); - dc.drawable = XCreatePixmap(dpy, root, ww, wh, - DefaultDepth(dpy, screen)); - dc.gc = XCreateGC(dpy, root, 0, 0); - if(!dc.font.set) - XSetFont(dpy, dc.gc, dc.font.xfont->fid); - - win = XCreateSimpleWindow(dpy, root, wx, wy, ww, wh, 0, - dc.norm[ColFG], dc.norm[ColBG]); - XMapRaised(dpy, win); - XSelectInput(dpy, win, SubstructureNotifyMask|FocusChangeMask| - ButtonPressMask|ExposureMask|KeyPressMask|PropertyChangeMask| - StructureNotifyMask|SubstructureRedirectMask); - xerrorxlib = XSetErrorHandler(xerror); - - class_hint.res_name = wmname; - class_hint.res_class = "tabbed"; - XSetClassHint(dpy, win, &class_hint); - - size_hint = XAllocSizeHints(); - if(!isfixed) { - size_hint->flags = PSize; - size_hint->height = wh; - size_hint->width = ww; - } else { - size_hint->flags = PMaxSize | PMinSize; - size_hint->min_width = size_hint->max_width = ww; - size_hint->min_height = size_hint->max_height = wh; - } - XSetWMProperties(dpy, win, NULL, NULL, NULL, 0, size_hint, NULL, NULL); - XFree(size_hint); - - XSetWMProtocols(dpy, win, &wmatom[WMDelete], 1); - - snprintf(winid, sizeof(winid), "%lu", win); - setenv("XEMBED", winid, 1); - - nextfocus = foreground; - focus(-1); -} - -void -sigchld(int unused) { - if(signal(SIGCHLD, sigchld) == SIG_ERR) - die("tabbed: cannot install SIGCHLD handler"); - - while(0 < waitpid(-1, NULL, WNOHANG)); -} - -void -spawn(const Arg *arg) { - if(fork() == 0) { - if(dpy) - close(ConnectionNumber(dpy)); - - setsid(); - if(arg && arg->v) { - execvp(((char **)arg->v)[0], (char **)arg->v); - fprintf(stderr, "tabbed: execvp %s", - ((char **)arg->v)[0]); - } else { - cmd[cmd_append_pos] = NULL; - execvp(cmd[0], cmd); - fprintf(stderr, "tabbed: execvp %s", cmd[0]); - } - perror(" failed"); - exit(0); - } -} - -int -textnw(const char *text, unsigned int len) { - XRectangle r; - - if(dc.font.set) { - XmbTextExtents(dc.font.set, text, len, NULL, &r); - - return r.width; - } - - return XTextWidth(dc.font.xfont, text, len); -} - -void -unmanage(int c) { - if(c < 0 || c >= nclients) { - drawbar(); - XSync(dpy, False); - return; - } - - if(!nclients) { - return; - } else if(c == 0) { - /* First client. */ - nclients--; - free(clients[0]); - memmove(&clients[0], &clients[1], sizeof(Client *) * nclients); - } else if(c == nclients - 1) { - /* Last client. */ - nclients--; - free(clients[c]); - clients = erealloc(clients, sizeof(Client *) * nclients); - } else { - /* Somewhere inbetween. */ - free(clients[c]); - memmove(&clients[c], &clients[c+1], - sizeof(Client *) * (nclients - (c + 1))); - nclients--; - } - - if(nclients <= 0) { - sel = -1; - lastsel = -1; - - if (closelastclient) { - running = False; - } else if (fillagain && running) { - spawn(NULL); - } - } else { - if(c == lastsel) { - lastsel = -1; - } else if(lastsel > c) { - lastsel--; - } - lastsel = MIN(lastsel, nclients - 1); - - if(c == sel) { - /* Note that focus() will never set lastsel == sel, - * so if here lastsel == sel, it was decreased by above if() clause - * and was actually (sel + 1) before. - */ - if(lastsel > 0) { - focus(lastsel); - } else { - focus(0); - lastsel = 1; - } - } else { - if(sel > c) - sel -= 1; - if(sel >= nclients) - sel = nclients - 1; - - focus(sel); - } - } - - drawbar(); - XSync(dpy, False); -} - -void -updatenumlockmask(void) { - unsigned int i, j; - XModifierKeymap *modmap; - - numlockmask = 0; - modmap = XGetModifierMapping(dpy); - for(i = 0; i < 8; i++) { - for(j = 0; j < modmap->max_keypermod; j++) { - if(modmap->modifiermap[i * modmap->max_keypermod + j] - == XKeysymToKeycode(dpy, - XK_Num_Lock)) { - numlockmask = (1 << i); - } - } - } - XFreeModifiermap(modmap); -} - -void -updatetitle(int c) { - if(!gettextprop(clients[c]->win, wmatom[WMName], - clients[c]->name, sizeof(clients[c]->name))) { - gettextprop(clients[c]->win, XA_WM_NAME, - clients[c]->name, sizeof(clients[c]->name)); - } - if(sel == c) - xsettitle(win, clients[c]->name); - drawbar(); -} - -/* There's no way to check accesses to destroyed windows, thus those cases are - * ignored (especially on UnmapNotify's). Other types of errors call Xlibs - * default error handler, which may call exit. */ -int -xerror(Display *dpy, XErrorEvent *ee) { - if(ee->error_code == BadWindow - || (ee->request_code == X_SetInputFocus - && ee->error_code == BadMatch) - || (ee->request_code == X_PolyText8 - && ee->error_code == BadDrawable) - || (ee->request_code == X_PolyFillRectangle - && ee->error_code == BadDrawable) - || (ee->request_code == X_PolySegment - && ee->error_code == BadDrawable) - || (ee->request_code == X_ConfigureWindow - && ee->error_code == BadMatch) - || (ee->request_code == X_GrabButton - && ee->error_code == BadAccess) - || (ee->request_code == X_GrabKey - && ee->error_code == BadAccess) - || (ee->request_code == X_CopyArea - && ee->error_code == BadDrawable)) { - return 0; - } - - fprintf(stderr, "tabbed: fatal error: request code=%d, error code=%d\n", - ee->request_code, ee->error_code); - return xerrorxlib(dpy, ee); /* may call exit */ -} - -void -xsettitle(Window w, const char *str) { - XTextProperty xtp; - - if(XmbTextListToTextProperty(dpy, (char **)&str, 1, XCompoundTextStyle, - &xtp) == Success) { - XSetTextProperty(dpy, w, &xtp, wmatom[WMName]); - XSetTextProperty(dpy, w, &xtp, XA_WM_NAME); - XFree(xtp.value); - } -} - -char *argv0; - -void -usage(void) { - die("usage: %s [-dfhsv] [-g geometry] [-n name] [-p [s+/-]pos] [-r narg] " - "[-u color] [-U color] [-t color] [-T color] command...\n", argv0); -} - -int -main(int argc, char *argv[]) { - Bool detach = False; - int replace = 0; - char *pstr; - - ARGBEGIN { - case 'c': - closelastclient = True; - fillagain = False; - break; - case 'd': - detach = True; - break; - case 'f': - fillagain = True; - break; - case 'g': - geometry = EARGF(usage()); - break; - case 'n': - wmname = EARGF(usage()); - break; - case 'p': - pstr = EARGF(usage()); - if(pstr[0] == 's') { - npisrelative = True; - newposition = atoi(&pstr[1]); - } else { - newposition = atoi(pstr); - } - break; - case 'r': - replace = atoi(EARGF(usage())); - break; - case 's': - doinitspawn = False; - break; - case 'v': - die("tabbed-"VERSION", © 2009-2012" - " tabbed engineers, see LICENSE" - " for details.\n"); - break; - case 't': - selbgcolor = EARGF(usage()); - break; - case 'T': - selfgcolor = EARGF(usage()); - break; - case 'u': - normbgcolor = EARGF(usage()); - break; - case 'U': - normfgcolor = EARGF(usage()); - break; - default: - case 'h': - usage(); - } ARGEND; - - if(argc < 1) { - doinitspawn = False; - fillagain = False; - } - - setcmd(argc, argv, replace); - - if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) - fprintf(stderr, "tabbed: no locale support\n"); - if(!(dpy = XOpenDisplay(NULL))) - die("tabbed: cannot open display\n"); - - setup(); - printf("0x%lx\n", win); - fflush(NULL); - - if(detach) { - if(fork() == 0) { - fclose(stdout); - } else { - if(dpy) - close(ConnectionNumber(dpy)); - return EXIT_SUCCESS; - } - } - - run(); - cleanup(); - XCloseDisplay(dpy); - - return EXIT_SUCCESS; -} - diff --git a/tabbed-0.6/tabbed.o b/tabbed-0.6/tabbed.o deleted file mode 100644 index 6ef6a71..0000000 Binary files a/tabbed-0.6/tabbed.o and /dev/null differ diff --git a/theme/blue/blue.png b/theme/blue/blue.png new file mode 100644 index 0000000..0920b93 Binary files /dev/null and b/theme/blue/blue.png differ diff --git a/theme/blue/colors.h b/theme/blue/colors.h new file mode 100644 index 0000000..648208b --- /dev/null +++ b/theme/blue/colors.h @@ -0,0 +1,51 @@ +/* Sarc config file */ + +/* + * DWM CONFIGURATION +*/ + +/* primary color */ + +static const char col_cyan[] = "#0a0063"; + +/* secondary colors */ + +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; + +/* st config */ + +float alpha = 0.6; + + +static const char *colorname[] = { + /* 8 normal colors */ + "black", + "red3", + "green3", + "yellow3", + "blue2", + "magenta3", + "cyan3", + "gray90", + + /* 8 bright colors */ + "gray50", + "red", + "green", + "yellow", + "#5c5cff", + "magenta", + "cyan", + "white", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", + "#000000", /* 258 -> bg */ + "#cfcfcf", /* 259 -> fg */ +}; diff --git a/theme/dracula/colors.h b/theme/dracula/colors.h new file mode 100644 index 0000000..f7353de --- /dev/null +++ b/theme/dracula/colors.h @@ -0,0 +1,53 @@ +/* Sarc config file */ + +/* + * DWM CONFIGURATION +*/ + +/* primary color */ + +static const char col_cyan[] = "#6272a4"; + +/* secondary colors */ + +static const char col_gray1[] = "#282a36"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; + +/* st config */ + +float alpha = 0.9; + + +static const char *colorname[] = { + /* 8 normal colors */ + "#000000", + "#ff5555", + "#50fa7b", + "#f1fa8c", + "#bd93f9", + "#ff79c6", + "#8be9fd", + "#bfbfbf", + + /* 8 bright colors */ + "#4d4d4d", + "#ff6e67", + "#5af78e", + "#f4f99d", + "#caa9fa", + "#ff92d0", + "#9aedfe", + "#e6e6e6", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", + "#282a36", /* 258 -> bg */ + "#f8f8f2", /* 259 -> fg */ +}; + + diff --git a/theme/dracula/dracula.png b/theme/dracula/dracula.png new file mode 100644 index 0000000..19bf67e Binary files /dev/null and b/theme/dracula/dracula.png differ diff --git a/theme/green/colors.h b/theme/green/colors.h new file mode 100644 index 0000000..1c182f6 --- /dev/null +++ b/theme/green/colors.h @@ -0,0 +1,50 @@ +/* Sarc config file */ + +/* + * DWM CONFIGURATION +*/ + +/* primary color */ + +static const char col_cyan[] = "#00731f"; + +/* secondary colors */ + +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; + +/* st config */ + +float alpha = 0.6; + +static const char *colorname[] = { + /* 8 normal colors */ + "black", + "red3", + "green3", + "yellow3", + "blue2", + "magenta3", + "cyan3", + "gray90", + + /* 8 bright colors */ + "gray50", + "red", + "green", + "yellow", + "#5c5cff", + "magenta", + "cyan", + "white", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", + "#000000", /* 258 -> bg */ + "#cfcfcf", /* 259 -> fg */ +}; diff --git a/theme/green/green.png b/theme/green/green.png new file mode 100644 index 0000000..111ffe1 Binary files /dev/null and b/theme/green/green.png differ diff --git a/theme/purple/colors.h b/theme/purple/colors.h new file mode 100644 index 0000000..c2e1c75 --- /dev/null +++ b/theme/purple/colors.h @@ -0,0 +1,51 @@ +/* Sarc config file */ + +/* + * DWM CONFIGURATION +*/ + +/* primary color */ + +static const char col_cyan[] = "#8c0180"; + +/* secondary colors */ + +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; + + +/* st config */ + +float alpha = 0.6; + +static const char *colorname[] = { + /* 8 normal colors */ + "black", + "red3", + "green3", + "yellow3", + "blue2", + "magenta3", + "cyan3", + "gray90", + + /* 8 bright colors */ + "gray50", + "red", + "green", + "yellow", + "#5c5cff", + "magenta", + "cyan", + "white", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", + "#000000", /* 258 -> bg */ + "#cfcfcf", /* 259 -> fg */ +}; diff --git a/theme/purple/purple.png b/theme/purple/purple.png new file mode 100644 index 0000000..f0e89e8 Binary files /dev/null and b/theme/purple/purple.png differ diff --git a/theme/purple_mountain/colors.h b/theme/purple_mountain/colors.h new file mode 100644 index 0000000..8026ee1 --- /dev/null +++ b/theme/purple_mountain/colors.h @@ -0,0 +1,40 @@ +/* dwm color configuration */ +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_cyan[] = "#4B4E74"; + +/* st config */ + +float alpha = 0.6; /* some themes may have this lighter or stronger then others */ + +static const char *colorname[] = { + /* 8 normal colors */ + "#050704", /* black */ + "#d80e0e", /* red */ + "#06f115", /* green */ + "#d8ff00", /* yellow */ + "#0050d2", /* blue */ + "#802bee", /* magenta */ + "#23f0f2", /* cyan */ + "#cfcfcf", /* white */ + + /* 8 bright colors */ + "#cfcfcf", /* black */ + "#ff2857", /* red */ + "#79fc6a", /* green */ + "#d7ff62", /* yellow */ + "#698eff", /* blue */ + "#a461fb", /* magenta */ + "#91fff5", /* cyan */ + "#ffffff", /* white */ + + [255] = 0, + + /* special colors */ + "#cccccc", + "#555555", + "#000000", /* background */ + "#cfcfcf", /* foreground */ +}; diff --git a/theme/purple_mountain/purple_mountain.png b/theme/purple_mountain/purple_mountain.png new file mode 100644 index 0000000..21efd79 Binary files /dev/null and b/theme/purple_mountain/purple_mountain.png differ diff --git a/theme/purple_mountain/screenshot.png b/theme/purple_mountain/screenshot.png new file mode 100644 index 0000000..c377fc2 Binary files /dev/null and b/theme/purple_mountain/screenshot.png differ diff --git a/theme/red/colors.h b/theme/red/colors.h new file mode 100644 index 0000000..e46a25c --- /dev/null +++ b/theme/red/colors.h @@ -0,0 +1,50 @@ +/* Sarc config file */ + +/* + * DWM CONFIGURATION +*/ + +/* primary color */ + +static const char col_cyan[] = "#bf0d00"; + +/* secondary colors */ + +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; + +/* st config */ + +float alpha = 0.6; + +static const char *colorname[] = { + /* 8 normal colors */ + "black", + "red3", + "green3", + "yellow3", + "blue2", + "magenta3", + "cyan3", + "gray90", + + /* 8 bright colors */ + "gray50", + "red", + "green", + "yellow", + "#5c5cff", + "magenta", + "cyan", + "white", + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", + "#000000", /* 258 -> bg */ + "#cfcfcf", /* 259 -> fg */ +}; diff --git a/theme/red/red.png b/theme/red/red.png new file mode 100644 index 0000000..4cc72e2 Binary files /dev/null and b/theme/red/red.png differ diff --git a/themes/blend b/themes/blend deleted file mode 100644 index 4dcaffe..0000000 --- a/themes/blend +++ /dev/null @@ -1,39 +0,0 @@ -/* Terminal colors (16 first used in escape sequence) */ - -static const char col_cyan[] = "#672427"; - -static const char col_gray1[] = "#07080c"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; -/* st config */ - -float alpha = 0.6; -static const char *colorname[] = { - - /* 8 normal colors */ - "#07080c", /* black */ - "#672427", /* red */ - "#576d39", /* green */ - "#A6B226", /* yellow */ - "#4c5768", /* blue */ - "#633b71", /* magenta */ - "#4c6862", /* cyan */ - "#d0bbba", /* white */ - - /* 8 bright colors */ - "#D0BBBA", /* black */ - "#cc6666", /* red */ - "#b5bd68", /* green */ - "#f0c674", /* yellow */ - "#81a2be", /* blue */ - "#b294bb", /* magenta */ - "#8abeb7", /* cyan */ - "#d0bbba", /* white */ - [255] = 0, - /* special colors */ - "#000000", - "#c5c8c6", - "#000000", /* background */ - "#c5c8c6", /* foreground */ -}; diff --git a/themes/blue b/themes/blue deleted file mode 100644 index 648208b..0000000 --- a/themes/blue +++ /dev/null @@ -1,51 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#0a0063"; - -/* secondary colors */ - -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - -/* st config */ - -float alpha = 0.6; - - -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "#000000", /* 258 -> bg */ - "#cfcfcf", /* 259 -> fg */ -}; diff --git a/themes/default b/themes/default deleted file mode 100644 index c7f07c9..0000000 --- a/themes/default +++ /dev/null @@ -1,50 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#005577"; */ - -/* Secondary color */ - -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - -/* st config */ - -float alpha = 0.6; - -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "#000000", /* 258 -> bg */ - "#cfcfcf", /* 259 -> fg */ -}; diff --git a/themes/dracula b/themes/dracula deleted file mode 100644 index f7353de..0000000 --- a/themes/dracula +++ /dev/null @@ -1,53 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#6272a4"; - -/* secondary colors */ - -static const char col_gray1[] = "#282a36"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - -/* st config */ - -float alpha = 0.9; - - -static const char *colorname[] = { - /* 8 normal colors */ - "#000000", - "#ff5555", - "#50fa7b", - "#f1fa8c", - "#bd93f9", - "#ff79c6", - "#8be9fd", - "#bfbfbf", - - /* 8 bright colors */ - "#4d4d4d", - "#ff6e67", - "#5af78e", - "#f4f99d", - "#caa9fa", - "#ff92d0", - "#9aedfe", - "#e6e6e6", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "#282a36", /* 258 -> bg */ - "#f8f8f2", /* 259 -> fg */ -}; - - diff --git a/themes/green b/themes/green deleted file mode 100644 index 1c182f6..0000000 --- a/themes/green +++ /dev/null @@ -1,50 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#00731f"; - -/* secondary colors */ - -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - -/* st config */ - -float alpha = 0.6; - -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "#000000", /* 258 -> bg */ - "#cfcfcf", /* 259 -> fg */ -}; diff --git a/themes/liquid_blue b/themes/liquid_blue deleted file mode 100644 index f4f6e47..0000000 --- a/themes/liquid_blue +++ /dev/null @@ -1,44 +0,0 @@ -/* Terminal colors (16 first used in escape sequence) */ - -static const char col_cyan[] = "#015188"; - -static const char col_gray1[] = "#080e0d"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; -/* st config */ - -float alpha = 0.6; - - -static const char *colorname[] = { - - /* 8 normal colors */ - "#050704", /* black */ - "#d80e0e", /* red */ - "#06f115", /* green */ - "#d8ff00", /* yellow */ - "#0050d2", /* blue */ - "#802bee", /* magenta */ - "#23f0f2", /* cyan */ - "#cfcfcf", /* white */ - - /* 8 bright colors */ - "#cfcfcf", /* black */ - "#ff2857", /* red */ - "#79fc6a", /* green */ - "#d7ff62", /* yellow */ - "#698eff", /* blue */ - "#a461fb", /* magenta */ - "#91fff5", /* cyan */ - "#ffffff", /* white */ - - [255] = 0, - - /* special colors */ - "#cccccc", - "#555555", - "#000000", /* background */ - "#cfcfcf", /* foreground */ -}; - diff --git a/themes/nord b/themes/nord deleted file mode 100644 index 92c2f16..0000000 --- a/themes/nord +++ /dev/null @@ -1,54 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#5e81ac"; - -/* secondary colors */ - -static const char col_gray1[] = "#2e3440"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - -/* st config */ - -float alpha = 4; - -static const char *colorname[] = { - - /* 8 normal colors */ - - "#3b4252", /* black */ - "#bf616a", /* red */ - "#a3be8c", /* green */ - "#ebcb8b", /* yellow */ - "#81a1c1", /* blue */ - "#b48ead", /* magenta */ - "#88c0d0", /* cyan */ - "#e5e9f0", /* white */ - - /* 8 bright colors */ - - "#4c566a", /* black */ - "#bf616a", /* red */ - "#a3be8c", /* green */ - "#ebcb8b", /* yellow */ - "#81a1c1", /* blue */ - "#b48ead", /* magenta */ - "#8fbcbb", /* cyan */ - "#eceff4", /* white */ - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - - "#cccccc", - "#555555", - "#2e3440", /* background */ - "#d8dee9", /* foreground */ - }; diff --git a/themes/purple b/themes/purple deleted file mode 100644 index c2e1c75..0000000 --- a/themes/purple +++ /dev/null @@ -1,51 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#8c0180"; - -/* secondary colors */ - -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - - -/* st config */ - -float alpha = 0.6; - -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "#000000", /* 258 -> bg */ - "#cfcfcf", /* 259 -> fg */ -}; diff --git a/themes/red b/themes/red deleted file mode 100644 index e46a25c..0000000 --- a/themes/red +++ /dev/null @@ -1,50 +0,0 @@ -/* Sarc config file */ - -/* - * DWM CONFIGURATION -*/ - -/* primary color */ - -static const char col_cyan[] = "#bf0d00"; - -/* secondary colors */ - -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; - -/* st config */ - -float alpha = 0.6; - -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "#000000", /* 258 -> bg */ - "#cfcfcf", /* 259 -> fg */ -}; diff --git a/tools/sarc-1.0.2.tar.xz b/tools/sarc-1.0.2.tar.xz deleted file mode 100644 index 2a23ce0..0000000 Binary files a/tools/sarc-1.0.2.tar.xz and /dev/null differ -- cgit v1.2.3