More minimal than "startx"
Branch: master
Clone or download
Latest commit 3b0282f Feb 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.bash_profile add .bash_profile Feb 4, 2019
.bashrc
.xinitrc add shebang Feb 4, 2019
.xserverrc add the main files Feb 4, 2019
LICENSE Initial commit Feb 4, 2019
README.org fix words Feb 13, 2019

README.org

How to use sx()

On linux, by default “startx” is 235 lines of code and sucks.

TIP: What follows below also works great with rootless Xorg setups! (See https://wiki.archlinux.org/index.php/xorg#Rootless_Xorg and https://wiki.gentoo.org/wiki/Non_root_Xorg)

To use sx(), simply place in ~/.bashrc (or equivalent),

.bashrc

sx() { ALT_WM=$1 xinit -- :"$XDG_VTNR" > ~/.xorg-redirected-output 2>&1; }

.xserverrc

For added security, place in ~/.xserverrc,

#!/bin/sh
exec /usr/bin/Xorg -nolisten tcp -nolisten local "$@" vt$XDG_VTNR

The perfect .xinitrc file

If your window manager is Emacs, like mine is, place in .xinitrc,

#!/bin/sh
if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

exec dbus-run-session "${ALT_WM:-emacs}"

Not minimal enough? Assuming pulseaudio and systemd, try this instead:

#!/bin/sh
systemctl --user import-environment DISPLAY XAUTHORITY
dbus-update-activation-environment DISPLAY XAUTHORITY
start-pulseaudio-x11

exec dbus-run-session "${ALT_WM:-emacs}"

instead of “startx”, do this now:

$ source ~/.bashrc

$ sx # launches the window manager that is declared in .xinitrc

$ sx foo # launches "foo" as a window manager

extra - autostart X

Append to .bash_profile,

[[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]] && sx

extra - a power management daemon

Check out https://github.com/a-schaefers/simple-power-manager

extra - adjust laptop touchpad settings

In .xinitrc, place this will turn on touch tapping and set acceleration speed for touchpads:

touchpad=$(xinput --list | awk '/TouchPad/ {print $7}')
[ -n "$touchpad" ] && xinput --set-prop "${touchpad#id=}" "libinput Accel Speed" 0.50 && \
    xinput --set-prop "${touchpad#id=}" "libinput Tapping Enabled" 1

extra - adjust keyboard repeat rate

In .xinitrc,

xset r rate 250 60

extra - adjust for multi-monitor situations

Here’s an example that I use to turn off my laptop’s internal monitor and use only the external monitor, only when it is connected, of course! In .xinitrc again,

internal="LVDS-1"
external="VGA-1"
if xrandr | grep -q "$external connected" ; then  xrandr --output "$internal" --off --output "$external" --auto ; fi

extra - turn off displays after X seconds of inactivity

add to .xinitrc,

xset +dpms
xset dpms 300

extra - fix the cursor and GTK themes to have that “consistent” look and feel:

Put inside .xinitrc,

xsetroot -cursor_name left_ptr
[ -f ~/.Xresources ] && xrdb ~/.Xresources

Create the .Xresources file with the minimum,

Xcursor.theme: Adwaita

Create the ~/.gtkrc-2.0 file,

gtk-theme-name="Adwaita"
gtk-icon-theme-name="Adwaita"
gtk-font-name="Noto Sans 10"
gtk-cursor-theme-name="Adwaita"
gtk-cursor-theme-size=0
gtk-toolbar-style=GTK_TOOLBAR_TEXT
gtk-toolbar-icon-size=GTK_ICON_SIZE_MENU
gtk-button-images=0
gtk-menu-images=0
gtk-enable-event-sounds=0
gtk-enable-input-feedback-sounds=0
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle="hintslight"
gtk-xft-rgba="rgb"

Create the ~/.config/gtk-3.0/settings.ini file,

[Settings]
gtk-theme-name=Adwaita
gtk-icon-theme-name=Adwaita
gtk-font-name=Noto Sans 10
gtk-cursor-theme-name=Adwaita
gtk-cursor-theme-size=0
gtk-toolbar-style=GTK_TOOLBAR_TEXT
gtk-toolbar-icon-size=GTK_ICON_SIZE_MENU
gtk-button-images=0
gtk-menu-images=0
gtk-enable-event-sounds=0
gtk-enable-input-feedback-sounds=0
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintslight
gtk-xft-rgba=rgb