speedwm-personal/scripts/speedwm-dm
speediegq 776a054830 Rework status functionality, save status bar to file, update various
other scripts by default so that all dependencies are forced. This is so
that people will actually install the dependencies. They are still not
100% forced as you can remove the line from Makefile.
2022-10-01 17:29:31 +02:00

139 lines
3.6 KiB
Bash
Executable file

#!/bin/sh
# speedwm-dm
# Create a .desktop file for people who use display managers.
# Delete the topbar file
rm -f /usr/share/speedwm/topbar
# Delete the padding file
rm -f /usr/share/speedwm/nopadding
# Make the directory for the .desktop file if it does not exist
mkdir -p /usr/share/xsessions
# Write the .desktop entry
printf "[Desktop Entry]\nEncoding=UTF-8\nName=speedwm\nComment=speedwm: speedie's window manager\nExec=/usr/bin/speedwm_run\nIcon=speedwm\nType=XSession" > /usr/share/xsessions/speedwm.desktop
# If the bar is on the top, touch /usr/share/speedwm/topbar
TOPBAR=$(grep "barposition" options.h | grep "1" | awk '{ print $5 }')
# If we have no padding, touch /usr/share/speedwm/nopadding
PADDING=$(grep "barpaddingv" options.h | grep "0" | awk '{ print $5 }')
# Write the compositor to /usr/share/speedwm/compositor
COMPOSITOR=$(grep "define COMPOSITOR " options.h | awk '{ print $3 }' | sed 's/"//g')
# Status
STATUS=$(grep "char status" options.h | awk '{ print $5 }' | sed 's/"//g; s/;//g')
# Print all of it
echo $TOPBAR | grep -q "1" && touch /usr/share/speedwm/topbar
echo $PADDING | grep -q "0" && touch /usr/share/speedwm/nopadding
echo $COMPOSITOR > /usr/share/speedwm/compositor
echo $STATUS > /usr/share/speedwm/statusbar
echo $(pwd) > /usr/share/speedwm/sourcedir
sed "s/#define //g" toggle.h | grep LAYOUT | sed "s|/[*]|#|g; s|[*]/||g; s/ //g; s/1/=1/g; s/0/=0/g; s/#/ # /g" > /usr/share/speedwm/layouts
. /usr/share/speedwm/layouts
AVAILABLE_LAYOUTS="$(printf "${AVAILABLE_LAYOUTS}Floating")"
# Tile
if [ "$LAYOUT_TILE" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tiling"
fi
# Tile (5:4)
if [ "$LAYOUT_TILE54" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tiling 5:4"
fi
# Monocle
if [ "$LAYOUT_MONOCLE" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Monocle"
fi
# Grid
if [ "$LAYOUT_GRID" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Grid"
fi
# Dwindle
if [ "$LAYOUT_DWINDLE" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Dwindle"
fi
# Spiral
if [ "$LAYOUT_SPIRAL" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Spiral"
fi
# Three Columns
if [ "$LAYOUT_TCL" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Three Columns"
fi
# Bottom Stack
if [ "$LAYOUT_BSTACK" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Bottom Stack"
fi
# Horizontal Bottom Stack
if [ "$LAYOUT_BSTACKH" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Horizontal Bottom Stack"
fi
# Horizontal Grid
if [ "$LAYOUT_HGRID" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Horizontal Grid"
fi
# Dynamic Grid
if [ "$LAYOUT_DGRID" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Dynamic Grid"
fi
# Tatami
if [ "$LAYOUT_TATAMI" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tatami"
fi
# Tilewide
if [ "$LAYOUT_TW" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Tilewide"
fi
# Centered Master
if [ "$LAYOUT_CM" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Centered Master"
fi
# Centered Floating Master
if [ "$LAYOUT_CFM" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Centered Floating Master"
fi
# Deck
if [ "$LAYOUT_DECK" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Deck"
fi
# Columns
if [ "$LAYOUT_COL" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Columns"
fi
# Stairs
if [ "$LAYOUT_STAIRS" = "1" ]; then
AVAILABLE_LAYOUTS="${AVAILABLE_LAYOUTS} Stairs"
fi
AVAILABLE_LAYOUTS="$(printf "$AVAILABLE_LAYOUTS" | sed "s/ /, /g")"
printf "Available layouts: $AVAILABLE_LAYOUTS\n"
# Copy .Xresources file
cp docs/example.Xresources /usr/share/speedwm/example.Xresources
exit 0