Skip to content

Instantly share code, notes, and snippets.

@davidrios
Last active October 21, 2023 16:58
Show Gist options
  • Save davidrios/535c43cbaafe6be665b7c6bd345ea6f4 to your computer and use it in GitHub Desktop.
Save davidrios/535c43cbaafe6be665b7c6bd345ea6f4 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
if [ $(id -u) -eq 0 ]; then
echo 'Please execute this script as a regular user.'
exit 1
fi
which sudo >/dev/null
if [ $? -ne 0 ]; then
echo 'An installation with sudo is required.'
exit 1
fi
function reconfig_meson() {
if [ -d build ]; then
sudo rm -r build/meson-logs
meson build --wipe
else
meson build
fi
}
echo 'Enabling contrib and non-free repositories'
sudo sed -i -e 's/main$/main contrib non-free/g' /etc/apt/sources.list
sudo apt update
mkdir -p ~/sway-src
echo 'Installing wlroots...'
sudo apt install -y build-essential cmake meson libwayland-dev wayland-protocols \
libegl1-mesa-dev libgles2-mesa-dev libdrm-dev libgbm-dev libinput-dev \
libxkbcommon-dev libudev-dev libpixman-1-dev libsystemd-dev libcap-dev \
libxcb1-dev libxcb-composite0-dev libxcb-xfixes0-dev libxcb-xinput-dev \
libxcb-image0-dev libxcb-render-util0-dev libx11-xcb-dev libxcb-icccm4-dev \
freerdp2-dev libwinpr2-dev libpng-dev libavutil-dev libavcodec-dev \
libavformat-dev universal-ctags git
cd ~/sway-src
[ ! -d wlroots ] && git clone https://github.com/swaywm/wlroots.git
cd wlroots
git fetch
git checkout 0.7.0
reconfig_meson
ninja -C build
sudo ninja -C build install
sudo ldconfig
echo 'Installing json-c...'
sudo apt install -y autoconf libtool
cd ~/sway-src
[ ! -d json-c ] && git clone https://github.com/json-c/json-c.git
cd json-c
git fetch
git checkout json-c-0.13.1-20180305
sh autogen.sh
./configure --enable-threading --prefix=/usr/local
CPUCOUNT=$(grep processor /proc/cpuinfo | wc -l)
make -j$CPUCOUNT
sudo make install
sudo ldconfig
echo 'Installing scdoc'
cd ~/sway-src
[ ! -d scdoc ] && git clone https://git.sr.ht/~sircmpwn/scdoc
cd scdoc
git fetch
git checkout 1.9.7
make PREFIX=/usr/local -j$CPUCOUNT
sudo make PREFIX=/usr/local install
echo 'Installing sway'
sudo apt install -y libpcre3-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev xwayland
cd ~/sway-src
[ ! -d sway ] && git clone https://github.com/swaywm/sway.git
cd sway
git fetch
git checkout 1.2
reconfig_meson
ninja -C build
sudo ninja -C build install
echo 'Installing swaybg'
cd ~/sway-src
[ ! -d swaybg ] && git clone https://github.com/swaywm/swaybg.git
cd swaybg
git fetch
git checkout 1.0
reconfig_meson
ninja -C build
sudo ninja -C build install
read -p "Do you wish to install kitty, a wayland terminal emulator, and configure it as default for Sway? (Or else you won't be able to do anything after entering Sway) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo apt install -y curl xz-utils libcanberra0 libxcb-xkb1
sudo mkdir -p /opt/kitty
curl -L https://github.com/kovidgoyal/kitty/releases/download/v0.14.4/kitty-0.14.4-x86_64.txz | sudo tar xvJ -C /opt/kitty
sudo ln -sf /opt/kitty/bin/kitty /usr/local/bin
sudo sed -i -e 's/urxvt/kitty/g' /usr/local/etc/sway/config
fi
echo 'All set, now you should be able to just execute "sway" from a tty.'
echo 'The default key combination for opening a terminal in Sway is <WinKey>+<Enter>'
@triwats
Copy link

triwats commented Aug 2, 2019

I can confirm that minus the check for Debian (see lines 9-12) that this works for Ubuntu 19.04. Thanks or the effort!

Copy link

ghost commented Aug 27, 2019

Please update the version:

wlroots 0.7.0
scdoc 1.9.7
sway 1.2
kitty 0.14.3

@davidrios
Copy link
Author

@tristanvvatson 👍 I removed the check for Debian, I guess it's not really necessary.

@beli3ver Updated. I see you updated the wiki, thanks man!

Copy link

ghost commented Sep 10, 2019

Please add in the main packages installation xwayland

Else the urxvt is not working anymore: swaywm/sway#3651 (comment)

Copy link

ghost commented Sep 10, 2019

Maybe you can add this too:

read -p "Do you wish to install mako, a lightweight notification daemon for Wayland? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
	cd ~/sway-src
        git clone https://github.com/emersion/mako
        cd mako
        meson build
        ninja -C build
        sudo ninja -C build install
        echo "##########################################"
        echo
        echo "Please add following line to you sway config:"
        echo
        echo "exec mako --anchor bottom-right"
        echo
        echo "##########################################"
fi

@davidrios
Copy link
Author

davidrios commented Sep 11, 2019

@beli3ver I added xwayland and two more libraries that are necessary for kitty to work.
As for the suggestion to include mako, that is out of the scope of this script, which is to setup a minimal sway installation.

I had a wiki page with instructions for some extras, including mako, but the Sway maitainers removed it. Here is a copy if you are interested: https://gist.github.com/davidrios/c1f053fe4525e2cd36995058493b3cda

Copy link

ghost commented Dec 7, 2019

Update please:

wlroots 0.8.1
kitty 0.15.0

For wlroots you need now:

libelogind-dev
libxcb-util0-dev

Copy link

ghost commented Dec 7, 2019

Dangerous command when there a different repos in that file:

sudo sed -i -e 's/main$/main contrib non-free/g' /etc/apt/sources.list

@yan-foto
Copy link

wouldn't it be safer to use something like apt-add-repository non-free instead of sed replacement?

@jpeeler
Copy link

jpeeler commented May 9, 2020

Not sure how long this script will be maintained, but I appreciated it. I had to add this one line patch on my compile:
swaywm/wlroots@d5e68ef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment