<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=154pinkchairs</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=154pinkchairs"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/154pinkchairs"/>
	<updated>2026-05-02T09:49:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=32095</id>
		<title>Configure a Wireguard interface (wg)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=32095"/>
		<updated>2026-02-27T19:10:54Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: Undo revision 32094 by 154pinkchairs (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC right}}&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/WireGuard WireGuard] multiple platform vpn solution. WireGuard itself is now integrated into the linux kernel since v5.6. Only the userland configuration tools are required.&lt;br /&gt;
&lt;br /&gt;
== Installation  ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward method to configure WireGuard is to use the tool &amp;lt;code&amp;gt;wg-quick&amp;lt;/code&amp;gt; available in the package {{pkg|wireguard-tools-wg-quick}}. &lt;br /&gt;
&lt;br /&gt;
Install the meta package {{pkg|wireguard-tools}} to install the necessary WireGuard packages  and {{pkg|iptables}} as follows: {{Cmd|# apk add wireguard-tools iptables}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
=== Create Server Keys and Interface Config ===&lt;br /&gt;
&lt;br /&gt;
Create a server private and public key: {{Cmd|&amp;lt;nowiki&amp;gt;# wg genkey | tee server.privatekey | wg pubkey &amp;gt; server.publickey&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Remove any permissions on the file for users and groups other than the root user to ensure that only it can access the private key: {{Cmd|&amp;lt;nowiki&amp;gt;# chmod go= server.privatekey&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Then, we create a new config file {{Path|/etc/wireguard/wg0.conf}} using these new keys as follows:{{Cat|/etc/wireguard/wg0.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
[Interface]&lt;br /&gt;
Address = 192.168.2.1/24, fddd::ffff/64&lt;br /&gt;
ListenPort = 45340&lt;br /&gt;
PrivateKey = &amp;lt;server private key value&amp;gt; # the key from the previously generated privatekey file&lt;br /&gt;
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;iptables -A FORWARD -o %i -j ACCEPT; ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;ip6tables -A FORWARD -o %i -j ACCEPT&lt;br /&gt;
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;iptables -D FORWARD -o %i -j ACCEPT; ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;ip6tables -D FORWARD -o %i -j ACCEPT&lt;br /&gt;
 &lt;br /&gt;
[Peer]&lt;br /&gt;
PublicKey = &amp;lt;client public key value&amp;gt; # obtained from client device via wireguard connection setup process&lt;br /&gt;
AllowedIPs = 192.168.2.2/32, fddd::1/128&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The PostUp and PostDown iptable rules forward traffic from the wg0 subnet (192.168.2.1/24) to the lan subnet on interface eth0. Refer to [https://github.com/pirate/wireguard-docs#user-content-config-reference this WireGuard documentation] for information on adding peers to the config file.&lt;br /&gt;
&lt;br /&gt;
Bring up the new {{ic|wg0}} interface:{{Cmd|# wg-quick up wg0}}&lt;br /&gt;
&lt;br /&gt;
To take it down, we can use &amp;lt;code&amp;gt;wg-quick down wg0&amp;lt;/code&amp;gt; which will clean up the interface and remove the iptables rules.&lt;br /&gt;
&lt;br /&gt;
{{Note|If running in a Docker container, you will need to run with &amp;lt;code&amp;gt;--cap-add{{=}}NET_ADMIN&amp;lt;/code&amp;gt; to modify your interfaces.}}&lt;br /&gt;
&lt;br /&gt;
=== Use with network interfaces ===&lt;br /&gt;
&lt;br /&gt;
To enable connecting with Wireguard on boot, open your {{Path|/etc/network/interfaces}} and add this information after your auto other network interfaces as follows:{{Cat|/etc/network/interfaces|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
auto wg0&lt;br /&gt;
iface wg0 inet static&lt;br /&gt;
pre-up wg-quick up /etc/wireguard/wg0.conf&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Service configuration ===&lt;br /&gt;
&lt;br /&gt;
Since Alpine 3.20, {{pkg|wireguard-tools-openrc}} package provides an OpenRC initd service file. &lt;br /&gt;
&lt;br /&gt;
To use this, install the package:{{Cmd|# apk add wireguard-tools-openrc }}&lt;br /&gt;
&lt;br /&gt;
To use the WireGuard OpenRC script with {{ic|wg-quick.wg0}}, create a symbolic link to it with the configuration name as follows:{{Cmd|# ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.wg0}}&lt;br /&gt;
&lt;br /&gt;
Add the {{ic|wg-quick.wg0}} service to the default runlevel:{{Cmd|# rc-update add wg-quick.wg0}}&lt;br /&gt;
To start|stop|restart the [[OpenRC]] service:{{Cmd|# rc-service wg-quick.wg0 start}}&lt;br /&gt;
&lt;br /&gt;
=== Enable IP Forwarding ===&lt;br /&gt;
&lt;br /&gt;
With a NAT destination rule in place on your router, you should be able connect to the wireguard instance and access the host. However, if you intend for peers to be able to access external resources (including the internet), you will need to enable ip forwarding.&lt;br /&gt;
&lt;br /&gt;
Edit the file {{Path|/etc/sysctl.conf}} or a &amp;lt;code&amp;gt;.conf&amp;lt;/code&amp;gt; file under {{Path|/etc/sysctl.d/}} folder add the following line as follows:{{Cat|/etc/sysctl.conf|&lt;br /&gt;
net.ipv4.ip_forward {{=}} 1&lt;br /&gt;
net.ipv6.conf.all.forwarding {{=}} 1&lt;br /&gt;
net.ipv6.conf.default.forwarding {{=}} 1}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add the sysctl service to run at boot:{{Cmd|# rc-update add sysctl}}&lt;br /&gt;
&lt;br /&gt;
Then either reboot or run {{ic|# sysctl -p /etc/sysctl.conf}} to reload the settings. To ensure forwarding is turned on, run {{ic|# sysctl -a | grep ip_forward}} and ensure &amp;lt;Code&amp;gt;net.ipv4.ip_forward&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the file {{Path|/etc/conf.d/iptables}}, Change the setting as follows:{{Cat|/etc/conf.d/iptables|...&lt;br /&gt;
IPFORWARD{{=}}&amp;quot;yes&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
== Running with modloop ==&lt;br /&gt;
&lt;br /&gt;
If you are running [[Diskless Mode]] i.e from a RAM disk, you can&#039;t modify the modloop. &lt;br /&gt;
&lt;br /&gt;
You can get around it by unpacking the modloop, mounting the unpacked modules folder, then installing WireGuard. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 apk add squashfs-tools # install squashfs tools to unpack modloop&lt;br /&gt;
 unsquashfs -d /root/squash /lib/modloop-lts # unpack modloop to root dir&lt;br /&gt;
 umount /.modloop # unmount existing modloop&lt;br /&gt;
 mount /root/squash/ /.modloop/ # mount unpacked modloop&lt;br /&gt;
 apk del wireguard-lts # uninstall previous WireGuard install&lt;br /&gt;
 apk add wireguard-lts&lt;br /&gt;
 apk add wireguard-tools&lt;br /&gt;
&lt;br /&gt;
You can repack the squash filesystem or put this script in the /etc/local.d/ path so it runs at boot-up.&lt;br /&gt;
&lt;br /&gt;
== Preventing leaks ==&lt;br /&gt;
&lt;br /&gt;
When using a private network over Wireguard, it may be desirable to prevent traffic from leaking onto other networks with the same range (e.g.: a Wi-Fi network using the same range).&lt;br /&gt;
&lt;br /&gt;
Suppose we are using the network &amp;lt;code&amp;gt;fd00:feed:c0de::&amp;lt;/code&amp;gt; over Wireguard. To prevent leaks using [[nftables]], use the following &amp;lt;code&amp;gt;/etc/nftables.d/private-network.nft&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/sbin/nft -f&lt;br /&gt;
 &lt;br /&gt;
 table inet filter {&lt;br /&gt;
   chain output {&lt;br /&gt;
     type filter hook output priority 0;&lt;br /&gt;
 &lt;br /&gt;
     # Allow traffic to fd00:feed:c0de::1 only via wg0.&lt;br /&gt;
     ip6 daddr fd00:feed:c0de::1 oifname &amp;quot;wg0&amp;quot; accept&lt;br /&gt;
 &lt;br /&gt;
     # Drop all other attempts to reach fd00:feed:c0de::1.&lt;br /&gt;
     ip6 daddr fd00:feed:c0de::1 drop&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Alternative Integrations into the Network Stack ==&lt;br /&gt;
{{Expand|Contributions welcome.  Thank you!}}&lt;br /&gt;
&lt;br /&gt;
=== ConnMan Wireguard ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|connman-wireguard}}&#039;&#039;&#039;: An integration plugin enabling ConnMan management of WireGuard interfaces.&lt;br /&gt;
&lt;br /&gt;
=== ifupdown-ng-wireguard ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|ifupdown-ng-wireguard}}&#039;&#039;&#039;: Supplies a declarative WireGuard interface for &#039;&#039;&#039;ifupdown-ng&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== wireguard-go ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|wireguard-go}}&#039;&#039;&#039;: A userspace implementation of WireGuard in &#039;&#039;&#039;go&#039;&#039;&#039;, not used by default in Alpine Linux except in containerized or restricted environments where kernel module loading is not possible. It can be used as a fallback on older kernels that do not offer WireGuard support. &lt;br /&gt;
&lt;br /&gt;
== Tools == &lt;br /&gt;
{{Expand|Contributions are encouraged.}}&lt;br /&gt;
&lt;br /&gt;
=== Tailscale and NetBird ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|tailscale}}&#039;&#039;&#039;, &#039;&#039;&#039;{{Pkg|netbird}}&#039;&#039;&#039;: Mesh VPNs built over WireGuard that streamline peer discovery and access control.&lt;br /&gt;
&lt;br /&gt;
=== Rosenpass ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|rosenpass}}&#039;&#039;&#039;: Verified, post-quantum key exchange tool.&lt;br /&gt;
&lt;br /&gt;
=== Innernet ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|innernet}}&#039;&#039;&#039;:  A private network based on WireGuard using centralized key management.  Currently in testing repository as of February 2026:  test by [[Repositories#Using_testing_repository|enabling and tagging the testing repository]] and installing as {{ic|innernet@testing}}.  &lt;br /&gt;
&lt;br /&gt;
=== py3-wgconfig ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|py3-wgconfig}}&#039;&#039;&#039;:  Python library to parse and modify WireGuard config files that preserves comments.  Currently in testing repository as of February 2026:  ensure that the [[Repositories#Using_testing_repository|the testing repo is enabled and tagged]], and install as {{ic|py3-wgconfig@testing}}. &lt;br /&gt;
&lt;br /&gt;
=== WireGuard Bash Completion ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|wireguard-tools-bash-completion}}&#039;&#039;&#039;: Enables tab completion in bash for {{Pkg|wg}} and {{Pkg|wg-quick}}.&lt;br /&gt;
&lt;br /&gt;
== WireGuard Monitoring and Management ==&lt;br /&gt;
{{Expand|Contributions are encouraged.}}&lt;br /&gt;
&lt;br /&gt;
=== Prometheus Wireguard Exporter ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|prometheus-wireguard-exporter}}&#039;&#039;&#039;: To monitor active peers,  traffic.  Rust-based, and must run with root privileges or with {{ic|CAP_NET_ADMIN}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/pirate/wireguard-docs WireGuard documentation]&lt;br /&gt;
* [https://medium.com/nerd-for-tech/wireguard-vpn-monitoring-alerting-e1e1d1eaaa4e Setting up Prometheus WireGuard exporter, Grafana Dashboard, Alerts Manager.]&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=32094</id>
		<title>Configure a Wireguard interface (wg)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Configure_a_Wireguard_interface_(wg)&amp;diff=32094"/>
		<updated>2026-02-27T19:07:44Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Installation */ legacy iptables -&amp;gt; nftables&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC right}}&lt;br /&gt;
&lt;br /&gt;
[https://en.wikipedia.org/wiki/WireGuard WireGuard] multiple platform vpn solution. WireGuard itself is now integrated into the linux kernel since v5.6. Only the userland configuration tools are required.&lt;br /&gt;
&lt;br /&gt;
== Installation  ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward method to configure WireGuard is to use the tool &amp;lt;code&amp;gt;wg-quick&amp;lt;/code&amp;gt; available in the package {{pkg|wireguard-tools-wg-quick}}. &lt;br /&gt;
&lt;br /&gt;
Install the meta package {{pkg|wireguard-tools}} to install the necessary WireGuard packages  and {{pkg|nftables}} as follows: {{Cmd|# apk add wireguard-tools nftables}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
=== Create Server Keys and Interface Config ===&lt;br /&gt;
&lt;br /&gt;
Create a server private and public key: {{Cmd|&amp;lt;nowiki&amp;gt;# wg genkey | tee server.privatekey | wg pubkey &amp;gt; server.publickey&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Remove any permissions on the file for users and groups other than the root user to ensure that only it can access the private key: {{Cmd|&amp;lt;nowiki&amp;gt;# chmod go= server.privatekey&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Then, we create a new config file {{Path|/etc/wireguard/wg0.conf}} using these new keys as follows:{{Cat|/etc/wireguard/wg0.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
[Interface]&lt;br /&gt;
Address = 192.168.2.1/24, fddd::ffff/64&lt;br /&gt;
ListenPort = 45340&lt;br /&gt;
PrivateKey = &amp;lt;server private key value&amp;gt; # the key from the previously generated privatekey file&lt;br /&gt;
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;iptables -A FORWARD -o %i -j ACCEPT; ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;ip6tables -A FORWARD -o %i -j ACCEPT&lt;br /&gt;
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;iptables -D FORWARD -o %i -j ACCEPT; ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;ip6tables -D FORWARD -o %i -j ACCEPT&lt;br /&gt;
 &lt;br /&gt;
[Peer]&lt;br /&gt;
PublicKey = &amp;lt;client public key value&amp;gt; # obtained from client device via wireguard connection setup process&lt;br /&gt;
AllowedIPs = 192.168.2.2/32, fddd::1/128&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The PostUp and PostDown iptable rules forward traffic from the wg0 subnet (192.168.2.1/24) to the lan subnet on interface eth0. Refer to [https://github.com/pirate/wireguard-docs#user-content-config-reference this WireGuard documentation] for information on adding peers to the config file.&lt;br /&gt;
&lt;br /&gt;
Bring up the new {{ic|wg0}} interface:{{Cmd|# wg-quick up wg0}}&lt;br /&gt;
&lt;br /&gt;
To take it down, we can use &amp;lt;code&amp;gt;wg-quick down wg0&amp;lt;/code&amp;gt; which will clean up the interface and remove the iptables rules.&lt;br /&gt;
&lt;br /&gt;
{{Note|If running in a Docker container, you will need to run with &amp;lt;code&amp;gt;--cap-add{{=}}NET_ADMIN&amp;lt;/code&amp;gt; to modify your interfaces.}}&lt;br /&gt;
&lt;br /&gt;
=== Use with network interfaces ===&lt;br /&gt;
&lt;br /&gt;
To enable connecting with Wireguard on boot, open your {{Path|/etc/network/interfaces}} and add this information after your auto other network interfaces as follows:{{Cat|/etc/network/interfaces|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
auto wg0&lt;br /&gt;
iface wg0 inet static&lt;br /&gt;
pre-up wg-quick up /etc/wireguard/wg0.conf&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Service configuration ===&lt;br /&gt;
&lt;br /&gt;
Since Alpine 3.20, {{pkg|wireguard-tools-openrc}} package provides an OpenRC initd service file. &lt;br /&gt;
&lt;br /&gt;
To use this, install the package:{{Cmd|# apk add wireguard-tools-openrc }}&lt;br /&gt;
&lt;br /&gt;
To use the WireGuard OpenRC script with {{ic|wg-quick.wg0}}, create a symbolic link to it with the configuration name as follows:{{Cmd|# ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.wg0}}&lt;br /&gt;
&lt;br /&gt;
Add the {{ic|wg-quick.wg0}} service to the default runlevel:{{Cmd|# rc-update add wg-quick.wg0}}&lt;br /&gt;
To start|stop|restart the [[OpenRC]] service:{{Cmd|# rc-service wg-quick.wg0 start}}&lt;br /&gt;
&lt;br /&gt;
=== Enable IP Forwarding ===&lt;br /&gt;
&lt;br /&gt;
With a NAT destination rule in place on your router, you should be able connect to the wireguard instance and access the host. However, if you intend for peers to be able to access external resources (including the internet), you will need to enable ip forwarding.&lt;br /&gt;
&lt;br /&gt;
Edit the file {{Path|/etc/sysctl.conf}} or a &amp;lt;code&amp;gt;.conf&amp;lt;/code&amp;gt; file under {{Path|/etc/sysctl.d/}} folder add the following line as follows:{{Cat|/etc/sysctl.conf|&lt;br /&gt;
net.ipv4.ip_forward {{=}} 1&lt;br /&gt;
net.ipv6.conf.all.forwarding {{=}} 1&lt;br /&gt;
net.ipv6.conf.default.forwarding {{=}} 1}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add the sysctl service to run at boot:{{Cmd|# rc-update add sysctl}}&lt;br /&gt;
&lt;br /&gt;
Then either reboot or run {{ic|# sysctl -p /etc/sysctl.conf}} to reload the settings. To ensure forwarding is turned on, run {{ic|# sysctl -a | grep ip_forward}} and ensure &amp;lt;Code&amp;gt;net.ipv4.ip_forward&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the file {{Path|/etc/conf.d/iptables}}, Change the setting as follows:{{Cat|/etc/conf.d/iptables|...&lt;br /&gt;
IPFORWARD{{=}}&amp;quot;yes&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
== Running with modloop ==&lt;br /&gt;
&lt;br /&gt;
If you are running [[Diskless Mode]] i.e from a RAM disk, you can&#039;t modify the modloop. &lt;br /&gt;
&lt;br /&gt;
You can get around it by unpacking the modloop, mounting the unpacked modules folder, then installing WireGuard. &lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 apk add squashfs-tools # install squashfs tools to unpack modloop&lt;br /&gt;
 unsquashfs -d /root/squash /lib/modloop-lts # unpack modloop to root dir&lt;br /&gt;
 umount /.modloop # unmount existing modloop&lt;br /&gt;
 mount /root/squash/ /.modloop/ # mount unpacked modloop&lt;br /&gt;
 apk del wireguard-lts # uninstall previous WireGuard install&lt;br /&gt;
 apk add wireguard-lts&lt;br /&gt;
 apk add wireguard-tools&lt;br /&gt;
&lt;br /&gt;
You can repack the squash filesystem or put this script in the /etc/local.d/ path so it runs at boot-up.&lt;br /&gt;
&lt;br /&gt;
== Preventing leaks ==&lt;br /&gt;
&lt;br /&gt;
When using a private network over Wireguard, it may be desirable to prevent traffic from leaking onto other networks with the same range (e.g.: a Wi-Fi network using the same range).&lt;br /&gt;
&lt;br /&gt;
Suppose we are using the network &amp;lt;code&amp;gt;fd00:feed:c0de::&amp;lt;/code&amp;gt; over Wireguard. To prevent leaks using [[nftables]], use the following &amp;lt;code&amp;gt;/etc/nftables.d/private-network.nft&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 #!/usr/sbin/nft -f&lt;br /&gt;
 &lt;br /&gt;
 table inet filter {&lt;br /&gt;
   chain output {&lt;br /&gt;
     type filter hook output priority 0;&lt;br /&gt;
 &lt;br /&gt;
     # Allow traffic to fd00:feed:c0de::1 only via wg0.&lt;br /&gt;
     ip6 daddr fd00:feed:c0de::1 oifname &amp;quot;wg0&amp;quot; accept&lt;br /&gt;
 &lt;br /&gt;
     # Drop all other attempts to reach fd00:feed:c0de::1.&lt;br /&gt;
     ip6 daddr fd00:feed:c0de::1 drop&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Alternative Integrations into the Network Stack ==&lt;br /&gt;
{{Expand|Contributions welcome.  Thank you!}}&lt;br /&gt;
&lt;br /&gt;
=== ConnMan Wireguard ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|connman-wireguard}}&#039;&#039;&#039;: An integration plugin enabling ConnMan management of WireGuard interfaces.&lt;br /&gt;
&lt;br /&gt;
=== ifupdown-ng-wireguard ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|ifupdown-ng-wireguard}}&#039;&#039;&#039;: Supplies a declarative WireGuard interface for &#039;&#039;&#039;ifupdown-ng&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== wireguard-go ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|wireguard-go}}&#039;&#039;&#039;: A userspace implementation of WireGuard in &#039;&#039;&#039;go&#039;&#039;&#039;, not used by default in Alpine Linux except in containerized or restricted environments where kernel module loading is not possible. It can be used as a fallback on older kernels that do not offer WireGuard support. &lt;br /&gt;
&lt;br /&gt;
== Tools == &lt;br /&gt;
{{Expand|Contributions are encouraged.}}&lt;br /&gt;
&lt;br /&gt;
=== Tailscale and NetBird ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|tailscale}}&#039;&#039;&#039;, &#039;&#039;&#039;{{Pkg|netbird}}&#039;&#039;&#039;: Mesh VPNs built over WireGuard that streamline peer discovery and access control.&lt;br /&gt;
&lt;br /&gt;
=== Rosenpass ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|rosenpass}}&#039;&#039;&#039;: Verified, post-quantum key exchange tool.&lt;br /&gt;
&lt;br /&gt;
=== Innernet ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|innernet}}&#039;&#039;&#039;:  A private network based on WireGuard using centralized key management.  Currently in testing repository as of February 2026:  test by [[Repositories#Using_testing_repository|enabling and tagging the testing repository]] and installing as {{ic|innernet@testing}}.  &lt;br /&gt;
&lt;br /&gt;
=== py3-wgconfig ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|py3-wgconfig}}&#039;&#039;&#039;:  Python library to parse and modify WireGuard config files that preserves comments.  Currently in testing repository as of February 2026:  ensure that the [[Repositories#Using_testing_repository|the testing repo is enabled and tagged]], and install as {{ic|py3-wgconfig@testing}}. &lt;br /&gt;
&lt;br /&gt;
=== WireGuard Bash Completion ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|wireguard-tools-bash-completion}}&#039;&#039;&#039;: Enables tab completion in bash for {{Pkg|wg}} and {{Pkg|wg-quick}}.&lt;br /&gt;
&lt;br /&gt;
== WireGuard Monitoring and Management ==&lt;br /&gt;
{{Expand|Contributions are encouraged.}}&lt;br /&gt;
&lt;br /&gt;
=== Prometheus Wireguard Exporter ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;{{Pkg|prometheus-wireguard-exporter}}&#039;&#039;&#039;: To monitor active peers,  traffic.  Rust-based, and must run with root privileges or with {{ic|CAP_NET_ADMIN}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/pirate/wireguard-docs WireGuard documentation]&lt;br /&gt;
* [https://medium.com/nerd-for-tech/wireguard-vpn-monitoring-alerting-e1e1d1eaaa4e Setting up Prometheus WireGuard exporter, Grafana Dashboard, Alerts Manager.]&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32068</id>
		<title>Setting up a laptop</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32068"/>
		<updated>2026-02-18T15:17:04Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Improved method with plausible deniability */ obtaining key file path&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide is about a project to create a &#039;&#039;&#039;secured laptop&#039;&#039;&#039;.  For this project we take in consideration ways to extend battery life.  It covers tools and daemons that are must haves for a laptop setup.&lt;br /&gt;
{{Todo|Instructions given in the page needs testing. Please help test section by section or the entire page. If individual sections have been tested, please update the Talkpage or please move/place this notice in the untested section(s) alone.}}&lt;br /&gt;
&lt;br /&gt;
== Guide features ==&lt;br /&gt;
&lt;br /&gt;
*Deniable full disk encryption&lt;br /&gt;
*Two factor authentication (physical object (USB key), mind) &lt;br /&gt;
*Encrypted swap and hibernation&lt;br /&gt;
*Encrypted home on top of encrypted drive&lt;br /&gt;
*Memory sanitation&lt;br /&gt;
*Dynamic power modes&lt;br /&gt;
*Feature keys support&lt;br /&gt;
&lt;br /&gt;
== Rubberhose Attack ==&lt;br /&gt;
&lt;br /&gt;
Just a reminder that all attacks are subjected to the Rubberhose Attack dilemma, you either give up your encryption keys or be tortured with a rubberhose with the possibly of death.  See [https://en.wikipedia.org/wiki/Rubber-hose_cryptanalysis Wikipedia article].  We try to present [https://en.wikipedia.org/wiki/Deniable_encryption  deniable encryption (Wikipedia)] to avoid a rubberhose attack scenario.  In this article we use the words plausible deniability interchangeably with deniable encryption.  To achieve this we use a facade and require no metadata fingerprints to expose or hint of encrypted or hidden containers or hint as in detect of existence of an encrypted disk.  The keys should be stored using steganography where we dilute the randomness into the facade.  It also requires you not to brag about encryption or mention it because that is an invitation for the attacker to torture the victim.  Deniable encryption requires you not put encrypted as an entry title to your bootloader.  There shouldn&#039;t be an entry for your facade bootloader to the encrypted drive.&lt;br /&gt;
&lt;br /&gt;
== Why full disk? ==&lt;br /&gt;
&lt;br /&gt;
The full disk encryption provides sort of some plausible deniability or a valid alibi that you didn&#039;t encrypt it.  Is the drive just random noise, broken, or is it really encrypted?  The other reason is that it implies that everything is protected.&lt;br /&gt;
&lt;br /&gt;
But there could be problems if not done right.  For example, cryptsetup does leave a plaintext marking or some hints by default that it has been encrypted when using luks/luks2 mode if a detached header with option &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is not presented.[https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/][https://man7.org/linux/man-pages/man8/cryptsetup.8.html]  To gain credibility that we didn&#039;t really do the encryption, you have to wipe the +3 MiB region based on the number of key slots used; or store the headers on an external device.&lt;br /&gt;
&lt;br /&gt;
If you did deniable encryption incorrectly, it is possible to erase and restore the header.  This presents an opportunity to improve obfuscation.  When you pull out the USB key, it should erase the header but store it on the USB key atomically as in completely.  If you plug in the USB key, it will restore back the header.  cryptsetup has luks actions luksHeaderBackup and luksHeaderRestore to do this.&lt;br /&gt;
&lt;br /&gt;
== Starting at the beginning ==&lt;br /&gt;
&lt;br /&gt;
Grab a USB thumb drive with Alpine.  Set it up as usual but don&#039;t let it touch your drive yet.  Then, install all the tools into memory ramdisk but not in the hard drive yet.  The hard drive will be obliterated.&lt;br /&gt;
&lt;br /&gt;
You will then install Alpine using the steps:&lt;br /&gt;
&lt;br /&gt;
First you need WiFi, to get it run do the command below but say no or skip  the hard drive setup stuff:&lt;br /&gt;
&lt;br /&gt;
  setup-alpine&lt;br /&gt;
&lt;br /&gt;
Then, you need to install some tools into RAM temporarly:&lt;br /&gt;
  apk add e2fsprogs grub grub-bios grub-efi mkinitfs nano&lt;br /&gt;
&lt;br /&gt;
== Randomizing the drive with pseudorandom urandom entropy ==&lt;br /&gt;
&lt;br /&gt;
The first part is to erase the drive with random noise but in practical time.  There are many techniques to do this but should be done in one day or two minimum.&lt;br /&gt;
&lt;br /&gt;
You can use shred or dd to accomplish this depending on your needs and the availability of entropy.  Some techniques take longer.  Cryptologist Bruce Schneier recommended 7 times with specified pattern.  See [https://en.wikipedia.org/wiki/Data_erasure Wikipedia Article].  For practical purposes, we just do it random in one pass.  It should be random so that the facade of random noise hides the encrypted data which resembles noise.&lt;br /&gt;
&lt;br /&gt;
To list the drives on the system do &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: make sure you wipe the right specific drive.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To wipe the disk with random entropy do:&lt;br /&gt;
&lt;br /&gt;
  dd if=/dev/urandom of=/dev/sda&lt;br /&gt;
&lt;br /&gt;
== Creating GPG keys ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;As of this time, Alpine&#039;s mkinitfs does only one factor authentication with passphrase.&#039;&#039;&#039; You need to manually edit the initramfs-init.in in mkinitfs to support two factor authentication using cryptsetup.&lt;br /&gt;
&lt;br /&gt;
After you have scrambled the drive, you want to create your GPG keys.  You will use these keys to set the password(s) for your cryptsetup-luks partitions.  These keys should be stored on a USB thumb drive or other memory device but should not be on the USB boot thumb drive or on the encrypted drive.  The key should be a random 128 bit key wrapped in GPG and protected with a password.&lt;br /&gt;
&lt;br /&gt;
If you are using x, you need to do &amp;lt;code&amp;gt;sudo apk add pinentry-gtk&amp;lt;/code&amp;gt; to display password prompt properly for the next step.&lt;br /&gt;
&lt;br /&gt;
To install openssl and gpg do:&lt;br /&gt;
&lt;br /&gt;
  apk add openssl gnupg&lt;br /&gt;
&lt;br /&gt;
Then, to generate a key:&lt;br /&gt;
&lt;br /&gt;
  export GPG_TTY=$(tty) &amp;amp;&amp;amp; openssl rand -base64 512 | gpg --symmetric --cipher-algo aes --armor &amp;gt; /mnt/usb/$(openssl rand -hex 12)&lt;br /&gt;
&lt;br /&gt;
(Make sure your usb is mounted on /mnt/usb first.)&lt;br /&gt;
&lt;br /&gt;
The long file name comes from &amp;lt;code&amp;gt;openssl rand -hex 12&amp;lt;/code&amp;gt; so that we enhance plausible deniability.  The attacker cannot determine the purpose of the key.  Is it used for GitHub? for Email?&lt;br /&gt;
&lt;br /&gt;
The first part will produce 512 random bytes in wrap it in base64.  The random data will be piped to gpg which will wrap it in AES as ciphertext which again gets wrapped in base64 ascii armor.  For every partition including swap in some cases, you should create more gpg keys and store them in your USB thumb drives.  After you have produced your gpg keys, you will then use them as a password for cryptsetup/luks.&lt;br /&gt;
&lt;br /&gt;
You can replace aes above with the ones listed in &amp;lt;code&amp;gt;gpg --version&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There should be a password generated for the swap.  This is to resume for your hibernate.  If you don&#039;t want to hibernate, then password is not required and all you need to do is to create/format the partition each time you boot without a password or with a one time random password.&lt;br /&gt;
&lt;br /&gt;
== Hiding the keys using steganography ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;WARNING:&#039;&#039; This section is considered experimental.  It requires the tool and the dependencies to be placed on another USB separate from the key files, the bootloaders, and encrypted disks.  The tool and dependencies need to be packaged together.  We decentralize these components so that the attacker doesn&#039;t connect the dots easily or immediately jumps to the conclusion for the requirements to decrypt.  Steghide automatically uses 128-bit AES in CBC mode to encrypt data.  This can be change if you don&#039;t like or trust AES with the -e option.  Use &amp;lt;code&amp;gt;steghide encinfo&amp;lt;/code&amp;gt; for other ciphers and modes.&lt;br /&gt;
&lt;br /&gt;
Fortunately, Alpine has a package for steganography called steghide (in the optional edge/testing repository as of February 2026). To install steghide do:&lt;br /&gt;
&lt;br /&gt;
  echo &amp;quot;http://dl-cdn.alpinelinux.org/alpine/edge/testing&amp;quot; &amp;gt;&amp;gt; /etc/apk/repositories&lt;br /&gt;
  apk add steghide&lt;br /&gt;
&lt;br /&gt;
You will place the keyfile in an image file.  The facade image file should be large enough that there is no apparent discernible difference between the original and the modified.  Do not use a small image with a small filesize.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously luks headers could be 3MB large or more and an jpeg image file is not suitable.  Use another format like .au/.wav or another steganography utility that handles mp3s.  The mp3/wav should be fairly large enough to dilute the header.  So, something with long content is suitable.&lt;br /&gt;
&lt;br /&gt;
There are two basic commands to use with steghide embed and extract,&lt;br /&gt;
&lt;br /&gt;
To embed do:&lt;br /&gt;
&lt;br /&gt;
  steghide embed -ef key.gpg -cf image.jpg&lt;br /&gt;
&lt;br /&gt;
To extract do:&lt;br /&gt;
&lt;br /&gt;
  steghide extract -xf key.gpg -sf image.jpg&lt;br /&gt;
&lt;br /&gt;
To get a file list of files to ship out, use:&lt;br /&gt;
&lt;br /&gt;
  apk info -L libgcc libmcrypt libmhash libstdc++ libjpeg-turbo steghide&lt;br /&gt;
&lt;br /&gt;
== Full disk encryption with with cryptsetup-luks volumes ==&lt;br /&gt;
&lt;br /&gt;
=== Partitioning scheme ===&lt;br /&gt;
&lt;br /&gt;
This section presents a conceptual layout.  It should not be a knee-jerk approval to automatically use the partition tool which would compromise your plausible deniability.&lt;br /&gt;
&lt;br /&gt;
For the facade, we use an Ubuntu Live CD (or less skilled distro) to present the impression that we are not sophisticated or tech savvy enough to implement encryption.  Windows is also acceptable even better.  The immutable Live CD and immutable partition ensures that you are not compromised by a third party attacker that implants evidence.&lt;br /&gt;
&lt;br /&gt;
There could be possibly two bootloaders, one for the facade and the other to the encrypted drive stored on an external device.&lt;br /&gt;
&lt;br /&gt;
==== Luks ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you can demonstrate no existence of partitions 2, 3, 4 and no fingerprints/plaintext introduced by cfdisk and cryptsetup-luks.  Use something like TestDisk, fdisk -l, or gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| root&lt;br /&gt;
| /&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Plain dm-crypt ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you are able to present #2 as being unused space or untampered.  To check use something like TestDisk, gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| vgroot&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_1&lt;br /&gt;
| vgroot-root&lt;br /&gt;
| /&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_2&lt;br /&gt;
| vgroot-swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 2_3&lt;br /&gt;
| vgroot-rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Installing cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
To install cryptsetup you need the package below&lt;br /&gt;
&lt;br /&gt;
  apk add cryptsetup&lt;br /&gt;
&lt;br /&gt;
=== Choosing ciphers ===&lt;br /&gt;
&lt;br /&gt;
When you create your luks drives, you need to decide on the type of ciphers and hashing techniques to use.  The ciphers that you want to use are ones are up to you, but it should be one that is hasn&#039;t been cracked yet or has not suffered a lot of cryptanalysis attacks.  The ones that you might want to use is AES which is hardware accelerated in some Intel CPUs that have the AES-NI cpuflag which you can check by &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt;.  Also consider the ciphers that are SIMD optimized such as serpent and twofish that are available in the Linux kernel.  Also consider ciphers that are unpopular but known to be secure such as Blowfish (which Wikipedia claims to be attacked and the author recommended Twofish).[https://en.wikipedia.org/wiki/Cipher_security_summary]  If it is hardware accelerated, it will save battery life and minimize CPU usage.&lt;br /&gt;
&lt;br /&gt;
For some ciphers weakness also see [https://en.wikipedia.org/wiki/Cipher_security_summary Cipher security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
For some hash function weaknesses also see [https://en.wikipedia.org/wiki/Hash_function_security_summary Hash function security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
Generally speaking, the swap partition should use a fast cipher.  You want to lower the latency or delay of the memory subsystem as a consequence of being encrypted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; Please read the [[Setting_up_a_laptop#Important_notes | Important notes]] section for details about the problems with AES encryption.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t trust AES shills and it&#039;s NSA endorsement, you can try another different one.  Another advantage of using a public vetted cipher is that it provides confidence that it works.&lt;br /&gt;
&lt;br /&gt;
Something like KHAZAD wouldn&#039;t work on &amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt;.  KHAZAD itself is insecure.  Wikipedia reported 5 out of 8 rounds been cracked.[https://en.wikipedia.org/wiki/KHAZAD]&lt;br /&gt;
&lt;br /&gt;
For AES-128 7 out of 10, AES-192 8 out of 12, AES-256-bit 9 out 14 rounds have been cracked according to Wikipedia.[https://en.wikipedia.org/wiki/Advanced_Encryption_Standard]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: Do not use sha1 as the hashing algorithm.&#039;&#039;&#039;  It already has been compromised.&lt;br /&gt;
&lt;br /&gt;
=== Getting the available ciphers ===&lt;br /&gt;
&lt;br /&gt;
To check the availability of a cipher or hash function use:&lt;br /&gt;
  find /lib/modules/* -type f -path  &amp;quot;*/crypto/*.ko&amp;quot; -exec basename {} \; | sort&lt;br /&gt;
&lt;br /&gt;
To check if a cipher is loaded and passed its own tests use:&lt;br /&gt;
  cat /proc/crypto&lt;br /&gt;
&lt;br /&gt;
To test some popular ciphers and hashes do:&lt;br /&gt;
&lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
&lt;br /&gt;
The top set is associated with the hashing algorithms.  The bottom set are the ciphers.  Use the commands below but replace the cipher and/or hash algorithm with your preferences.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt; actually doesn&#039;t show all the ciphers like Anubis.  The cipher should also have CBC and/or XTS block cipher mode of operation to encrypt larger block sizes.  AES for example has a block size of 128.  &lt;br /&gt;
&lt;br /&gt;
To test if the unpopular but uncracked cipher works use sometime like:&lt;br /&gt;
  cryptsetup benchmark --cipher anubis&lt;br /&gt;
&lt;br /&gt;
=== General steps for cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
==== Original method with fdisk with no plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
In this method &amp;lt;code&amp;gt;--type luks&amp;lt;/code&amp;gt; is implied which generates metadata.&lt;br /&gt;
&lt;br /&gt;
If you want plausible deniability for luks, you need to pass &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; to all the luks commands, where &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is a unix path like /mnt/usb/d6ae10eda66704c8.  The random name comes from &amp;lt;code&amp;gt;openssl rand -hex 8&amp;lt;/code&amp;gt;.  The header is transferred to the external device (but no mention of the key slot area but ciphertext being transferred) in the man page.  The information in that file should be obfuscated with encryption if there is plaintext or fingerprint in it just in case. Then, it should be decrypted when reused.&lt;br /&gt;
&lt;br /&gt;
You need to install cfdisk if you prefer the interactive ncurses console method:&lt;br /&gt;
&lt;br /&gt;
  apk add cfdisk&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Use cfdisk to create partitions.  Make two partitions--a system partition and a swap partition&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cfdisk&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Create and format the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --cipher aes-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sda1 /mnt/usb/$(ls)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Open the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --key-file /mnt/usb/$(ls) luksOpen /dev/sda1 root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Format the decrypted drive with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Create the mount point&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Mount the root partition&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Create swap&lt;br /&gt;
| cryptsetup -c blowfish -h sha256 -d /dev/urandom --key-file /mnt/usb/59022506d9f4a714 create swap /dev/sda2 &lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Use swap&lt;br /&gt;
| mkswap /dev/mapper/swap &amp;amp;&amp;amp; swapon /dev/mapper/swap&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Improved method with plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
This method requires lvm2.  To install:&lt;br /&gt;
&lt;br /&gt;
  apk add lvm2&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Grab the previously generated key file&#039;s path. It is the one with non-zero size. Store it in a variable, e.g. &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;KEYFILE&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;ls -l /mnt/usb/&amp;lt;/nowiki&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Open the &#039;&#039;plain dm-crypt&#039;&#039; device generating no metadata&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$KEYFILE /dev/sda pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Physical volume create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;pvcreate /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Volume group create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;vgcreate vgroot /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Logical volume create the swap volume with LVM. Remember to replace 4G with your actual RAM size.&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 4G vgroot -n swap&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Logical volume create the root volume with LVM. Also replace 2T with your physical volume size.&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 2T vgroot -n root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Logical volume create the rescue volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 110M vgroot -n rescue&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Format the root volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Format the swap volume and activate it&lt;br /&gt;
| &amp;lt;code&amp;gt;mkswap /dev/mapper/vgroot-swap &amp;amp;&amp;amp; swapon /dev/mapper/vgroot-swap&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Format the rescue volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-rescue&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| Create mount point for root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| Mount the root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/vgroot-root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Configuring OpenRC dmcrypt and setting up fstab ===&lt;br /&gt;
&lt;br /&gt;
You need to tell OpenRC init scripts to decrypt the volumes.  See &amp;lt;code&amp;gt;/etc/conf.d/dmcrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You need to add the service to boot well because it needs to decrypt the root volume before OpenRC starts running commands from it.  So you need to do:&lt;br /&gt;
&lt;br /&gt;
  rc-update add dmcrypt boot&lt;br /&gt;
&lt;br /&gt;
==== dmcrypt ====&lt;br /&gt;
The dmcrypt OpenRC service will attempt to decrypt the drive using information provided in &#039;&#039;/etc/conf.d/dmcrypt&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root may not be necessary since it is already mounted.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda1&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root is likely not required since you already mounted it before OpenRC starts to do its thing.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
  options=&#039;--type plain --cipher aes-cbc-essiv:sha256 --key-size 256&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
  pre_mount=&#039;vgchange -ay vgroot ; lvchange -ay vgroot/swap&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
dm-crypt will just mount the encrypted &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; partition.  What you need to do next is set up fstab located at /etc/fstab.  Examples are shown below.&lt;br /&gt;
&lt;br /&gt;
==== /etc/fstab ====&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;plain dm-crypt&#039;&#039; device with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/root          /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/swap          none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;lvm&#039;&#039; volumes with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/vgroot-root   /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/vgroot-swap   none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How to recover from a bad setup ===&lt;br /&gt;
&lt;br /&gt;
Many times you will not get it right perfectly the first try.  To recover from this situation, you need to reopen the &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; drive and then remount everything back.&lt;br /&gt;
&lt;br /&gt;
To recover from &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
  cryptsetup --key-file /mnt/usb/2a667ec72774b0d5 luksOpen /dev/sda1 root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/root /mnt/root&lt;br /&gt;
&lt;br /&gt;
To recover from the &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
  cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda root&lt;br /&gt;
  vgchange -ay vgroot&lt;br /&gt;
  lvchange -ay vgroot/root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/vgroot-swap /mnt/root&lt;br /&gt;
&lt;br /&gt;
== Next step: Full blown Alpine installation ==&lt;br /&gt;
&lt;br /&gt;
We will setup the /mnt/root encrypted partition:&lt;br /&gt;
  apk add --root=/mnt/root --initdb $(cat /etc/apk/world) --keys-dir /etc/apk/keys --repositories-file /etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, enable edge repositories in both files including community and testing:&lt;br /&gt;
  nano /etc/apk/repositories /mnt/root/etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, copy the necessary files:&lt;br /&gt;
  cp /etc/resolv.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, install the basic utils:&lt;br /&gt;
  apk add --root=/mnt/root dhcpcd chrony networkmanager wireless-tools wpa_supplicant&lt;br /&gt;
  apk add --root=/mnt/root grub mkinitfs e2fsprogs grub-bios grub-efi&lt;br /&gt;
  apk add --root=/mnt/root sudo nano&lt;br /&gt;
  apk add --root=/mnt/root linux-lts&lt;br /&gt;
&lt;br /&gt;
Then, you need to mount your usb on to /boot:&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Edit grub:&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
Then, install grub on the usb:&lt;br /&gt;
  grub-install --force /dev/sdb&lt;br /&gt;
&lt;br /&gt;
Then, prepare chroot:&lt;br /&gt;
  mount --bind /dev /mnt/root/dev&lt;br /&gt;
  mount --bind /sys /mnt/root/sys&lt;br /&gt;
  cp /etc/reslov.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, chroot:&lt;br /&gt;
  chroot /mnt/root /bin/sh&lt;br /&gt;
&lt;br /&gt;
Set the root administrator password:&lt;br /&gt;
  passwd&lt;br /&gt;
&lt;br /&gt;
The root password should be very difficult to deter you from using it and force you to use sudo&lt;br /&gt;
&lt;br /&gt;
Edit sudo so that wheel group has administrative :&lt;br /&gt;
  EDITOR=nano visudo&lt;br /&gt;
&lt;br /&gt;
Set:&lt;br /&gt;
  ## Uncomment to allow members of group wheel to execute any command       &lt;br /&gt;
  %wheel ALL=(ALL) ALL                                                 &lt;br /&gt;
&lt;br /&gt;
Then, add wheel (administrator) user:&lt;br /&gt;
  useradd -m myname&lt;br /&gt;
  usermod -a -G video,audio,wheel myname&lt;br /&gt;
&lt;br /&gt;
log in that user:&lt;br /&gt;
  su myname&lt;br /&gt;
&lt;br /&gt;
Then, update and upgrade it&lt;br /&gt;
  sudo apk update&lt;br /&gt;
  sudo apk upgrade&lt;br /&gt;
&lt;br /&gt;
Then, setup xorg:&lt;br /&gt;
  sudo setup-xorg-base&lt;br /&gt;
  sudo apk search xf86-video | sort&lt;br /&gt;
  # pick your xf86 video driver&lt;br /&gt;
  sudo apk add xf86-video-amdgpu&lt;br /&gt;
  # install the mesa driver&lt;br /&gt;
  sudo apk add mesa-dri-gallium  &lt;br /&gt;
&lt;br /&gt;
Then, keep piling on:&lt;br /&gt;
  sudo apk add firefox dwm xfce4-terminal alsa-utils keepassx xfce4 xchat&lt;br /&gt;
  sudo apk add font-noto-emoji font-terminus leafpad xsetroot # See [[Emojis]] to complete installation&lt;br /&gt;
  sudo apk add xf86-input-libinput # or -evdev if libinput doesn&#039;t work&lt;br /&gt;
&lt;br /&gt;
Then, set the desktop:&lt;br /&gt;
  nano .xinitrc&lt;br /&gt;
&lt;br /&gt;
Put both but comment with a # one of them if you don&#039;t want it,&lt;br /&gt;
  #while true; do xsetroot -name &amp;quot;$( date +&amp;quot;%a %b %d %I:%M:%S %Y&amp;quot; )&amp;quot; ; sleep 1; done &amp;amp;&lt;br /&gt;
  #exec dwm&lt;br /&gt;
  exec xfce4-session&lt;br /&gt;
&lt;br /&gt;
For the above xsetroot statement used to provide information in the statusbar for dwm, consider adding information about the battery level.  This information can be found in sysfs at /sys/class/power_supply/BAT0/.&lt;br /&gt;
&lt;br /&gt;
  sync&lt;br /&gt;
  sudo reboot&lt;br /&gt;
&lt;br /&gt;
== Hacking mkinitfs to support cryptsetup with GPG keys ==&lt;br /&gt;
&lt;br /&gt;
This section describes how to assemble a custom initscript chain in multiple parts.  It could be extended with three-factor authentication which adds biometrics along side with mind and physical object.&lt;br /&gt;
&lt;br /&gt;
Most entry to secure systems are not fully automated or do not allow things to quickly pass through freely and often guarded.  This process may seem like a hassle, but it should dissuade the rubberhosers from jumping to the conclusion of the possibility of the existence of a encrypted drive.&lt;br /&gt;
&lt;br /&gt;
Here is the steps required so that the facade initscripts and dependencies are free from encryption.&lt;br /&gt;
* You will separate and archive cryptsetup, ciphers kernel modules, hash function kernel modules, and any additional obfuscation dependencies, and another continuation initscript discussed below.  You need to make sure that you copy /etc/mkinitfs/mkinitfs.conf to your home directory and strip out those features without those modules.&lt;br /&gt;
* You will hide this archive in a mp3 file with another tool you will package or you can use steghide&#039;s .au/.wav support, but .au seems too conspicuous or strange by current trends.&lt;br /&gt;
&lt;br /&gt;
Here we try to clean up the facade so that it presents itself as free without cryptography.  You need the following changes to your initramfs to avoid a sensitive rubberhoser:&lt;br /&gt;
* You will delete everything in the custom initramfs-init referring to encryption.  This includes cryptroot, cryptdm, crypt-anything, etc init options.&lt;br /&gt;
* You need to delete references in nlplug-findfs to cryptsetup and recompile the mkinitfs package.&lt;br /&gt;
* You could program the init script to boot into a facade partition but drop into sh if a hidden special keypress sequence is met.&lt;br /&gt;
&lt;br /&gt;
You need to create a custom init continuation script:&lt;br /&gt;
* Your initscript should drop into single mode which you will mount the encrypted path manually. &lt;br /&gt;
* You will manually steg-unhide the encrypted archive hidden in the mp3 file and extract it to the ramdisk.&lt;br /&gt;
* You will run the custom init continuation script manually.&lt;br /&gt;
* This custom init continuation will automate the process of extracting the gpg keys from another device and image files into the ramdisk.  This will then automate the mounting of the encrypted drive.  This resume continuation script should handle both cold boot and hibernate.&lt;br /&gt;
* You will finish resuming running the other half of mkinitfs-init or specifically where the points after where it typically will mount cryptsetup and hibernate devices.&lt;br /&gt;
&lt;br /&gt;
If you use a USB keyboard, you will unlock the encrypted devices in early userspace. You will need to either compile the USB keyboard drivers in the kernel or you need to add additional modules when generating the mkinitfs.  You will need the hid, hid-generic, ehci-hcd, uhci-hcd, usbcore driver and add those paths in a customized &amp;lt;code&amp;gt;/etc/mkinitfs/features.d/usb-keyboard.modules&amp;lt;/code&amp;gt;.  It should be separate from usb.modules because apk updates may overwrite it.  Use the &amp;lt;code&amp;gt;lsmod&amp;lt;/code&amp;gt; utility from the kmod package to find what drivers your USB keyboard uses.&lt;br /&gt;
&lt;br /&gt;
You need to generate the final mkinitfs.&lt;br /&gt;
First you need the kernelversion to pass into mkinitfs.  To obtain that information do &amp;lt;code&amp;gt;ls /lib/modules&amp;lt;/code&amp;gt; which will show some folders.  Once you found it pass it to mkinitrafs by doing and replacing kernelversion below:&lt;br /&gt;
&lt;br /&gt;
  sudo mkinitramfs -i $HOMEDIR/initramfs-init -c &amp;quot;$HOMEDIR&amp;quot;/mkinitfs.conf kernelversion&lt;br /&gt;
&lt;br /&gt;
The $HOMEDIR should be replaced with the full path if you are not root.&lt;br /&gt;
&lt;br /&gt;
==  Install the bootloader in the USB thumb drive ==&lt;br /&gt;
&lt;br /&gt;
To install grub, you need to install grub on the ramdisk first on the host.  &lt;br /&gt;
&lt;br /&gt;
  apk add grub&lt;br /&gt;
&lt;br /&gt;
To get a list of partitions&lt;br /&gt;
&lt;br /&gt;
  fdisk -l&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition in /boot&lt;br /&gt;
&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Make changes to grub&#039;s configuration &lt;br /&gt;
&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You need to customize the initramfs in order to use GPG keys since there is no support from it.&#039;&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
The steps here below assumes that these custom initramfs features have been implemented.  &lt;br /&gt;
&lt;br /&gt;
The following boot loader settings is &#039;&#039;&#039;not sufficient&#039;&#039;&#039; for deniable encryption because it exposes the fact that an encrypted drive exists because an attacker can discover that encryption was used through the edit option of the grub menu.  To protect yourself from a rubberhose attack, you really need to customize the initramfs so that references to anything mentioning encryption, ciphers, hashing are not explicitly mentioned.  These configurations should be considered an intermediate form for used in debugging purposes.  In addition, the attacker just can inspect grub.cfg files directly.&lt;br /&gt;
&lt;br /&gt;
The following are just examples to just get it working but should be modified so that it doesn&#039;t hint to the rubberhoser of a hidden partition or encrypted partitions.&lt;br /&gt;
&lt;br /&gt;
The entry should look like:&lt;br /&gt;
&lt;br /&gt;
For &#039;luks&#039;&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda1 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda4 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;plain dm-crypt&#039;:&lt;br /&gt;
&lt;br /&gt;
The stock mkinitfs may not support plain dm-crypt.  It looks like it only supports luks.  Customization of the initramfs is required.&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-root rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-rescue rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=rescue&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The source code of grub could possibly be modified and recompiled to use other non-standard keys.  See [https://github.com/lemenkov/grub2/blob/master/grub-core/commands/keystatus.c].  Ideally, it should be not so obvious or accessible for the attacker.&lt;br /&gt;
&lt;br /&gt;
The above grub.cfg is applied to the USB bootloader.  For the facade bootloader, you just want the Windows 10 or Ubuntu entry, nothing more.&lt;br /&gt;
&lt;br /&gt;
For the modules parameter, you need to add your crypto modules.&lt;br /&gt;
Use &amp;lt;code&amp;gt;find /lib/modules/ -name &amp;quot;*aes*&amp;quot;&amp;lt;/code&amp;gt; where aes is the basename for your cipher or hash algorithm&lt;br /&gt;
Use &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt; to obtain the UUID of your device&lt;br /&gt;
&lt;br /&gt;
Install it to your USB thumb drive&lt;br /&gt;
&lt;br /&gt;
  grub-install /dev/sdb&lt;br /&gt;
&lt;br /&gt;
== Home mounting with eCryptfs ==&lt;br /&gt;
&lt;br /&gt;
We use eCryptfs to encrypt home.  The rationale for having another encrypted file system is that if you leave your laptop unattended on break or accidentally leave your USB key in, your data will not be accessible.  The other rationale is that if another person wants to use your computer, you can just log off and the data will be kept hidden and encrypted.  When you log off due to inactivity, your home directory will be unmounted and encrypted.  eCryptfs will encrypt/decrypt the filename and the contents and will sit on top of ext4 which sits on top of luks.&lt;br /&gt;
&lt;br /&gt;
To install ecryptfs-utils:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add ecryptfs-utils&lt;br /&gt;
&lt;br /&gt;
This does one factor authentication mostly with just the password, but it should be modified to use the USB key too.  You need to reconfigure pam with the pam_usb.so which is not in Alpine aports.&lt;br /&gt;
&lt;br /&gt;
You need to use the pam_ecryptfs PAM module.&lt;br /&gt;
&lt;br /&gt;
== Locking it down ==&lt;br /&gt;
&lt;br /&gt;
Many times you will leave your laptop behind with people you trust.  The following tools will help lock down the system.&lt;br /&gt;
&lt;br /&gt;
=== physlock ===&lt;br /&gt;
&lt;br /&gt;
This will auto lock the tty and when you return will prompt for password.&lt;br /&gt;
&lt;br /&gt;
To install physlock:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add physlock&lt;br /&gt;
&lt;br /&gt;
It is currently bugged.  See [https://bugs.alpinelinux.org/issues/3282].  physlock likely doesn&#039;t do two-factor authentication but it should.&lt;br /&gt;
&lt;br /&gt;
You need to create custom script that will monitor idle time in TTY then call physlock.  You load this script when you log on.&lt;br /&gt;
&lt;br /&gt;
=== xscreensaver ===&lt;br /&gt;
&lt;br /&gt;
This will lock you out of xserver&lt;br /&gt;
&lt;br /&gt;
To install xscreensaver:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add xscreensaver&lt;br /&gt;
&lt;br /&gt;
=== USB key udev rule ===&lt;br /&gt;
&lt;br /&gt;
You need to add a new [[udev]] rule that will suspend-to-ram or hibernate and log off once you pull the USB key.  When you come back on, you should do 2 factor authentication to restore back everything.  Hibernation and suspend-to-ram might mitigate cold-boot attack (but unlikely see notes at the bottom of the page) to extract plaintext private data and encryption keys in memory.&lt;br /&gt;
&lt;br /&gt;
To find out the details of your USB do:&lt;br /&gt;
&lt;br /&gt;
  udevadm monitor --udev -p&lt;br /&gt;
&lt;br /&gt;
The output should look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UDEV  [181762.722853] add      /devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc (block)&lt;br /&gt;
ACTION=add&lt;br /&gt;
DEVLINKS=/dev/disk/by-id/usb-Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0 /dev/disk/by-path/pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0 /dev/disk/by-uuid/5A96-03E4&lt;br /&gt;
DEVNAME=/dev/sdc&lt;br /&gt;
DEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc&lt;br /&gt;
DEVTYPE=disk&lt;br /&gt;
ID_BUS=usb&lt;br /&gt;
ID_FS_TYPE=vfat&lt;br /&gt;
ID_FS_USAGE=filesystem&lt;br /&gt;
ID_FS_UUID=5A96-03E4&lt;br /&gt;
ID_FS_UUID_ENC=5A96-03E4&lt;br /&gt;
ID_FS_VERSION=FAT32&lt;br /&gt;
ID_INSTANCE=0:0&lt;br /&gt;
ID_MODEL=MSFT_NORB&lt;br /&gt;
ID_MODEL_ENC=MSFT\x20NORB\x20\x20\x20\x20\x20\x20\x20&lt;br /&gt;
ID_MODEL_ID=1645&lt;br /&gt;
ID_PATH=pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0&lt;br /&gt;
ID_PATH_TAG=pci-0000_00_13_2-usb-0_5_1_0-scsi-0_0_0_0&lt;br /&gt;
ID_REVISION=PMAP&lt;br /&gt;
ID_SERIAL=Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0&lt;br /&gt;
ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&lt;br /&gt;
ID_TYPE=disk&lt;br /&gt;
ID_USB_DRIVER=usb-storage&lt;br /&gt;
ID_USB_INTERFACES=:080650:&lt;br /&gt;
ID_USB_INTERFACE_NUM=00&lt;br /&gt;
ID_VENDOR=Kingston&lt;br /&gt;
ID_VENDOR_ENC=Kingston&lt;br /&gt;
ID_VENDOR_ID=0951&lt;br /&gt;
MAJOR=8&lt;br /&gt;
MINOR=32&lt;br /&gt;
SEQNUM=2027&lt;br /&gt;
SUBSYSTEM=block&lt;br /&gt;
USEC_INITIALIZED=1762722168&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You want to extract the &amp;lt;code&amp;gt;ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&amp;lt;/code&amp;gt; or whatever is associated with your USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
You need pm-utils for ps-suspend.  So to install it do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add pm-utils&lt;br /&gt;
&lt;br /&gt;
You will create a udev rules so that when you pull out the USB, it will suspend-to-ram or you can use your own script.  To do that create a file with the following contents:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/udev/rules.d/50-usb-thumb-drive.rules|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACTION==&amp;quot;remove&amp;quot;, SUBSYSTEM==&amp;quot;usb&amp;quot;, ENV{ID_SERIAL_SHORT}==&amp;quot;MSFTLAKDA300EB3021790009&amp;quot;, RUN+=&amp;quot;/usr/sbin/pm-suspend&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Extending battery life ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING: If you do not use the proper mitigation for cold boot attack, you are better off auto-shutdowning the laptop instead of using suspend or hibernate.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== ACPI ===&lt;br /&gt;
&lt;br /&gt;
ACPI is a good daemon to use to execute certain scripts when laptop events are triggered.&lt;br /&gt;
&lt;br /&gt;
To install ACPI do:&lt;br /&gt;
&lt;br /&gt;
  apk add acpi&lt;br /&gt;
&lt;br /&gt;
The events to pay attention to are:&lt;br /&gt;
&lt;br /&gt;
{|  cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Event&lt;br /&gt;
! ACPI Event&lt;br /&gt;
! What your script should do&lt;br /&gt;
|-&lt;br /&gt;
| lid close&lt;br /&gt;
|&lt;br /&gt;
| log off ttys and suspend-to-ram.  ALSA should either set the volume to 0 for the sound card or the sound driver be unloaded.  It might be a good idea to kill or mute any music or movie players if the sound loops loudly after lid open.&lt;br /&gt;
|-&lt;br /&gt;
| lid open&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and all xservers should be locked, possibly reinitialize ALSA and the sound system.&lt;br /&gt;
|-&lt;br /&gt;
| tapped power button&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and suspend-to-ram&lt;br /&gt;
|-&lt;br /&gt;
| held power button&lt;br /&gt;
|&lt;br /&gt;
| hibernate&lt;br /&gt;
|-&lt;br /&gt;
| unplugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;conservative&#039; cpufreq governor at above 25% power ; &#039;powersave&#039; governor at 25%.  set hdparam spindown rate lower.&lt;br /&gt;
|-&lt;br /&gt;
| plugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;performance&#039; governor.  disable hdparam spindown.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The purpose of the power governor is to regulate the running frequency (GHz) of the processor.&lt;br /&gt;
&lt;br /&gt;
Certain event handlers are are managed through laptop-mode-tools.  If you don&#039;t want the dependency, then you could write ACPI handler scripts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;acpi_listen&amp;lt;/code&amp;gt; can be used to retrieve the event name.&lt;br /&gt;
&lt;br /&gt;
TODO: put scripts below&lt;br /&gt;
&lt;br /&gt;
=== Adjusting the backlight dynamically ===&lt;br /&gt;
&lt;br /&gt;
The backlight may be controlled using sysfs.  The setting is a descendant of &amp;lt;code&amp;gt;/sys/class/backlight/&amp;lt;/code&amp;gt;.  The feature may allow you to echo a value to it.  Use trial and error to discover the values.&lt;br /&gt;
&lt;br /&gt;
The adjustment of the backlight should be function of battery life.  So if it is like 33% battery life, you want to run it near lowest settings but readable.  For 50 percent battery energy maybe 40% light.  For 90% battery maybe 75% light.&lt;br /&gt;
&lt;br /&gt;
=== hdparm ===&lt;br /&gt;
&lt;br /&gt;
To install hdparam do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add hdparm&lt;br /&gt;
&lt;br /&gt;
The settings that laptop-mode-tools messes with is the &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; or the spindown timeout.  It was also hinted that acoustic setting &amp;lt;code&amp;gt;-M&amp;lt;/code&amp;gt; is associated with the speed meaning that louder is faster and quieter is slower which could contribute to the amount of energy used or reduced.&lt;br /&gt;
&lt;br /&gt;
Again you want something like laptop-mode-tools or ACPI to dynamically adjust the settings based on ACPI events.&lt;br /&gt;
&lt;br /&gt;
=== laptop-mode-tools ===&lt;br /&gt;
&lt;br /&gt;
This is currently not in aports but worthy mentioning.  It should really be packaged.  This is a set of scripts to define a power policies.  You can manage all the settings in one place here like the hard drive idle spindown time, CPU governor control, dynamic LCD backlight behavior based on running on battery or AC power supply.&lt;br /&gt;
&lt;br /&gt;
=== cpufreqd ===&lt;br /&gt;
&lt;br /&gt;
This is a useful daemon for regulating power.&lt;br /&gt;
&lt;br /&gt;
To install cpufreqd do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add cpufreqd&lt;br /&gt;
&lt;br /&gt;
Make sure you add the service:&lt;br /&gt;
&lt;br /&gt;
  sudo rc-update add cpufreqd&lt;br /&gt;
&lt;br /&gt;
=== LCD screen refresh rate ===&lt;br /&gt;
&lt;br /&gt;
The refresh rate sets the maximum framerate.  The more frames pushed the more energy consumed on the battery.  You want this adjusted dynamically per certain events.  For gaming, you want it to be the highest as possible for the laptop and vsync off.  For battery use and traveling, you want it capped at 60 FPS/60 Hz or lower but dynamically adjust when you plug in the AC power supply.  You can adjust the framerate with xrandr.  For movies and YouTube, you want 60FPS and vsync on.&lt;br /&gt;
&lt;br /&gt;
== Hacking the kernel ==&lt;br /&gt;
&lt;br /&gt;
You should refer to the [[Custom Kernel]] page for details.&lt;br /&gt;
&lt;br /&gt;
== Hibernation ==&lt;br /&gt;
&lt;br /&gt;
See [[Custom_Kernel#Hibernation_to_prevent_data_loss|Hibernation to prevent data loss]].&lt;br /&gt;
&lt;br /&gt;
== WiFi management ==&lt;br /&gt;
&lt;br /&gt;
Since you are using WiFi, you need a better WiFi management to quickly find open access WiFi access points.  We don&#039;t have all day to debug complexities of WiFi settings while away from home.&lt;br /&gt;
&lt;br /&gt;
To install NetworkManager do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add networkmanager&lt;br /&gt;
&lt;br /&gt;
To find WiFi access points use the &amp;lt;code&amp;gt;nmtui&amp;lt;/code&amp;gt; ncurses interface.&lt;br /&gt;
&lt;br /&gt;
You also need other programs so install them as well:&lt;br /&gt;
&lt;br /&gt;
  apk add wpa-supplicant dhcpcd chrony macchanger wireless-tools iputils&lt;br /&gt;
&lt;br /&gt;
What these programs do:&lt;br /&gt;
&lt;br /&gt;
* wpa-supplicant -- for WPA encryption&lt;br /&gt;
* dhcpcd -- for getting a dynamic IP address&lt;br /&gt;
* chrony -- for fixing the time with the atomic clock&lt;br /&gt;
* wireless-tools -- for additional information&lt;br /&gt;
* macchanger -- for protecting against WiFi access discrimination or increased anonymity.  (optional)&lt;br /&gt;
* iputils -- for the ping command (optional)&lt;br /&gt;
&lt;br /&gt;
You also need to add those services:&lt;br /&gt;
&lt;br /&gt;
  rc-update add chronyd&lt;br /&gt;
  rc-update add wpa_supplicant&lt;br /&gt;
  rc-update add dhcpcd&lt;br /&gt;
  rc-update add networkmanager&lt;br /&gt;
&lt;br /&gt;
To start the services manually (or just reboot):&lt;br /&gt;
&lt;br /&gt;
  rc-service chronyd start&lt;br /&gt;
  rc-service wpa_supplicant start&lt;br /&gt;
  rc-service dhcpcd start&lt;br /&gt;
  rc-service networkmanager start&lt;br /&gt;
&lt;br /&gt;
== Additional tools ==&lt;br /&gt;
&lt;br /&gt;
=== actkbd ===&lt;br /&gt;
&lt;br /&gt;
To control the sound with fn function keys, you need this daemon.  It is currently not in aports.  You could override the design and meaning of those keys with your own scripts and utilities.  This daemon gives you that freedom.&lt;br /&gt;
&lt;br /&gt;
If your laptop contains a brightness key, you want to set that up with this program.  See also [[Setting_up_a_laptop#Adjusting_the_backlight_dynamically | Adjusting the backlight dynamically]].&lt;br /&gt;
&lt;br /&gt;
=== secure-delete ===&lt;br /&gt;
&lt;br /&gt;
Want to prevent cold-boot attack or decrypted keys in memory falling in the wrong hands?  This maybe could work who knows?  From research from cold boot attack, the data can actually stay in memory in minutes, just enough time for a hacker to copy the contents of the memory to a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
To install secure-delete do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add secure-delete&lt;br /&gt;
&lt;br /&gt;
smem only works for unused ram.[https://github.com/gordonrs/thc-secure-delete]  If you use the vanilla kernel, this may work.  If you use grsecurity, it will automatically sanitize memory if you enable it (but not enabled by default in the Alpine hardened kernel) when the memory page is freed.[https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Sanitize_all_freed_memory]&lt;br /&gt;
&lt;br /&gt;
Close all important programs then call smem.&lt;br /&gt;
&lt;br /&gt;
You call smem in your shutdown script or auto-logoff script.&lt;br /&gt;
&lt;br /&gt;
You can call create a OpenRC shutdown script to run smem when most programs and services are closed.  This will erase all your sensitive plaintext private data just in case.&lt;br /&gt;
&lt;br /&gt;
You may want to create a wrapper script to call smem after your program closes.&lt;br /&gt;
&lt;br /&gt;
You need to write a custom script that does the following:&lt;br /&gt;
  * kill all running processes associated with your user account&lt;br /&gt;
  * auto logoff terminals&lt;br /&gt;
  * for the last terminal closed including all idle xservers, unmount your user home&lt;br /&gt;
  * (optional) use smem to wipe all your plaintext private data in memory after all closed programs in case of cold boot attack&lt;br /&gt;
&lt;br /&gt;
=== Sharing presentations over HDMI ===&lt;br /&gt;
&lt;br /&gt;
If you want to use your laptop to share presentation over HDMI connection, you need libxinerama and xrandr.&lt;br /&gt;
&lt;br /&gt;
To install libxinerama and xrandr do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add libxinerama xrandr&lt;br /&gt;
&lt;br /&gt;
== Important notes ==&lt;br /&gt;
&lt;br /&gt;
If you lose or break your USB key, that is it and you cannot decrypt your drive.  It would be wise to make a backup of it.&lt;br /&gt;
&lt;br /&gt;
By default, suspend-to-ram or hibernate will not sufficiently clear the AES encryption keys off ram in those phases which would invite a cold boot attack.  This has been covered by the TRESOR kernel patch.[https://en.wikipedia.org/wiki/TRESOR][https://www1.cs.fau.de/tresor]  This patch hasn&#039;t been updated since the 4.x kernel series.[https://www1.cs.fau.de/tresor].  This patch currently only works on 32-bit x86 Linux with SSE and MMX, and on processors with the AES-NI instruction set for x86_64 Linux.  TRESOR doesn&#039;t work with DMA attack, but it can be mitigated by disabling DMA.[https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.303.3053&amp;amp;rep=rep1&amp;amp;type=pdf]  The 32-bit version of TRESOR has only a key size of 128.  The AES-NI version of TRESOR has a largest key size of 256 bit.  See [[Setting_up_a_laptop#Choosing_ciphers | Choosing ciphers]] for the number of rounds cracked.&lt;br /&gt;
&lt;br /&gt;
Loop-Amnesia works with LoopAES and is only for 64 bit Linux and only supports 128 bit keys but can result in data loss if their recommendations are not followed. [https://moongate.ydns.eu/amnesia.html]&lt;br /&gt;
&lt;br /&gt;
Please read the Wikipedia article on Cold Boot Attack especially the mitigation section.[https://en.wikipedia.org/wiki/Cold_boot_attack] Full disk encryption will not protect your data especially for older hardware if you do not have the proper mitigation (implying not full proof) prerequisites such as a patched kernel, memory scrambling, permanent memory module mounting for example.&lt;br /&gt;
&lt;br /&gt;
If you have a different but fully encrypted device like iPad, you still can be rubberhosed or interrogated with a perfect deniable encrypted laptop.  This guide doesn&#039;t protect you from that possibility.  If you do not want to be rubberhosed, don&#039;t possess those devices.&lt;br /&gt;
&lt;br /&gt;
Additional tips to mitigate against a DMA Attack to exfiltrate encryption keys:&lt;br /&gt;
&lt;br /&gt;
Disable DMA in the BIOS and set the password for the BIOS according to Wikipedia.[https://en.wikipedia.org/wiki/DMA_attack]&lt;br /&gt;
&lt;br /&gt;
Blacklist kernel modules that use DMA and any unused expansion modules (FireWire, CardBus, ExpressCard, Thunderbolt, USB 3.0, PCI Express and hotplug modules) that use DMA.&lt;br /&gt;
&lt;br /&gt;
You may need a custom (or customize a) BIOS or use Intel TXT or TPM which will authenticate the boot devices or boot from specific serial numbers not just any.  For cold boot attack, it is not required to remove the RAM but to to slow down the rate of decay of the RAM module with liquid air in addition an USB thumb drive containing an encryption key retriever bypassing the operating system.[https://youtu.be/XfUlRsE3ymQ]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[category: Desktop]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32061</id>
		<title>Setting up a laptop</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32061"/>
		<updated>2026-02-17T10:16:03Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Getting the available ciphers */ cleaner find oneliner&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide is about a project to create a &#039;&#039;&#039;secured laptop&#039;&#039;&#039;.  For this project we take in consideration ways to extend battery life.  It covers tools and daemons that are must haves for a laptop setup.&lt;br /&gt;
{{Todo|Instructions given in the page needs testing. Please help test section by section or the entire page. If individual sections have been tested, please update the Talkpage or please move/place this notice in the untested section(s) alone.}}&lt;br /&gt;
&lt;br /&gt;
== Guide features ==&lt;br /&gt;
&lt;br /&gt;
*Deniable full disk encryption&lt;br /&gt;
*Two factor authentication (physical object (USB key), mind) &lt;br /&gt;
*Encrypted swap and hibernation&lt;br /&gt;
*Encrypted home on top of encrypted drive&lt;br /&gt;
*Memory sanitation&lt;br /&gt;
*Dynamic power modes&lt;br /&gt;
*Feature keys support&lt;br /&gt;
&lt;br /&gt;
== Rubberhose Attack ==&lt;br /&gt;
&lt;br /&gt;
Just a reminder that all attacks are subjected to the Rubberhose Attack dilemma, you either give up your encryption keys or be tortured with a rubberhose with the possibly of death.  See [https://en.wikipedia.org/wiki/Rubber-hose_cryptanalysis Wikipedia article].  We try to present [https://en.wikipedia.org/wiki/Deniable_encryption  deniable encryption (Wikipedia)] to avoid a rubberhose attack scenario.  In this article we use the words plausible deniability interchangeably with deniable encryption.  To achieve this we use a facade and require no metadata fingerprints to expose or hint of encrypted or hidden containers or hint as in detect of existence of an encrypted disk.  The keys should be stored using steganography where we dilute the randomness into the facade.  It also requires you not to brag about encryption or mention it because that is an invitation for the attacker to torture the victim.  Deniable encryption requires you not put encrypted as an entry title to your bootloader.  There shouldn&#039;t be an entry for your facade bootloader to the encrypted drive.&lt;br /&gt;
&lt;br /&gt;
== Why full disk? ==&lt;br /&gt;
&lt;br /&gt;
The full disk encryption provides sort of some plausible deniability or a valid alibi that you didn&#039;t encrypt it.  Is the drive just random noise, broken, or is it really encrypted?  The other reason is that it implies that everything is protected.&lt;br /&gt;
&lt;br /&gt;
But there could be problems if not done right.  For example, cryptsetup does leave a plaintext marking or some hints by default that it has been encrypted when using luks/luks2 mode if a detached header with option &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is not presented.[https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/][https://man7.org/linux/man-pages/man8/cryptsetup.8.html]  To gain credibility that we didn&#039;t really do the encryption, you have to wipe the +3 MiB region based on the number of key slots used; or store the headers on an external device.&lt;br /&gt;
&lt;br /&gt;
If you did deniable encryption incorrectly, it is possible to erase and restore the header.  This presents an opportunity to improve obfuscation.  When you pull out the USB key, it should erase the header but store it on the USB key atomically as in completely.  If you plug in the USB key, it will restore back the header.  cryptsetup has luks actions luksHeaderBackup and luksHeaderRestore to do this.&lt;br /&gt;
&lt;br /&gt;
== Starting at the beginning ==&lt;br /&gt;
&lt;br /&gt;
Grab a USB thumb drive with Alpine.  Set it up as usual but don&#039;t let it touch your drive yet.  Then, install all the tools into memory ramdisk but not in the hard drive yet.  The hard drive will be obliterated.&lt;br /&gt;
&lt;br /&gt;
You will then install Alpine using the steps:&lt;br /&gt;
&lt;br /&gt;
First you need WiFi, to get it run do the command below but say no or skip  the hard drive setup stuff:&lt;br /&gt;
&lt;br /&gt;
  setup-alpine&lt;br /&gt;
&lt;br /&gt;
Then, you need to install some tools into RAM temporarly:&lt;br /&gt;
  apk add e2fsprogs grub grub-bios grub-efi mkinitfs nano&lt;br /&gt;
&lt;br /&gt;
== Randomizing the drive with pseudorandom urandom entropy ==&lt;br /&gt;
&lt;br /&gt;
The first part is to erase the drive with random noise but in practical time.  There are many techniques to do this but should be done in one day or two minimum.&lt;br /&gt;
&lt;br /&gt;
You can use shred or dd to accomplish this depending on your needs and the availability of entropy.  Some techniques take longer.  Cryptologist Bruce Schneier recommended 7 times with specified pattern.  See [https://en.wikipedia.org/wiki/Data_erasure Wikipedia Article].  For practical purposes, we just do it random in one pass.  It should be random so that the facade of random noise hides the encrypted data which resembles noise.&lt;br /&gt;
&lt;br /&gt;
To list the drives on the system do &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: make sure you wipe the right specific drive.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To wipe the disk with random entropy do:&lt;br /&gt;
&lt;br /&gt;
  dd if=/dev/urandom of=/dev/sda&lt;br /&gt;
&lt;br /&gt;
== Creating GPG keys ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;As of this time, Alpine&#039;s mkinitfs does only one factor authentication with passphrase.&#039;&#039;&#039; You need to manually edit the initramfs-init.in in mkinitfs to support two factor authentication using cryptsetup.&lt;br /&gt;
&lt;br /&gt;
After you have scrambled the drive, you want to create your GPG keys.  You will use these keys to set the password(s) for your cryptsetup-luks partitions.  These keys should be stored on a USB thumb drive or other memory device but should not be on the USB boot thumb drive or on the encrypted drive.  The key should be a random 128 bit key wrapped in GPG and protected with a password.&lt;br /&gt;
&lt;br /&gt;
If you are using x, you need to do &amp;lt;code&amp;gt;sudo apk add pinentry-gtk&amp;lt;/code&amp;gt; to display password prompt properly for the next step.&lt;br /&gt;
&lt;br /&gt;
To install openssl and gpg do:&lt;br /&gt;
&lt;br /&gt;
  apk add openssl gnupg&lt;br /&gt;
&lt;br /&gt;
Then, to generate a key:&lt;br /&gt;
&lt;br /&gt;
  export GPG_TTY=$(tty) &amp;amp;&amp;amp; openssl rand -base64 512 | gpg --symmetric --cipher-algo aes --armor &amp;gt; /mnt/usb/$(openssl rand -hex 12)&lt;br /&gt;
&lt;br /&gt;
(Make sure your usb is mounted on /mnt/usb first.)&lt;br /&gt;
&lt;br /&gt;
The long file name comes from &amp;lt;code&amp;gt;openssl rand -hex 12&amp;lt;/code&amp;gt; so that we enhance plausible deniability.  The attacker cannot determine the purpose of the key.  Is it used for GitHub? for Email?&lt;br /&gt;
&lt;br /&gt;
The first part will produce 512 random bytes in wrap it in base64.  The random data will be piped to gpg which will wrap it in AES as ciphertext which again gets wrapped in base64 ascii armor.  For every partition including swap in some cases, you should create more gpg keys and store them in your USB thumb drives.  After you have produced your gpg keys, you will then use them as a password for cryptsetup/luks.&lt;br /&gt;
&lt;br /&gt;
You can replace aes above with the ones listed in &amp;lt;code&amp;gt;gpg --version&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There should be a password generated for the swap.  This is to resume for your hibernate.  If you don&#039;t want to hibernate, then password is not required and all you need to do is to create/format the partition each time you boot without a password or with a one time random password.&lt;br /&gt;
&lt;br /&gt;
== Hiding the keys using steganography ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;WARNING:&#039;&#039; This section is considered experimental.  It requires the tool and the dependencies to be placed on another USB separate from the key files, the bootloaders, and encrypted disks.  The tool and dependencies need to be packaged together.  We decentralize these components so that the attacker doesn&#039;t connect the dots easily or immediately jumps to the conclusion for the requirements to decrypt.  Steghide automatically uses 128-bit AES in CBC mode to encrypt data.  This can be change if you don&#039;t like or trust AES with the -e option.  Use &amp;lt;code&amp;gt;steghide encinfo&amp;lt;/code&amp;gt; for other ciphers and modes.&lt;br /&gt;
&lt;br /&gt;
Fortunately, Alpine has a package for steganography called steghide (in the optional edge/testing repository as of February 2026). To install steghide do:&lt;br /&gt;
&lt;br /&gt;
  echo &amp;quot;http://dl-cdn.alpinelinux.org/alpine/edge/testing&amp;quot; &amp;gt;&amp;gt; /etc/apk/repositories&lt;br /&gt;
  apk add steghide&lt;br /&gt;
&lt;br /&gt;
You will place the keyfile in an image file.  The facade image file should be large enough that there is no apparent discernible difference between the original and the modified.  Do not use a small image with a small filesize.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously luks headers could be 3MB large or more and an jpeg image file is not suitable.  Use another format like .au/.wav or another steganography utility that handles mp3s.  The mp3/wav should be fairly large enough to dilute the header.  So, something with long content is suitable.&lt;br /&gt;
&lt;br /&gt;
There are two basic commands to use with steghide embed and extract,&lt;br /&gt;
&lt;br /&gt;
To embed do:&lt;br /&gt;
&lt;br /&gt;
  steghide embed -ef key.gpg -cf image.jpg&lt;br /&gt;
&lt;br /&gt;
To extract do:&lt;br /&gt;
&lt;br /&gt;
  steghide extract -xf key.gpg -sf image.jpg&lt;br /&gt;
&lt;br /&gt;
To get a file list of files to ship out, use:&lt;br /&gt;
&lt;br /&gt;
  apk info -L libgcc libmcrypt libmhash libstdc++ libjpeg-turbo steghide&lt;br /&gt;
&lt;br /&gt;
== Full disk encryption with with cryptsetup-luks volumes ==&lt;br /&gt;
&lt;br /&gt;
=== Partitioning scheme ===&lt;br /&gt;
&lt;br /&gt;
This section presents a conceptual layout.  It should not be a knee-jerk approval to automatically use the partition tool which would compromise your plausible deniability.&lt;br /&gt;
&lt;br /&gt;
For the facade, we use an Ubuntu Live CD (or less skilled distro) to present the impression that we are not sophisticated or tech savvy enough to implement encryption.  Windows is also acceptable even better.  The immutable Live CD and immutable partition ensures that you are not compromised by a third party attacker that implants evidence.&lt;br /&gt;
&lt;br /&gt;
There could be possibly two bootloaders, one for the facade and the other to the encrypted drive stored on an external device.&lt;br /&gt;
&lt;br /&gt;
==== Luks ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you can demonstrate no existence of partitions 2, 3, 4 and no fingerprints/plaintext introduced by cfdisk and cryptsetup-luks.  Use something like TestDisk, fdisk -l, or gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| root&lt;br /&gt;
| /&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Plain dm-crypt ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you are able to present #2 as being unused space or untampered.  To check use something like TestDisk, gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| vgroot&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_1&lt;br /&gt;
| vgroot-root&lt;br /&gt;
| /&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_2&lt;br /&gt;
| vgroot-swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 2_3&lt;br /&gt;
| vgroot-rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Installing cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
To install cryptsetup you need the package below&lt;br /&gt;
&lt;br /&gt;
  apk add cryptsetup&lt;br /&gt;
&lt;br /&gt;
=== Choosing ciphers ===&lt;br /&gt;
&lt;br /&gt;
When you create your luks drives, you need to decide on the type of ciphers and hashing techniques to use.  The ciphers that you want to use are ones are up to you, but it should be one that is hasn&#039;t been cracked yet or has not suffered a lot of cryptanalysis attacks.  The ones that you might want to use is AES which is hardware accelerated in some Intel CPUs that have the AES-NI cpuflag which you can check by &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt;.  Also consider the ciphers that are SIMD optimized such as serpent and twofish that are available in the Linux kernel.  Also consider ciphers that are unpopular but known to be secure such as Blowfish (which Wikipedia claims to be attacked and the author recommended Twofish).[https://en.wikipedia.org/wiki/Cipher_security_summary]  If it is hardware accelerated, it will save battery life and minimize CPU usage.&lt;br /&gt;
&lt;br /&gt;
For some ciphers weakness also see [https://en.wikipedia.org/wiki/Cipher_security_summary Cipher security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
For some hash function weaknesses also see [https://en.wikipedia.org/wiki/Hash_function_security_summary Hash function security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
Generally speaking, the swap partition should use a fast cipher.  You want to lower the latency or delay of the memory subsystem as a consequence of being encrypted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; Please read the [[Setting_up_a_laptop#Important_notes | Important notes]] section for details about the problems with AES encryption.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t trust AES shills and it&#039;s NSA endorsement, you can try another different one.  Another advantage of using a public vetted cipher is that it provides confidence that it works.&lt;br /&gt;
&lt;br /&gt;
Something like KHAZAD wouldn&#039;t work on &amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt;.  KHAZAD itself is insecure.  Wikipedia reported 5 out of 8 rounds been cracked.[https://en.wikipedia.org/wiki/KHAZAD]&lt;br /&gt;
&lt;br /&gt;
For AES-128 7 out of 10, AES-192 8 out of 12, AES-256-bit 9 out 14 rounds have been cracked according to Wikipedia.[https://en.wikipedia.org/wiki/Advanced_Encryption_Standard]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: Do not use sha1 as the hashing algorithm.&#039;&#039;&#039;  It already has been compromised.&lt;br /&gt;
&lt;br /&gt;
=== Getting the available ciphers ===&lt;br /&gt;
&lt;br /&gt;
To check the availability of a cipher or hash function use:&lt;br /&gt;
  find /lib/modules/* -type f -path  &amp;quot;*/crypto/*.ko&amp;quot; -exec basename {} \; | sort&lt;br /&gt;
&lt;br /&gt;
To check if a cipher is loaded and passed its own tests use:&lt;br /&gt;
  cat /proc/crypto&lt;br /&gt;
&lt;br /&gt;
To test some popular ciphers and hashes do:&lt;br /&gt;
&lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
&lt;br /&gt;
The top set is associated with the hashing algorithms.  The bottom set are the ciphers.  Use the commands below but replace the cipher and/or hash algorithm with your preferences.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt; actually doesn&#039;t show all the ciphers like Anubis.  The cipher should also have CBC and/or XTS block cipher mode of operation to encrypt larger block sizes.  AES for example has a block size of 128.  &lt;br /&gt;
&lt;br /&gt;
To test if the unpopular but uncracked cipher works use sometime like:&lt;br /&gt;
  cryptsetup benchmark --cipher anubis&lt;br /&gt;
&lt;br /&gt;
=== General steps for cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
==== Original method with fdisk with no plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
In this method &amp;lt;code&amp;gt;--type luks&amp;lt;/code&amp;gt; is implied which generates metadata.&lt;br /&gt;
&lt;br /&gt;
If you want plausible deniability for luks, you need to pass &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; to all the luks commands, where &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is a unix path like /mnt/usb/d6ae10eda66704c8.  The random name comes from &amp;lt;code&amp;gt;openssl rand -hex 8&amp;lt;/code&amp;gt;.  The header is transferred to the external device (but no mention of the key slot area but ciphertext being transferred) in the man page.  The information in that file should be obfuscated with encryption if there is plaintext or fingerprint in it just in case. Then, it should be decrypted when reused.&lt;br /&gt;
&lt;br /&gt;
You need to install cfdisk if you prefer the interactive ncurses console method:&lt;br /&gt;
&lt;br /&gt;
  apk add cfdisk&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Use cfdisk to create partitions.  Make two partitions--a system partition and a swap partition&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cfdisk&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Create and format the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --cipher aes-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sda1 /mnt/usb/$(ls)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Open the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --key-file /mnt/usb/$(ls) luksOpen /dev/sda1 root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Format the decrypted drive with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Create the mount point&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Mount the root partition&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Create swap&lt;br /&gt;
| cryptsetup -c blowfish -h sha256 -d /dev/urandom --key-file /mnt/usb/59022506d9f4a714 create swap /dev/sda2 &lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Use swap&lt;br /&gt;
| mkswap /dev/mapper/swap &amp;amp;&amp;amp; swapon /dev/mapper/swap&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Improved method with plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
This method requires lvm2.  To install:&lt;br /&gt;
&lt;br /&gt;
  apk add lvm2&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Open the &#039;&#039;plain dm-crypt&#039;&#039; device generating no metadata&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Physical volume create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;pvcreate /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Volume group create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;vgcreate vgroot /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Logical volume create the swap volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 4G vgroot -n swap&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Logical volume create the root volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 2T vgroot -n root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Logical volume create the rescue volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 110M vgroot -n rescue&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Format the root volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Format the swap volume and activate it&lt;br /&gt;
| &amp;lt;code&amp;gt;mkswap /dev/mapper/vgroot-swap &amp;amp;&amp;amp; swapon /dev/mapper/vgroot-swap&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Format the rescue volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-rescue&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Create mount point for root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| Mount the root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/vgroot-root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Configuring OpenRC dmcrypt and setting up fstab ===&lt;br /&gt;
&lt;br /&gt;
You need to tell OpenRC init scripts to decrypt the volumes.  See &amp;lt;code&amp;gt;/etc/conf.d/dmcrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You need to add the service to boot well because it needs to decrypt the root volume before OpenRC starts running commands from it.  So you need to do:&lt;br /&gt;
&lt;br /&gt;
  rc-update add dmcrypt boot&lt;br /&gt;
&lt;br /&gt;
==== dmcrypt ====&lt;br /&gt;
The dmcrypt OpenRC service will attempt to decrypt the drive using information provided in &#039;&#039;/etc/conf.d/dmcrypt&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root may not be necessary since it is already mounted.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda1&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root is likely not required since you already mounted it before OpenRC starts to do its thing.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
  options=&#039;--type plain --cipher aes-cbc-essiv:sha256 --key-size 256&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
  pre_mount=&#039;vgchange -ay vgroot ; lvchange -ay vgroot/swap&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
dm-crypt will just mount the encrypted &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; partition.  What you need to do next is set up fstab located at /etc/fstab.  Examples are shown below.&lt;br /&gt;
&lt;br /&gt;
==== /etc/fstab ====&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;plain dm-crypt&#039;&#039; device with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/root          /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/swap          none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;lvm&#039;&#039; volumes with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/vgroot-root   /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/vgroot-swap   none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How to recover from a bad setup ===&lt;br /&gt;
&lt;br /&gt;
Many times you will not get it right perfectly the first try.  To recover from this situation, you need to reopen the &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; drive and then remount everything back.&lt;br /&gt;
&lt;br /&gt;
To recover from &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
  cryptsetup --key-file /mnt/usb/2a667ec72774b0d5 luksOpen /dev/sda1 root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/root /mnt/root&lt;br /&gt;
&lt;br /&gt;
To recover from the &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
  cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda root&lt;br /&gt;
  vgchange -ay vgroot&lt;br /&gt;
  lvchange -ay vgroot/root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/vgroot-swap /mnt/root&lt;br /&gt;
&lt;br /&gt;
== Next step: Full blown Alpine installation ==&lt;br /&gt;
&lt;br /&gt;
We will setup the /mnt/root encrypted partition:&lt;br /&gt;
  apk add --root=/mnt/root --initdb $(cat /etc/apk/world) --keys-dir /etc/apk/keys --repositories-file /etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, enable edge repositories in both files including community and testing:&lt;br /&gt;
  nano /etc/apk/repositories /mnt/root/etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, copy the necessary files:&lt;br /&gt;
  cp /etc/resolv.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, install the basic utils:&lt;br /&gt;
  apk add --root=/mnt/root dhcpcd chrony networkmanager wireless-tools wpa_supplicant&lt;br /&gt;
  apk add --root=/mnt/root grub mkinitfs e2fsprogs grub-bios grub-efi&lt;br /&gt;
  apk add --root=/mnt/root sudo nano&lt;br /&gt;
  apk add --root=/mnt/root linux-lts&lt;br /&gt;
&lt;br /&gt;
Then, you need to mount your usb on to /boot:&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Edit grub:&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
Then, install grub on the usb:&lt;br /&gt;
  grub-install --force /dev/sdb&lt;br /&gt;
&lt;br /&gt;
Then, prepare chroot:&lt;br /&gt;
  mount --bind /dev /mnt/root/dev&lt;br /&gt;
  mount --bind /sys /mnt/root/sys&lt;br /&gt;
  cp /etc/reslov.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, chroot:&lt;br /&gt;
  chroot /mnt/root /bin/sh&lt;br /&gt;
&lt;br /&gt;
Set the root administrator password:&lt;br /&gt;
  passwd&lt;br /&gt;
&lt;br /&gt;
The root password should be very difficult to deter you from using it and force you to use sudo&lt;br /&gt;
&lt;br /&gt;
Edit sudo so that wheel group has administrative :&lt;br /&gt;
  EDITOR=nano visudo&lt;br /&gt;
&lt;br /&gt;
Set:&lt;br /&gt;
  ## Uncomment to allow members of group wheel to execute any command       &lt;br /&gt;
  %wheel ALL=(ALL) ALL                                                 &lt;br /&gt;
&lt;br /&gt;
Then, add wheel (administrator) user:&lt;br /&gt;
  useradd -m myname&lt;br /&gt;
  usermod -a -G video,audio,wheel myname&lt;br /&gt;
&lt;br /&gt;
log in that user:&lt;br /&gt;
  su myname&lt;br /&gt;
&lt;br /&gt;
Then, update and upgrade it&lt;br /&gt;
  sudo apk update&lt;br /&gt;
  sudo apk upgrade&lt;br /&gt;
&lt;br /&gt;
Then, setup xorg:&lt;br /&gt;
  sudo setup-xorg-base&lt;br /&gt;
  sudo apk search xf86-video | sort&lt;br /&gt;
  # pick your xf86 video driver&lt;br /&gt;
  sudo apk add xf86-video-amdgpu&lt;br /&gt;
  # install the mesa driver&lt;br /&gt;
  sudo apk add mesa-dri-gallium  &lt;br /&gt;
&lt;br /&gt;
Then, keep piling on:&lt;br /&gt;
  sudo apk add firefox dwm xfce4-terminal alsa-utils keepassx xfce4 xchat&lt;br /&gt;
  sudo apk add font-noto-emoji font-terminus leafpad xsetroot # See [[Emojis]] to complete installation&lt;br /&gt;
  sudo apk add xf86-input-libinput # or -evdev if libinput doesn&#039;t work&lt;br /&gt;
&lt;br /&gt;
Then, set the desktop:&lt;br /&gt;
  nano .xinitrc&lt;br /&gt;
&lt;br /&gt;
Put both but comment with a # one of them if you don&#039;t want it,&lt;br /&gt;
  #while true; do xsetroot -name &amp;quot;$( date +&amp;quot;%a %b %d %I:%M:%S %Y&amp;quot; )&amp;quot; ; sleep 1; done &amp;amp;&lt;br /&gt;
  #exec dwm&lt;br /&gt;
  exec xfce4-session&lt;br /&gt;
&lt;br /&gt;
For the above xsetroot statement used to provide information in the statusbar for dwm, consider adding information about the battery level.  This information can be found in sysfs at /sys/class/power_supply/BAT0/.&lt;br /&gt;
&lt;br /&gt;
  sync&lt;br /&gt;
  sudo reboot&lt;br /&gt;
&lt;br /&gt;
== Hacking mkinitfs to support cryptsetup with GPG keys ==&lt;br /&gt;
&lt;br /&gt;
This section describes how to assemble a custom initscript chain in multiple parts.  It could be extended with three-factor authentication which adds biometrics along side with mind and physical object.&lt;br /&gt;
&lt;br /&gt;
Most entry to secure systems are not fully automated or do not allow things to quickly pass through freely and often guarded.  This process may seem like a hassle, but it should dissuade the rubberhosers from jumping to the conclusion of the possibility of the existence of a encrypted drive.&lt;br /&gt;
&lt;br /&gt;
Here is the steps required so that the facade initscripts and dependencies are free from encryption.&lt;br /&gt;
* You will separate and archive cryptsetup, ciphers kernel modules, hash function kernel modules, and any additional obfuscation dependencies, and another continuation initscript discussed below.  You need to make sure that you copy /etc/mkinitfs/mkinitfs.conf to your home directory and strip out those features without those modules.&lt;br /&gt;
* You will hide this archive in a mp3 file with another tool you will package or you can use steghide&#039;s .au/.wav support, but .au seems too conspicuous or strange by current trends.&lt;br /&gt;
&lt;br /&gt;
Here we try to clean up the facade so that it presents itself as free without cryptography.  You need the following changes to your initramfs to avoid a sensitive rubberhoser:&lt;br /&gt;
* You will delete everything in the custom initramfs-init referring to encryption.  This includes cryptroot, cryptdm, crypt-anything, etc init options.&lt;br /&gt;
* You need to delete references in nlplug-findfs to cryptsetup and recompile the mkinitfs package.&lt;br /&gt;
* You could program the init script to boot into a facade partition but drop into sh if a hidden special keypress sequence is met.&lt;br /&gt;
&lt;br /&gt;
You need to create a custom init continuation script:&lt;br /&gt;
* Your initscript should drop into single mode which you will mount the encrypted path manually. &lt;br /&gt;
* You will manually steg-unhide the encrypted archive hidden in the mp3 file and extract it to the ramdisk.&lt;br /&gt;
* You will run the custom init continuation script manually.&lt;br /&gt;
* This custom init continuation will automate the process of extracting the gpg keys from another device and image files into the ramdisk.  This will then automate the mounting of the encrypted drive.  This resume continuation script should handle both cold boot and hibernate.&lt;br /&gt;
* You will finish resuming running the other half of mkinitfs-init or specifically where the points after where it typically will mount cryptsetup and hibernate devices.&lt;br /&gt;
&lt;br /&gt;
If you use a USB keyboard, you will unlock the encrypted devices in early userspace. You will need to either compile the USB keyboard drivers in the kernel or you need to add additional modules when generating the mkinitfs.  You will need the hid, hid-generic, ehci-hcd, uhci-hcd, usbcore driver and add those paths in a customized &amp;lt;code&amp;gt;/etc/mkinitfs/features.d/usb-keyboard.modules&amp;lt;/code&amp;gt;.  It should be separate from usb.modules because apk updates may overwrite it.  Use the &amp;lt;code&amp;gt;lsmod&amp;lt;/code&amp;gt; utility from the kmod package to find what drivers your USB keyboard uses.&lt;br /&gt;
&lt;br /&gt;
You need to generate the final mkinitfs.&lt;br /&gt;
First you need the kernelversion to pass into mkinitfs.  To obtain that information do &amp;lt;code&amp;gt;ls /lib/modules&amp;lt;/code&amp;gt; which will show some folders.  Once you found it pass it to mkinitrafs by doing and replacing kernelversion below:&lt;br /&gt;
&lt;br /&gt;
  sudo mkinitramfs -i $HOMEDIR/initramfs-init -c &amp;quot;$HOMEDIR&amp;quot;/mkinitfs.conf kernelversion&lt;br /&gt;
&lt;br /&gt;
The $HOMEDIR should be replaced with the full path if you are not root.&lt;br /&gt;
&lt;br /&gt;
==  Install the bootloader in the USB thumb drive ==&lt;br /&gt;
&lt;br /&gt;
To install grub, you need to install grub on the ramdisk first on the host.  &lt;br /&gt;
&lt;br /&gt;
  apk add grub&lt;br /&gt;
&lt;br /&gt;
To get a list of partitions&lt;br /&gt;
&lt;br /&gt;
  fdisk -l&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition in /boot&lt;br /&gt;
&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Make changes to grub&#039;s configuration &lt;br /&gt;
&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You need to customize the initramfs in order to use GPG keys since there is no support from it.&#039;&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
The steps here below assumes that these custom initramfs features have been implemented.  &lt;br /&gt;
&lt;br /&gt;
The following boot loader settings is &#039;&#039;&#039;not sufficient&#039;&#039;&#039; for deniable encryption because it exposes the fact that an encrypted drive exists because an attacker can discover that encryption was used through the edit option of the grub menu.  To protect yourself from a rubberhose attack, you really need to customize the initramfs so that references to anything mentioning encryption, ciphers, hashing are not explicitly mentioned.  These configurations should be considered an intermediate form for used in debugging purposes.  In addition, the attacker just can inspect grub.cfg files directly.&lt;br /&gt;
&lt;br /&gt;
The following are just examples to just get it working but should be modified so that it doesn&#039;t hint to the rubberhoser of a hidden partition or encrypted partitions.&lt;br /&gt;
&lt;br /&gt;
The entry should look like:&lt;br /&gt;
&lt;br /&gt;
For &#039;luks&#039;&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda1 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda4 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;plain dm-crypt&#039;:&lt;br /&gt;
&lt;br /&gt;
The stock mkinitfs may not support plain dm-crypt.  It looks like it only supports luks.  Customization of the initramfs is required.&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-root rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-rescue rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=rescue&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The source code of grub could possibly be modified and recompiled to use other non-standard keys.  See [https://github.com/lemenkov/grub2/blob/master/grub-core/commands/keystatus.c].  Ideally, it should be not so obvious or accessible for the attacker.&lt;br /&gt;
&lt;br /&gt;
The above grub.cfg is applied to the USB bootloader.  For the facade bootloader, you just want the Windows 10 or Ubuntu entry, nothing more.&lt;br /&gt;
&lt;br /&gt;
For the modules parameter, you need to add your crypto modules.&lt;br /&gt;
Use &amp;lt;code&amp;gt;find /lib/modules/ -name &amp;quot;*aes*&amp;quot;&amp;lt;/code&amp;gt; where aes is the basename for your cipher or hash algorithm&lt;br /&gt;
Use &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt; to obtain the UUID of your device&lt;br /&gt;
&lt;br /&gt;
Install it to your USB thumb drive&lt;br /&gt;
&lt;br /&gt;
  grub-install /dev/sdb&lt;br /&gt;
&lt;br /&gt;
== Home mounting with eCryptfs ==&lt;br /&gt;
&lt;br /&gt;
We use eCryptfs to encrypt home.  The rationale for having another encrypted file system is that if you leave your laptop unattended on break or accidentally leave your USB key in, your data will not be accessible.  The other rationale is that if another person wants to use your computer, you can just log off and the data will be kept hidden and encrypted.  When you log off due to inactivity, your home directory will be unmounted and encrypted.  eCryptfs will encrypt/decrypt the filename and the contents and will sit on top of ext4 which sits on top of luks.&lt;br /&gt;
&lt;br /&gt;
To install ecryptfs-utils:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add ecryptfs-utils&lt;br /&gt;
&lt;br /&gt;
This does one factor authentication mostly with just the password, but it should be modified to use the USB key too.  You need to reconfigure pam with the pam_usb.so which is not in Alpine aports.&lt;br /&gt;
&lt;br /&gt;
You need to use the pam_ecryptfs PAM module.&lt;br /&gt;
&lt;br /&gt;
== Locking it down ==&lt;br /&gt;
&lt;br /&gt;
Many times you will leave your laptop behind with people you trust.  The following tools will help lock down the system.&lt;br /&gt;
&lt;br /&gt;
=== physlock ===&lt;br /&gt;
&lt;br /&gt;
This will auto lock the tty and when you return will prompt for password.&lt;br /&gt;
&lt;br /&gt;
To install physlock:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add physlock&lt;br /&gt;
&lt;br /&gt;
It is currently bugged.  See [https://bugs.alpinelinux.org/issues/3282].  physlock likely doesn&#039;t do two-factor authentication but it should.&lt;br /&gt;
&lt;br /&gt;
You need to create custom script that will monitor idle time in TTY then call physlock.  You load this script when you log on.&lt;br /&gt;
&lt;br /&gt;
=== xscreensaver ===&lt;br /&gt;
&lt;br /&gt;
This will lock you out of xserver&lt;br /&gt;
&lt;br /&gt;
To install xscreensaver:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add xscreensaver&lt;br /&gt;
&lt;br /&gt;
=== USB key udev rule ===&lt;br /&gt;
&lt;br /&gt;
You need to add a new [[udev]] rule that will suspend-to-ram or hibernate and log off once you pull the USB key.  When you come back on, you should do 2 factor authentication to restore back everything.  Hibernation and suspend-to-ram might mitigate cold-boot attack (but unlikely see notes at the bottom of the page) to extract plaintext private data and encryption keys in memory.&lt;br /&gt;
&lt;br /&gt;
To find out the details of your USB do:&lt;br /&gt;
&lt;br /&gt;
  udevadm monitor --udev -p&lt;br /&gt;
&lt;br /&gt;
The output should look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UDEV  [181762.722853] add      /devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc (block)&lt;br /&gt;
ACTION=add&lt;br /&gt;
DEVLINKS=/dev/disk/by-id/usb-Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0 /dev/disk/by-path/pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0 /dev/disk/by-uuid/5A96-03E4&lt;br /&gt;
DEVNAME=/dev/sdc&lt;br /&gt;
DEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc&lt;br /&gt;
DEVTYPE=disk&lt;br /&gt;
ID_BUS=usb&lt;br /&gt;
ID_FS_TYPE=vfat&lt;br /&gt;
ID_FS_USAGE=filesystem&lt;br /&gt;
ID_FS_UUID=5A96-03E4&lt;br /&gt;
ID_FS_UUID_ENC=5A96-03E4&lt;br /&gt;
ID_FS_VERSION=FAT32&lt;br /&gt;
ID_INSTANCE=0:0&lt;br /&gt;
ID_MODEL=MSFT_NORB&lt;br /&gt;
ID_MODEL_ENC=MSFT\x20NORB\x20\x20\x20\x20\x20\x20\x20&lt;br /&gt;
ID_MODEL_ID=1645&lt;br /&gt;
ID_PATH=pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0&lt;br /&gt;
ID_PATH_TAG=pci-0000_00_13_2-usb-0_5_1_0-scsi-0_0_0_0&lt;br /&gt;
ID_REVISION=PMAP&lt;br /&gt;
ID_SERIAL=Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0&lt;br /&gt;
ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&lt;br /&gt;
ID_TYPE=disk&lt;br /&gt;
ID_USB_DRIVER=usb-storage&lt;br /&gt;
ID_USB_INTERFACES=:080650:&lt;br /&gt;
ID_USB_INTERFACE_NUM=00&lt;br /&gt;
ID_VENDOR=Kingston&lt;br /&gt;
ID_VENDOR_ENC=Kingston&lt;br /&gt;
ID_VENDOR_ID=0951&lt;br /&gt;
MAJOR=8&lt;br /&gt;
MINOR=32&lt;br /&gt;
SEQNUM=2027&lt;br /&gt;
SUBSYSTEM=block&lt;br /&gt;
USEC_INITIALIZED=1762722168&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You want to extract the &amp;lt;code&amp;gt;ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&amp;lt;/code&amp;gt; or whatever is associated with your USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
You need pm-utils for ps-suspend.  So to install it do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add pm-utils&lt;br /&gt;
&lt;br /&gt;
You will create a udev rules so that when you pull out the USB, it will suspend-to-ram or you can use your own script.  To do that create a file with the following contents:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/udev/rules.d/50-usb-thumb-drive.rules|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACTION==&amp;quot;remove&amp;quot;, SUBSYSTEM==&amp;quot;usb&amp;quot;, ENV{ID_SERIAL_SHORT}==&amp;quot;MSFTLAKDA300EB3021790009&amp;quot;, RUN+=&amp;quot;/usr/sbin/pm-suspend&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Extending battery life ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING: If you do not use the proper mitigation for cold boot attack, you are better off auto-shutdowning the laptop instead of using suspend or hibernate.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== ACPI ===&lt;br /&gt;
&lt;br /&gt;
ACPI is a good daemon to use to execute certain scripts when laptop events are triggered.&lt;br /&gt;
&lt;br /&gt;
To install ACPI do:&lt;br /&gt;
&lt;br /&gt;
  apk add acpi&lt;br /&gt;
&lt;br /&gt;
The events to pay attention to are:&lt;br /&gt;
&lt;br /&gt;
{|  cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Event&lt;br /&gt;
! ACPI Event&lt;br /&gt;
! What your script should do&lt;br /&gt;
|-&lt;br /&gt;
| lid close&lt;br /&gt;
|&lt;br /&gt;
| log off ttys and suspend-to-ram.  ALSA should either set the volume to 0 for the sound card or the sound driver be unloaded.  It might be a good idea to kill or mute any music or movie players if the sound loops loudly after lid open.&lt;br /&gt;
|-&lt;br /&gt;
| lid open&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and all xservers should be locked, possibly reinitialize ALSA and the sound system.&lt;br /&gt;
|-&lt;br /&gt;
| tapped power button&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and suspend-to-ram&lt;br /&gt;
|-&lt;br /&gt;
| held power button&lt;br /&gt;
|&lt;br /&gt;
| hibernate&lt;br /&gt;
|-&lt;br /&gt;
| unplugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;conservative&#039; cpufreq governor at above 25% power ; &#039;powersave&#039; governor at 25%.  set hdparam spindown rate lower.&lt;br /&gt;
|-&lt;br /&gt;
| plugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;performance&#039; governor.  disable hdparam spindown.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The purpose of the power governor is to regulate the running frequency (GHz) of the processor.&lt;br /&gt;
&lt;br /&gt;
Certain event handlers are are managed through laptop-mode-tools.  If you don&#039;t want the dependency, then you could write ACPI handler scripts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;acpi_listen&amp;lt;/code&amp;gt; can be used to retrieve the event name.&lt;br /&gt;
&lt;br /&gt;
TODO: put scripts below&lt;br /&gt;
&lt;br /&gt;
=== Adjusting the backlight dynamically ===&lt;br /&gt;
&lt;br /&gt;
The backlight may be controlled using sysfs.  The setting is a descendant of &amp;lt;code&amp;gt;/sys/class/backlight/&amp;lt;/code&amp;gt;.  The feature may allow you to echo a value to it.  Use trial and error to discover the values.&lt;br /&gt;
&lt;br /&gt;
The adjustment of the backlight should be function of battery life.  So if it is like 33% battery life, you want to run it near lowest settings but readable.  For 50 percent battery energy maybe 40% light.  For 90% battery maybe 75% light.&lt;br /&gt;
&lt;br /&gt;
=== hdparm ===&lt;br /&gt;
&lt;br /&gt;
To install hdparam do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add hdparm&lt;br /&gt;
&lt;br /&gt;
The settings that laptop-mode-tools messes with is the &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; or the spindown timeout.  It was also hinted that acoustic setting &amp;lt;code&amp;gt;-M&amp;lt;/code&amp;gt; is associated with the speed meaning that louder is faster and quieter is slower which could contribute to the amount of energy used or reduced.&lt;br /&gt;
&lt;br /&gt;
Again you want something like laptop-mode-tools or ACPI to dynamically adjust the settings based on ACPI events.&lt;br /&gt;
&lt;br /&gt;
=== laptop-mode-tools ===&lt;br /&gt;
&lt;br /&gt;
This is currently not in aports but worthy mentioning.  It should really be packaged.  This is a set of scripts to define a power policies.  You can manage all the settings in one place here like the hard drive idle spindown time, CPU governor control, dynamic LCD backlight behavior based on running on battery or AC power supply.&lt;br /&gt;
&lt;br /&gt;
=== cpufreqd ===&lt;br /&gt;
&lt;br /&gt;
This is a useful daemon for regulating power.&lt;br /&gt;
&lt;br /&gt;
To install cpufreqd do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add cpufreqd&lt;br /&gt;
&lt;br /&gt;
Make sure you add the service:&lt;br /&gt;
&lt;br /&gt;
  sudo rc-update add cpufreqd&lt;br /&gt;
&lt;br /&gt;
=== LCD screen refresh rate ===&lt;br /&gt;
&lt;br /&gt;
The refresh rate sets the maximum framerate.  The more frames pushed the more energy consumed on the battery.  You want this adjusted dynamically per certain events.  For gaming, you want it to be the highest as possible for the laptop and vsync off.  For battery use and traveling, you want it capped at 60 FPS/60 Hz or lower but dynamically adjust when you plug in the AC power supply.  You can adjust the framerate with xrandr.  For movies and YouTube, you want 60FPS and vsync on.&lt;br /&gt;
&lt;br /&gt;
== Hacking the kernel ==&lt;br /&gt;
&lt;br /&gt;
You should refer to the [[Custom Kernel]] page for details.&lt;br /&gt;
&lt;br /&gt;
== Hibernation ==&lt;br /&gt;
&lt;br /&gt;
See [[Custom_Kernel#Hibernation_to_prevent_data_loss|Hibernation to prevent data loss]].&lt;br /&gt;
&lt;br /&gt;
== WiFi management ==&lt;br /&gt;
&lt;br /&gt;
Since you are using WiFi, you need a better WiFi management to quickly find open access WiFi access points.  We don&#039;t have all day to debug complexities of WiFi settings while away from home.&lt;br /&gt;
&lt;br /&gt;
To install NetworkManager do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add networkmanager&lt;br /&gt;
&lt;br /&gt;
To find WiFi access points use the &amp;lt;code&amp;gt;nmtui&amp;lt;/code&amp;gt; ncurses interface.&lt;br /&gt;
&lt;br /&gt;
You also need other programs so install them as well:&lt;br /&gt;
&lt;br /&gt;
  apk add wpa-supplicant dhcpcd chrony macchanger wireless-tools iputils&lt;br /&gt;
&lt;br /&gt;
What these programs do:&lt;br /&gt;
&lt;br /&gt;
* wpa-supplicant -- for WPA encryption&lt;br /&gt;
* dhcpcd -- for getting a dynamic IP address&lt;br /&gt;
* chrony -- for fixing the time with the atomic clock&lt;br /&gt;
* wireless-tools -- for additional information&lt;br /&gt;
* macchanger -- for protecting against WiFi access discrimination or increased anonymity.  (optional)&lt;br /&gt;
* iputils -- for the ping command (optional)&lt;br /&gt;
&lt;br /&gt;
You also need to add those services:&lt;br /&gt;
&lt;br /&gt;
  rc-update add chronyd&lt;br /&gt;
  rc-update add wpa_supplicant&lt;br /&gt;
  rc-update add dhcpcd&lt;br /&gt;
  rc-update add networkmanager&lt;br /&gt;
&lt;br /&gt;
To start the services manually (or just reboot):&lt;br /&gt;
&lt;br /&gt;
  rc-service chronyd start&lt;br /&gt;
  rc-service wpa_supplicant start&lt;br /&gt;
  rc-service dhcpcd start&lt;br /&gt;
  rc-service networkmanager start&lt;br /&gt;
&lt;br /&gt;
== Additional tools ==&lt;br /&gt;
&lt;br /&gt;
=== actkbd ===&lt;br /&gt;
&lt;br /&gt;
To control the sound with fn function keys, you need this daemon.  It is currently not in aports.  You could override the design and meaning of those keys with your own scripts and utilities.  This daemon gives you that freedom.&lt;br /&gt;
&lt;br /&gt;
If your laptop contains a brightness key, you want to set that up with this program.  See also [[Setting_up_a_laptop#Adjusting_the_backlight_dynamically | Adjusting the backlight dynamically]].&lt;br /&gt;
&lt;br /&gt;
=== secure-delete ===&lt;br /&gt;
&lt;br /&gt;
Want to prevent cold-boot attack or decrypted keys in memory falling in the wrong hands?  This maybe could work who knows?  From research from cold boot attack, the data can actually stay in memory in minutes, just enough time for a hacker to copy the contents of the memory to a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
To install secure-delete do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add secure-delete&lt;br /&gt;
&lt;br /&gt;
smem only works for unused ram.[https://github.com/gordonrs/thc-secure-delete]  If you use the vanilla kernel, this may work.  If you use grsecurity, it will automatically sanitize memory if you enable it (but not enabled by default in the Alpine hardened kernel) when the memory page is freed.[https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Sanitize_all_freed_memory]&lt;br /&gt;
&lt;br /&gt;
Close all important programs then call smem.&lt;br /&gt;
&lt;br /&gt;
You call smem in your shutdown script or auto-logoff script.&lt;br /&gt;
&lt;br /&gt;
You can call create a OpenRC shutdown script to run smem when most programs and services are closed.  This will erase all your sensitive plaintext private data just in case.&lt;br /&gt;
&lt;br /&gt;
You may want to create a wrapper script to call smem after your program closes.&lt;br /&gt;
&lt;br /&gt;
You need to write a custom script that does the following:&lt;br /&gt;
  * kill all running processes associated with your user account&lt;br /&gt;
  * auto logoff terminals&lt;br /&gt;
  * for the last terminal closed including all idle xservers, unmount your user home&lt;br /&gt;
  * (optional) use smem to wipe all your plaintext private data in memory after all closed programs in case of cold boot attack&lt;br /&gt;
&lt;br /&gt;
=== Sharing presentations over HDMI ===&lt;br /&gt;
&lt;br /&gt;
If you want to use your laptop to share presentation over HDMI connection, you need libxinerama and xrandr.&lt;br /&gt;
&lt;br /&gt;
To install libxinerama and xrandr do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add libxinerama xrandr&lt;br /&gt;
&lt;br /&gt;
== Important notes ==&lt;br /&gt;
&lt;br /&gt;
If you lose or break your USB key, that is it and you cannot decrypt your drive.  It would be wise to make a backup of it.&lt;br /&gt;
&lt;br /&gt;
By default, suspend-to-ram or hibernate will not sufficiently clear the AES encryption keys off ram in those phases which would invite a cold boot attack.  This has been covered by the TRESOR kernel patch.[https://en.wikipedia.org/wiki/TRESOR][https://www1.cs.fau.de/tresor]  This patch hasn&#039;t been updated since the 4.x kernel series.[https://www1.cs.fau.de/tresor].  This patch currently only works on 32-bit x86 Linux with SSE and MMX, and on processors with the AES-NI instruction set for x86_64 Linux.  TRESOR doesn&#039;t work with DMA attack, but it can be mitigated by disabling DMA.[https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.303.3053&amp;amp;rep=rep1&amp;amp;type=pdf]  The 32-bit version of TRESOR has only a key size of 128.  The AES-NI version of TRESOR has a largest key size of 256 bit.  See [[Setting_up_a_laptop#Choosing_ciphers | Choosing ciphers]] for the number of rounds cracked.&lt;br /&gt;
&lt;br /&gt;
Loop-Amnesia works with LoopAES and is only for 64 bit Linux and only supports 128 bit keys but can result in data loss if their recommendations are not followed. [https://moongate.ydns.eu/amnesia.html]&lt;br /&gt;
&lt;br /&gt;
Please read the Wikipedia article on Cold Boot Attack especially the mitigation section.[https://en.wikipedia.org/wiki/Cold_boot_attack] Full disk encryption will not protect your data especially for older hardware if you do not have the proper mitigation (implying not full proof) prerequisites such as a patched kernel, memory scrambling, permanent memory module mounting for example.&lt;br /&gt;
&lt;br /&gt;
If you have a different but fully encrypted device like iPad, you still can be rubberhosed or interrogated with a perfect deniable encrypted laptop.  This guide doesn&#039;t protect you from that possibility.  If you do not want to be rubberhosed, don&#039;t possess those devices.&lt;br /&gt;
&lt;br /&gt;
Additional tips to mitigate against a DMA Attack to exfiltrate encryption keys:&lt;br /&gt;
&lt;br /&gt;
Disable DMA in the BIOS and set the password for the BIOS according to Wikipedia.[https://en.wikipedia.org/wiki/DMA_attack]&lt;br /&gt;
&lt;br /&gt;
Blacklist kernel modules that use DMA and any unused expansion modules (FireWire, CardBus, ExpressCard, Thunderbolt, USB 3.0, PCI Express and hotplug modules) that use DMA.&lt;br /&gt;
&lt;br /&gt;
You may need a custom (or customize a) BIOS or use Intel TXT or TPM which will authenticate the boot devices or boot from specific serial numbers not just any.  For cold boot attack, it is not required to remove the RAM but to to slow down the rate of decay of the RAM module with liquid air in addition an USB thumb drive containing an encryption key retriever bypassing the operating system.[https://youtu.be/XfUlRsE3ymQ]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[category: Desktop]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32060</id>
		<title>Setting up a laptop</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32060"/>
		<updated>2026-02-17T10:03:01Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Choosing ciphers */ grammar, duplicate &amp;quot;already&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide is about a project to create a &#039;&#039;&#039;secured laptop&#039;&#039;&#039;.  For this project we take in consideration ways to extend battery life.  It covers tools and daemons that are must haves for a laptop setup.&lt;br /&gt;
{{Todo|Instructions given in the page needs testing. Please help test section by section or the entire page. If individual sections have been tested, please update the Talkpage or please move/place this notice in the untested section(s) alone.}}&lt;br /&gt;
&lt;br /&gt;
== Guide features ==&lt;br /&gt;
&lt;br /&gt;
*Deniable full disk encryption&lt;br /&gt;
*Two factor authentication (physical object (USB key), mind) &lt;br /&gt;
*Encrypted swap and hibernation&lt;br /&gt;
*Encrypted home on top of encrypted drive&lt;br /&gt;
*Memory sanitation&lt;br /&gt;
*Dynamic power modes&lt;br /&gt;
*Feature keys support&lt;br /&gt;
&lt;br /&gt;
== Rubberhose Attack ==&lt;br /&gt;
&lt;br /&gt;
Just a reminder that all attacks are subjected to the Rubberhose Attack dilemma, you either give up your encryption keys or be tortured with a rubberhose with the possibly of death.  See [https://en.wikipedia.org/wiki/Rubber-hose_cryptanalysis Wikipedia article].  We try to present [https://en.wikipedia.org/wiki/Deniable_encryption  deniable encryption (Wikipedia)] to avoid a rubberhose attack scenario.  In this article we use the words plausible deniability interchangeably with deniable encryption.  To achieve this we use a facade and require no metadata fingerprints to expose or hint of encrypted or hidden containers or hint as in detect of existence of an encrypted disk.  The keys should be stored using steganography where we dilute the randomness into the facade.  It also requires you not to brag about encryption or mention it because that is an invitation for the attacker to torture the victim.  Deniable encryption requires you not put encrypted as an entry title to your bootloader.  There shouldn&#039;t be an entry for your facade bootloader to the encrypted drive.&lt;br /&gt;
&lt;br /&gt;
== Why full disk? ==&lt;br /&gt;
&lt;br /&gt;
The full disk encryption provides sort of some plausible deniability or a valid alibi that you didn&#039;t encrypt it.  Is the drive just random noise, broken, or is it really encrypted?  The other reason is that it implies that everything is protected.&lt;br /&gt;
&lt;br /&gt;
But there could be problems if not done right.  For example, cryptsetup does leave a plaintext marking or some hints by default that it has been encrypted when using luks/luks2 mode if a detached header with option &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is not presented.[https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/][https://man7.org/linux/man-pages/man8/cryptsetup.8.html]  To gain credibility that we didn&#039;t really do the encryption, you have to wipe the +3 MiB region based on the number of key slots used; or store the headers on an external device.&lt;br /&gt;
&lt;br /&gt;
If you did deniable encryption incorrectly, it is possible to erase and restore the header.  This presents an opportunity to improve obfuscation.  When you pull out the USB key, it should erase the header but store it on the USB key atomically as in completely.  If you plug in the USB key, it will restore back the header.  cryptsetup has luks actions luksHeaderBackup and luksHeaderRestore to do this.&lt;br /&gt;
&lt;br /&gt;
== Starting at the beginning ==&lt;br /&gt;
&lt;br /&gt;
Grab a USB thumb drive with Alpine.  Set it up as usual but don&#039;t let it touch your drive yet.  Then, install all the tools into memory ramdisk but not in the hard drive yet.  The hard drive will be obliterated.&lt;br /&gt;
&lt;br /&gt;
You will then install Alpine using the steps:&lt;br /&gt;
&lt;br /&gt;
First you need WiFi, to get it run do the command below but say no or skip  the hard drive setup stuff:&lt;br /&gt;
&lt;br /&gt;
  setup-alpine&lt;br /&gt;
&lt;br /&gt;
Then, you need to install some tools into RAM temporarly:&lt;br /&gt;
  apk add e2fsprogs grub grub-bios grub-efi mkinitfs nano&lt;br /&gt;
&lt;br /&gt;
== Randomizing the drive with pseudorandom urandom entropy ==&lt;br /&gt;
&lt;br /&gt;
The first part is to erase the drive with random noise but in practical time.  There are many techniques to do this but should be done in one day or two minimum.&lt;br /&gt;
&lt;br /&gt;
You can use shred or dd to accomplish this depending on your needs and the availability of entropy.  Some techniques take longer.  Cryptologist Bruce Schneier recommended 7 times with specified pattern.  See [https://en.wikipedia.org/wiki/Data_erasure Wikipedia Article].  For practical purposes, we just do it random in one pass.  It should be random so that the facade of random noise hides the encrypted data which resembles noise.&lt;br /&gt;
&lt;br /&gt;
To list the drives on the system do &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: make sure you wipe the right specific drive.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To wipe the disk with random entropy do:&lt;br /&gt;
&lt;br /&gt;
  dd if=/dev/urandom of=/dev/sda&lt;br /&gt;
&lt;br /&gt;
== Creating GPG keys ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;As of this time, Alpine&#039;s mkinitfs does only one factor authentication with passphrase.&#039;&#039;&#039; You need to manually edit the initramfs-init.in in mkinitfs to support two factor authentication using cryptsetup.&lt;br /&gt;
&lt;br /&gt;
After you have scrambled the drive, you want to create your GPG keys.  You will use these keys to set the password(s) for your cryptsetup-luks partitions.  These keys should be stored on a USB thumb drive or other memory device but should not be on the USB boot thumb drive or on the encrypted drive.  The key should be a random 128 bit key wrapped in GPG and protected with a password.&lt;br /&gt;
&lt;br /&gt;
If you are using x, you need to do &amp;lt;code&amp;gt;sudo apk add pinentry-gtk&amp;lt;/code&amp;gt; to display password prompt properly for the next step.&lt;br /&gt;
&lt;br /&gt;
To install openssl and gpg do:&lt;br /&gt;
&lt;br /&gt;
  apk add openssl gnupg&lt;br /&gt;
&lt;br /&gt;
Then, to generate a key:&lt;br /&gt;
&lt;br /&gt;
  export GPG_TTY=$(tty) &amp;amp;&amp;amp; openssl rand -base64 512 | gpg --symmetric --cipher-algo aes --armor &amp;gt; /mnt/usb/$(openssl rand -hex 12)&lt;br /&gt;
&lt;br /&gt;
(Make sure your usb is mounted on /mnt/usb first.)&lt;br /&gt;
&lt;br /&gt;
The long file name comes from &amp;lt;code&amp;gt;openssl rand -hex 12&amp;lt;/code&amp;gt; so that we enhance plausible deniability.  The attacker cannot determine the purpose of the key.  Is it used for GitHub? for Email?&lt;br /&gt;
&lt;br /&gt;
The first part will produce 512 random bytes in wrap it in base64.  The random data will be piped to gpg which will wrap it in AES as ciphertext which again gets wrapped in base64 ascii armor.  For every partition including swap in some cases, you should create more gpg keys and store them in your USB thumb drives.  After you have produced your gpg keys, you will then use them as a password for cryptsetup/luks.&lt;br /&gt;
&lt;br /&gt;
You can replace aes above with the ones listed in &amp;lt;code&amp;gt;gpg --version&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There should be a password generated for the swap.  This is to resume for your hibernate.  If you don&#039;t want to hibernate, then password is not required and all you need to do is to create/format the partition each time you boot without a password or with a one time random password.&lt;br /&gt;
&lt;br /&gt;
== Hiding the keys using steganography ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;WARNING:&#039;&#039; This section is considered experimental.  It requires the tool and the dependencies to be placed on another USB separate from the key files, the bootloaders, and encrypted disks.  The tool and dependencies need to be packaged together.  We decentralize these components so that the attacker doesn&#039;t connect the dots easily or immediately jumps to the conclusion for the requirements to decrypt.  Steghide automatically uses 128-bit AES in CBC mode to encrypt data.  This can be change if you don&#039;t like or trust AES with the -e option.  Use &amp;lt;code&amp;gt;steghide encinfo&amp;lt;/code&amp;gt; for other ciphers and modes.&lt;br /&gt;
&lt;br /&gt;
Fortunately, Alpine has a package for steganography called steghide (in the optional edge/testing repository as of February 2026). To install steghide do:&lt;br /&gt;
&lt;br /&gt;
  echo &amp;quot;http://dl-cdn.alpinelinux.org/alpine/edge/testing&amp;quot; &amp;gt;&amp;gt; /etc/apk/repositories&lt;br /&gt;
  apk add steghide&lt;br /&gt;
&lt;br /&gt;
You will place the keyfile in an image file.  The facade image file should be large enough that there is no apparent discernible difference between the original and the modified.  Do not use a small image with a small filesize.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously luks headers could be 3MB large or more and an jpeg image file is not suitable.  Use another format like .au/.wav or another steganography utility that handles mp3s.  The mp3/wav should be fairly large enough to dilute the header.  So, something with long content is suitable.&lt;br /&gt;
&lt;br /&gt;
There are two basic commands to use with steghide embed and extract,&lt;br /&gt;
&lt;br /&gt;
To embed do:&lt;br /&gt;
&lt;br /&gt;
  steghide embed -ef key.gpg -cf image.jpg&lt;br /&gt;
&lt;br /&gt;
To extract do:&lt;br /&gt;
&lt;br /&gt;
  steghide extract -xf key.gpg -sf image.jpg&lt;br /&gt;
&lt;br /&gt;
To get a file list of files to ship out, use:&lt;br /&gt;
&lt;br /&gt;
  apk info -L libgcc libmcrypt libmhash libstdc++ libjpeg-turbo steghide&lt;br /&gt;
&lt;br /&gt;
== Full disk encryption with with cryptsetup-luks volumes ==&lt;br /&gt;
&lt;br /&gt;
=== Partitioning scheme ===&lt;br /&gt;
&lt;br /&gt;
This section presents a conceptual layout.  It should not be a knee-jerk approval to automatically use the partition tool which would compromise your plausible deniability.&lt;br /&gt;
&lt;br /&gt;
For the facade, we use an Ubuntu Live CD (or less skilled distro) to present the impression that we are not sophisticated or tech savvy enough to implement encryption.  Windows is also acceptable even better.  The immutable Live CD and immutable partition ensures that you are not compromised by a third party attacker that implants evidence.&lt;br /&gt;
&lt;br /&gt;
There could be possibly two bootloaders, one for the facade and the other to the encrypted drive stored on an external device.&lt;br /&gt;
&lt;br /&gt;
==== Luks ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you can demonstrate no existence of partitions 2, 3, 4 and no fingerprints/plaintext introduced by cfdisk and cryptsetup-luks.  Use something like TestDisk, fdisk -l, or gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| root&lt;br /&gt;
| /&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Plain dm-crypt ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you are able to present #2 as being unused space or untampered.  To check use something like TestDisk, gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| vgroot&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_1&lt;br /&gt;
| vgroot-root&lt;br /&gt;
| /&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_2&lt;br /&gt;
| vgroot-swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 2_3&lt;br /&gt;
| vgroot-rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Installing cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
To install cryptsetup you need the package below&lt;br /&gt;
&lt;br /&gt;
  apk add cryptsetup&lt;br /&gt;
&lt;br /&gt;
=== Choosing ciphers ===&lt;br /&gt;
&lt;br /&gt;
When you create your luks drives, you need to decide on the type of ciphers and hashing techniques to use.  The ciphers that you want to use are ones are up to you, but it should be one that is hasn&#039;t been cracked yet or has not suffered a lot of cryptanalysis attacks.  The ones that you might want to use is AES which is hardware accelerated in some Intel CPUs that have the AES-NI cpuflag which you can check by &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt;.  Also consider the ciphers that are SIMD optimized such as serpent and twofish that are available in the Linux kernel.  Also consider ciphers that are unpopular but known to be secure such as Blowfish (which Wikipedia claims to be attacked and the author recommended Twofish).[https://en.wikipedia.org/wiki/Cipher_security_summary]  If it is hardware accelerated, it will save battery life and minimize CPU usage.&lt;br /&gt;
&lt;br /&gt;
For some ciphers weakness also see [https://en.wikipedia.org/wiki/Cipher_security_summary Cipher security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
For some hash function weaknesses also see [https://en.wikipedia.org/wiki/Hash_function_security_summary Hash function security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
Generally speaking, the swap partition should use a fast cipher.  You want to lower the latency or delay of the memory subsystem as a consequence of being encrypted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; Please read the [[Setting_up_a_laptop#Important_notes | Important notes]] section for details about the problems with AES encryption.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t trust AES shills and it&#039;s NSA endorsement, you can try another different one.  Another advantage of using a public vetted cipher is that it provides confidence that it works.&lt;br /&gt;
&lt;br /&gt;
Something like KHAZAD wouldn&#039;t work on &amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt;.  KHAZAD itself is insecure.  Wikipedia reported 5 out of 8 rounds been cracked.[https://en.wikipedia.org/wiki/KHAZAD]&lt;br /&gt;
&lt;br /&gt;
For AES-128 7 out of 10, AES-192 8 out of 12, AES-256-bit 9 out 14 rounds have been cracked according to Wikipedia.[https://en.wikipedia.org/wiki/Advanced_Encryption_Standard]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: Do not use sha1 as the hashing algorithm.&#039;&#039;&#039;  It already has been compromised.&lt;br /&gt;
&lt;br /&gt;
=== Getting the available ciphers ===&lt;br /&gt;
&lt;br /&gt;
To check the availability of a cipher or hash function use:&lt;br /&gt;
  find $(find /lib/modules -name &amp;quot;crypto&amp;quot; -type d) -type f -name &amp;quot;*.ko&amp;quot; | sort&lt;br /&gt;
&lt;br /&gt;
To check if a cipher is loaded and passed its own tests use:&lt;br /&gt;
  cat /proc/crypto&lt;br /&gt;
&lt;br /&gt;
To test some popular ciphers and hashes do:&lt;br /&gt;
&lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
&lt;br /&gt;
The top set is associated with the hashing algorithms.  The bottom set are the ciphers.  Use the commands below but replace the cipher and/or hash algorithm with your preferences.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt; actually doesn&#039;t show all the ciphers like Anubis.  The cipher should also have CBC and/or XTS block cipher mode of operation to encrypt larger block sizes.  AES for example has a block size of 128.  &lt;br /&gt;
&lt;br /&gt;
To test if the unpopular but uncracked cipher works use sometime like:&lt;br /&gt;
  cryptsetup benchmark --cipher anubis&lt;br /&gt;
&lt;br /&gt;
=== General steps for cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
==== Original method with fdisk with no plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
In this method &amp;lt;code&amp;gt;--type luks&amp;lt;/code&amp;gt; is implied which generates metadata.&lt;br /&gt;
&lt;br /&gt;
If you want plausible deniability for luks, you need to pass &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; to all the luks commands, where &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is a unix path like /mnt/usb/d6ae10eda66704c8.  The random name comes from &amp;lt;code&amp;gt;openssl rand -hex 8&amp;lt;/code&amp;gt;.  The header is transferred to the external device (but no mention of the key slot area but ciphertext being transferred) in the man page.  The information in that file should be obfuscated with encryption if there is plaintext or fingerprint in it just in case. Then, it should be decrypted when reused.&lt;br /&gt;
&lt;br /&gt;
You need to install cfdisk if you prefer the interactive ncurses console method:&lt;br /&gt;
&lt;br /&gt;
  apk add cfdisk&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Use cfdisk to create partitions.  Make two partitions--a system partition and a swap partition&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cfdisk&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Create and format the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --cipher aes-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sda1 /mnt/usb/$(ls)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Open the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --key-file /mnt/usb/$(ls) luksOpen /dev/sda1 root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Format the decrypted drive with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Create the mount point&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Mount the root partition&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Create swap&lt;br /&gt;
| cryptsetup -c blowfish -h sha256 -d /dev/urandom --key-file /mnt/usb/59022506d9f4a714 create swap /dev/sda2 &lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Use swap&lt;br /&gt;
| mkswap /dev/mapper/swap &amp;amp;&amp;amp; swapon /dev/mapper/swap&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Improved method with plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
This method requires lvm2.  To install:&lt;br /&gt;
&lt;br /&gt;
  apk add lvm2&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Open the &#039;&#039;plain dm-crypt&#039;&#039; device generating no metadata&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Physical volume create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;pvcreate /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Volume group create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;vgcreate vgroot /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Logical volume create the swap volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 4G vgroot -n swap&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Logical volume create the root volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 2T vgroot -n root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Logical volume create the rescue volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 110M vgroot -n rescue&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Format the root volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Format the swap volume and activate it&lt;br /&gt;
| &amp;lt;code&amp;gt;mkswap /dev/mapper/vgroot-swap &amp;amp;&amp;amp; swapon /dev/mapper/vgroot-swap&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Format the rescue volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-rescue&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Create mount point for root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| Mount the root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/vgroot-root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Configuring OpenRC dmcrypt and setting up fstab ===&lt;br /&gt;
&lt;br /&gt;
You need to tell OpenRC init scripts to decrypt the volumes.  See &amp;lt;code&amp;gt;/etc/conf.d/dmcrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You need to add the service to boot well because it needs to decrypt the root volume before OpenRC starts running commands from it.  So you need to do:&lt;br /&gt;
&lt;br /&gt;
  rc-update add dmcrypt boot&lt;br /&gt;
&lt;br /&gt;
==== dmcrypt ====&lt;br /&gt;
The dmcrypt OpenRC service will attempt to decrypt the drive using information provided in &#039;&#039;/etc/conf.d/dmcrypt&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root may not be necessary since it is already mounted.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda1&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root is likely not required since you already mounted it before OpenRC starts to do its thing.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
  options=&#039;--type plain --cipher aes-cbc-essiv:sha256 --key-size 256&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
  pre_mount=&#039;vgchange -ay vgroot ; lvchange -ay vgroot/swap&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
dm-crypt will just mount the encrypted &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; partition.  What you need to do next is set up fstab located at /etc/fstab.  Examples are shown below.&lt;br /&gt;
&lt;br /&gt;
==== /etc/fstab ====&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;plain dm-crypt&#039;&#039; device with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/root          /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/swap          none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;lvm&#039;&#039; volumes with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/vgroot-root   /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/vgroot-swap   none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How to recover from a bad setup ===&lt;br /&gt;
&lt;br /&gt;
Many times you will not get it right perfectly the first try.  To recover from this situation, you need to reopen the &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; drive and then remount everything back.&lt;br /&gt;
&lt;br /&gt;
To recover from &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
  cryptsetup --key-file /mnt/usb/2a667ec72774b0d5 luksOpen /dev/sda1 root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/root /mnt/root&lt;br /&gt;
&lt;br /&gt;
To recover from the &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
  cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda root&lt;br /&gt;
  vgchange -ay vgroot&lt;br /&gt;
  lvchange -ay vgroot/root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/vgroot-swap /mnt/root&lt;br /&gt;
&lt;br /&gt;
== Next step: Full blown Alpine installation ==&lt;br /&gt;
&lt;br /&gt;
We will setup the /mnt/root encrypted partition:&lt;br /&gt;
  apk add --root=/mnt/root --initdb $(cat /etc/apk/world) --keys-dir /etc/apk/keys --repositories-file /etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, enable edge repositories in both files including community and testing:&lt;br /&gt;
  nano /etc/apk/repositories /mnt/root/etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, copy the necessary files:&lt;br /&gt;
  cp /etc/resolv.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, install the basic utils:&lt;br /&gt;
  apk add --root=/mnt/root dhcpcd chrony networkmanager wireless-tools wpa_supplicant&lt;br /&gt;
  apk add --root=/mnt/root grub mkinitfs e2fsprogs grub-bios grub-efi&lt;br /&gt;
  apk add --root=/mnt/root sudo nano&lt;br /&gt;
  apk add --root=/mnt/root linux-lts&lt;br /&gt;
&lt;br /&gt;
Then, you need to mount your usb on to /boot:&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Edit grub:&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
Then, install grub on the usb:&lt;br /&gt;
  grub-install --force /dev/sdb&lt;br /&gt;
&lt;br /&gt;
Then, prepare chroot:&lt;br /&gt;
  mount --bind /dev /mnt/root/dev&lt;br /&gt;
  mount --bind /sys /mnt/root/sys&lt;br /&gt;
  cp /etc/reslov.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, chroot:&lt;br /&gt;
  chroot /mnt/root /bin/sh&lt;br /&gt;
&lt;br /&gt;
Set the root administrator password:&lt;br /&gt;
  passwd&lt;br /&gt;
&lt;br /&gt;
The root password should be very difficult to deter you from using it and force you to use sudo&lt;br /&gt;
&lt;br /&gt;
Edit sudo so that wheel group has administrative :&lt;br /&gt;
  EDITOR=nano visudo&lt;br /&gt;
&lt;br /&gt;
Set:&lt;br /&gt;
  ## Uncomment to allow members of group wheel to execute any command       &lt;br /&gt;
  %wheel ALL=(ALL) ALL                                                 &lt;br /&gt;
&lt;br /&gt;
Then, add wheel (administrator) user:&lt;br /&gt;
  useradd -m myname&lt;br /&gt;
  usermod -a -G video,audio,wheel myname&lt;br /&gt;
&lt;br /&gt;
log in that user:&lt;br /&gt;
  su myname&lt;br /&gt;
&lt;br /&gt;
Then, update and upgrade it&lt;br /&gt;
  sudo apk update&lt;br /&gt;
  sudo apk upgrade&lt;br /&gt;
&lt;br /&gt;
Then, setup xorg:&lt;br /&gt;
  sudo setup-xorg-base&lt;br /&gt;
  sudo apk search xf86-video | sort&lt;br /&gt;
  # pick your xf86 video driver&lt;br /&gt;
  sudo apk add xf86-video-amdgpu&lt;br /&gt;
  # install the mesa driver&lt;br /&gt;
  sudo apk add mesa-dri-gallium  &lt;br /&gt;
&lt;br /&gt;
Then, keep piling on:&lt;br /&gt;
  sudo apk add firefox dwm xfce4-terminal alsa-utils keepassx xfce4 xchat&lt;br /&gt;
  sudo apk add font-noto-emoji font-terminus leafpad xsetroot # See [[Emojis]] to complete installation&lt;br /&gt;
  sudo apk add xf86-input-libinput # or -evdev if libinput doesn&#039;t work&lt;br /&gt;
&lt;br /&gt;
Then, set the desktop:&lt;br /&gt;
  nano .xinitrc&lt;br /&gt;
&lt;br /&gt;
Put both but comment with a # one of them if you don&#039;t want it,&lt;br /&gt;
  #while true; do xsetroot -name &amp;quot;$( date +&amp;quot;%a %b %d %I:%M:%S %Y&amp;quot; )&amp;quot; ; sleep 1; done &amp;amp;&lt;br /&gt;
  #exec dwm&lt;br /&gt;
  exec xfce4-session&lt;br /&gt;
&lt;br /&gt;
For the above xsetroot statement used to provide information in the statusbar for dwm, consider adding information about the battery level.  This information can be found in sysfs at /sys/class/power_supply/BAT0/.&lt;br /&gt;
&lt;br /&gt;
  sync&lt;br /&gt;
  sudo reboot&lt;br /&gt;
&lt;br /&gt;
== Hacking mkinitfs to support cryptsetup with GPG keys ==&lt;br /&gt;
&lt;br /&gt;
This section describes how to assemble a custom initscript chain in multiple parts.  It could be extended with three-factor authentication which adds biometrics along side with mind and physical object.&lt;br /&gt;
&lt;br /&gt;
Most entry to secure systems are not fully automated or do not allow things to quickly pass through freely and often guarded.  This process may seem like a hassle, but it should dissuade the rubberhosers from jumping to the conclusion of the possibility of the existence of a encrypted drive.&lt;br /&gt;
&lt;br /&gt;
Here is the steps required so that the facade initscripts and dependencies are free from encryption.&lt;br /&gt;
* You will separate and archive cryptsetup, ciphers kernel modules, hash function kernel modules, and any additional obfuscation dependencies, and another continuation initscript discussed below.  You need to make sure that you copy /etc/mkinitfs/mkinitfs.conf to your home directory and strip out those features without those modules.&lt;br /&gt;
* You will hide this archive in a mp3 file with another tool you will package or you can use steghide&#039;s .au/.wav support, but .au seems too conspicuous or strange by current trends.&lt;br /&gt;
&lt;br /&gt;
Here we try to clean up the facade so that it presents itself as free without cryptography.  You need the following changes to your initramfs to avoid a sensitive rubberhoser:&lt;br /&gt;
* You will delete everything in the custom initramfs-init referring to encryption.  This includes cryptroot, cryptdm, crypt-anything, etc init options.&lt;br /&gt;
* You need to delete references in nlplug-findfs to cryptsetup and recompile the mkinitfs package.&lt;br /&gt;
* You could program the init script to boot into a facade partition but drop into sh if a hidden special keypress sequence is met.&lt;br /&gt;
&lt;br /&gt;
You need to create a custom init continuation script:&lt;br /&gt;
* Your initscript should drop into single mode which you will mount the encrypted path manually. &lt;br /&gt;
* You will manually steg-unhide the encrypted archive hidden in the mp3 file and extract it to the ramdisk.&lt;br /&gt;
* You will run the custom init continuation script manually.&lt;br /&gt;
* This custom init continuation will automate the process of extracting the gpg keys from another device and image files into the ramdisk.  This will then automate the mounting of the encrypted drive.  This resume continuation script should handle both cold boot and hibernate.&lt;br /&gt;
* You will finish resuming running the other half of mkinitfs-init or specifically where the points after where it typically will mount cryptsetup and hibernate devices.&lt;br /&gt;
&lt;br /&gt;
If you use a USB keyboard, you will unlock the encrypted devices in early userspace. You will need to either compile the USB keyboard drivers in the kernel or you need to add additional modules when generating the mkinitfs.  You will need the hid, hid-generic, ehci-hcd, uhci-hcd, usbcore driver and add those paths in a customized &amp;lt;code&amp;gt;/etc/mkinitfs/features.d/usb-keyboard.modules&amp;lt;/code&amp;gt;.  It should be separate from usb.modules because apk updates may overwrite it.  Use the &amp;lt;code&amp;gt;lsmod&amp;lt;/code&amp;gt; utility from the kmod package to find what drivers your USB keyboard uses.&lt;br /&gt;
&lt;br /&gt;
You need to generate the final mkinitfs.&lt;br /&gt;
First you need the kernelversion to pass into mkinitfs.  To obtain that information do &amp;lt;code&amp;gt;ls /lib/modules&amp;lt;/code&amp;gt; which will show some folders.  Once you found it pass it to mkinitrafs by doing and replacing kernelversion below:&lt;br /&gt;
&lt;br /&gt;
  sudo mkinitramfs -i $HOMEDIR/initramfs-init -c &amp;quot;$HOMEDIR&amp;quot;/mkinitfs.conf kernelversion&lt;br /&gt;
&lt;br /&gt;
The $HOMEDIR should be replaced with the full path if you are not root.&lt;br /&gt;
&lt;br /&gt;
==  Install the bootloader in the USB thumb drive ==&lt;br /&gt;
&lt;br /&gt;
To install grub, you need to install grub on the ramdisk first on the host.  &lt;br /&gt;
&lt;br /&gt;
  apk add grub&lt;br /&gt;
&lt;br /&gt;
To get a list of partitions&lt;br /&gt;
&lt;br /&gt;
  fdisk -l&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition in /boot&lt;br /&gt;
&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Make changes to grub&#039;s configuration &lt;br /&gt;
&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You need to customize the initramfs in order to use GPG keys since there is no support from it.&#039;&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
The steps here below assumes that these custom initramfs features have been implemented.  &lt;br /&gt;
&lt;br /&gt;
The following boot loader settings is &#039;&#039;&#039;not sufficient&#039;&#039;&#039; for deniable encryption because it exposes the fact that an encrypted drive exists because an attacker can discover that encryption was used through the edit option of the grub menu.  To protect yourself from a rubberhose attack, you really need to customize the initramfs so that references to anything mentioning encryption, ciphers, hashing are not explicitly mentioned.  These configurations should be considered an intermediate form for used in debugging purposes.  In addition, the attacker just can inspect grub.cfg files directly.&lt;br /&gt;
&lt;br /&gt;
The following are just examples to just get it working but should be modified so that it doesn&#039;t hint to the rubberhoser of a hidden partition or encrypted partitions.&lt;br /&gt;
&lt;br /&gt;
The entry should look like:&lt;br /&gt;
&lt;br /&gt;
For &#039;luks&#039;&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda1 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda4 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;plain dm-crypt&#039;:&lt;br /&gt;
&lt;br /&gt;
The stock mkinitfs may not support plain dm-crypt.  It looks like it only supports luks.  Customization of the initramfs is required.&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-root rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-rescue rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=rescue&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The source code of grub could possibly be modified and recompiled to use other non-standard keys.  See [https://github.com/lemenkov/grub2/blob/master/grub-core/commands/keystatus.c].  Ideally, it should be not so obvious or accessible for the attacker.&lt;br /&gt;
&lt;br /&gt;
The above grub.cfg is applied to the USB bootloader.  For the facade bootloader, you just want the Windows 10 or Ubuntu entry, nothing more.&lt;br /&gt;
&lt;br /&gt;
For the modules parameter, you need to add your crypto modules.&lt;br /&gt;
Use &amp;lt;code&amp;gt;find /lib/modules/ -name &amp;quot;*aes*&amp;quot;&amp;lt;/code&amp;gt; where aes is the basename for your cipher or hash algorithm&lt;br /&gt;
Use &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt; to obtain the UUID of your device&lt;br /&gt;
&lt;br /&gt;
Install it to your USB thumb drive&lt;br /&gt;
&lt;br /&gt;
  grub-install /dev/sdb&lt;br /&gt;
&lt;br /&gt;
== Home mounting with eCryptfs ==&lt;br /&gt;
&lt;br /&gt;
We use eCryptfs to encrypt home.  The rationale for having another encrypted file system is that if you leave your laptop unattended on break or accidentally leave your USB key in, your data will not be accessible.  The other rationale is that if another person wants to use your computer, you can just log off and the data will be kept hidden and encrypted.  When you log off due to inactivity, your home directory will be unmounted and encrypted.  eCryptfs will encrypt/decrypt the filename and the contents and will sit on top of ext4 which sits on top of luks.&lt;br /&gt;
&lt;br /&gt;
To install ecryptfs-utils:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add ecryptfs-utils&lt;br /&gt;
&lt;br /&gt;
This does one factor authentication mostly with just the password, but it should be modified to use the USB key too.  You need to reconfigure pam with the pam_usb.so which is not in Alpine aports.&lt;br /&gt;
&lt;br /&gt;
You need to use the pam_ecryptfs PAM module.&lt;br /&gt;
&lt;br /&gt;
== Locking it down ==&lt;br /&gt;
&lt;br /&gt;
Many times you will leave your laptop behind with people you trust.  The following tools will help lock down the system.&lt;br /&gt;
&lt;br /&gt;
=== physlock ===&lt;br /&gt;
&lt;br /&gt;
This will auto lock the tty and when you return will prompt for password.&lt;br /&gt;
&lt;br /&gt;
To install physlock:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add physlock&lt;br /&gt;
&lt;br /&gt;
It is currently bugged.  See [https://bugs.alpinelinux.org/issues/3282].  physlock likely doesn&#039;t do two-factor authentication but it should.&lt;br /&gt;
&lt;br /&gt;
You need to create custom script that will monitor idle time in TTY then call physlock.  You load this script when you log on.&lt;br /&gt;
&lt;br /&gt;
=== xscreensaver ===&lt;br /&gt;
&lt;br /&gt;
This will lock you out of xserver&lt;br /&gt;
&lt;br /&gt;
To install xscreensaver:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add xscreensaver&lt;br /&gt;
&lt;br /&gt;
=== USB key udev rule ===&lt;br /&gt;
&lt;br /&gt;
You need to add a new [[udev]] rule that will suspend-to-ram or hibernate and log off once you pull the USB key.  When you come back on, you should do 2 factor authentication to restore back everything.  Hibernation and suspend-to-ram might mitigate cold-boot attack (but unlikely see notes at the bottom of the page) to extract plaintext private data and encryption keys in memory.&lt;br /&gt;
&lt;br /&gt;
To find out the details of your USB do:&lt;br /&gt;
&lt;br /&gt;
  udevadm monitor --udev -p&lt;br /&gt;
&lt;br /&gt;
The output should look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UDEV  [181762.722853] add      /devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc (block)&lt;br /&gt;
ACTION=add&lt;br /&gt;
DEVLINKS=/dev/disk/by-id/usb-Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0 /dev/disk/by-path/pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0 /dev/disk/by-uuid/5A96-03E4&lt;br /&gt;
DEVNAME=/dev/sdc&lt;br /&gt;
DEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc&lt;br /&gt;
DEVTYPE=disk&lt;br /&gt;
ID_BUS=usb&lt;br /&gt;
ID_FS_TYPE=vfat&lt;br /&gt;
ID_FS_USAGE=filesystem&lt;br /&gt;
ID_FS_UUID=5A96-03E4&lt;br /&gt;
ID_FS_UUID_ENC=5A96-03E4&lt;br /&gt;
ID_FS_VERSION=FAT32&lt;br /&gt;
ID_INSTANCE=0:0&lt;br /&gt;
ID_MODEL=MSFT_NORB&lt;br /&gt;
ID_MODEL_ENC=MSFT\x20NORB\x20\x20\x20\x20\x20\x20\x20&lt;br /&gt;
ID_MODEL_ID=1645&lt;br /&gt;
ID_PATH=pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0&lt;br /&gt;
ID_PATH_TAG=pci-0000_00_13_2-usb-0_5_1_0-scsi-0_0_0_0&lt;br /&gt;
ID_REVISION=PMAP&lt;br /&gt;
ID_SERIAL=Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0&lt;br /&gt;
ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&lt;br /&gt;
ID_TYPE=disk&lt;br /&gt;
ID_USB_DRIVER=usb-storage&lt;br /&gt;
ID_USB_INTERFACES=:080650:&lt;br /&gt;
ID_USB_INTERFACE_NUM=00&lt;br /&gt;
ID_VENDOR=Kingston&lt;br /&gt;
ID_VENDOR_ENC=Kingston&lt;br /&gt;
ID_VENDOR_ID=0951&lt;br /&gt;
MAJOR=8&lt;br /&gt;
MINOR=32&lt;br /&gt;
SEQNUM=2027&lt;br /&gt;
SUBSYSTEM=block&lt;br /&gt;
USEC_INITIALIZED=1762722168&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You want to extract the &amp;lt;code&amp;gt;ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&amp;lt;/code&amp;gt; or whatever is associated with your USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
You need pm-utils for ps-suspend.  So to install it do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add pm-utils&lt;br /&gt;
&lt;br /&gt;
You will create a udev rules so that when you pull out the USB, it will suspend-to-ram or you can use your own script.  To do that create a file with the following contents:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/udev/rules.d/50-usb-thumb-drive.rules|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACTION==&amp;quot;remove&amp;quot;, SUBSYSTEM==&amp;quot;usb&amp;quot;, ENV{ID_SERIAL_SHORT}==&amp;quot;MSFTLAKDA300EB3021790009&amp;quot;, RUN+=&amp;quot;/usr/sbin/pm-suspend&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Extending battery life ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING: If you do not use the proper mitigation for cold boot attack, you are better off auto-shutdowning the laptop instead of using suspend or hibernate.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== ACPI ===&lt;br /&gt;
&lt;br /&gt;
ACPI is a good daemon to use to execute certain scripts when laptop events are triggered.&lt;br /&gt;
&lt;br /&gt;
To install ACPI do:&lt;br /&gt;
&lt;br /&gt;
  apk add acpi&lt;br /&gt;
&lt;br /&gt;
The events to pay attention to are:&lt;br /&gt;
&lt;br /&gt;
{|  cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Event&lt;br /&gt;
! ACPI Event&lt;br /&gt;
! What your script should do&lt;br /&gt;
|-&lt;br /&gt;
| lid close&lt;br /&gt;
|&lt;br /&gt;
| log off ttys and suspend-to-ram.  ALSA should either set the volume to 0 for the sound card or the sound driver be unloaded.  It might be a good idea to kill or mute any music or movie players if the sound loops loudly after lid open.&lt;br /&gt;
|-&lt;br /&gt;
| lid open&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and all xservers should be locked, possibly reinitialize ALSA and the sound system.&lt;br /&gt;
|-&lt;br /&gt;
| tapped power button&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and suspend-to-ram&lt;br /&gt;
|-&lt;br /&gt;
| held power button&lt;br /&gt;
|&lt;br /&gt;
| hibernate&lt;br /&gt;
|-&lt;br /&gt;
| unplugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;conservative&#039; cpufreq governor at above 25% power ; &#039;powersave&#039; governor at 25%.  set hdparam spindown rate lower.&lt;br /&gt;
|-&lt;br /&gt;
| plugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;performance&#039; governor.  disable hdparam spindown.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The purpose of the power governor is to regulate the running frequency (GHz) of the processor.&lt;br /&gt;
&lt;br /&gt;
Certain event handlers are are managed through laptop-mode-tools.  If you don&#039;t want the dependency, then you could write ACPI handler scripts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;acpi_listen&amp;lt;/code&amp;gt; can be used to retrieve the event name.&lt;br /&gt;
&lt;br /&gt;
TODO: put scripts below&lt;br /&gt;
&lt;br /&gt;
=== Adjusting the backlight dynamically ===&lt;br /&gt;
&lt;br /&gt;
The backlight may be controlled using sysfs.  The setting is a descendant of &amp;lt;code&amp;gt;/sys/class/backlight/&amp;lt;/code&amp;gt;.  The feature may allow you to echo a value to it.  Use trial and error to discover the values.&lt;br /&gt;
&lt;br /&gt;
The adjustment of the backlight should be function of battery life.  So if it is like 33% battery life, you want to run it near lowest settings but readable.  For 50 percent battery energy maybe 40% light.  For 90% battery maybe 75% light.&lt;br /&gt;
&lt;br /&gt;
=== hdparm ===&lt;br /&gt;
&lt;br /&gt;
To install hdparam do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add hdparm&lt;br /&gt;
&lt;br /&gt;
The settings that laptop-mode-tools messes with is the &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; or the spindown timeout.  It was also hinted that acoustic setting &amp;lt;code&amp;gt;-M&amp;lt;/code&amp;gt; is associated with the speed meaning that louder is faster and quieter is slower which could contribute to the amount of energy used or reduced.&lt;br /&gt;
&lt;br /&gt;
Again you want something like laptop-mode-tools or ACPI to dynamically adjust the settings based on ACPI events.&lt;br /&gt;
&lt;br /&gt;
=== laptop-mode-tools ===&lt;br /&gt;
&lt;br /&gt;
This is currently not in aports but worthy mentioning.  It should really be packaged.  This is a set of scripts to define a power policies.  You can manage all the settings in one place here like the hard drive idle spindown time, CPU governor control, dynamic LCD backlight behavior based on running on battery or AC power supply.&lt;br /&gt;
&lt;br /&gt;
=== cpufreqd ===&lt;br /&gt;
&lt;br /&gt;
This is a useful daemon for regulating power.&lt;br /&gt;
&lt;br /&gt;
To install cpufreqd do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add cpufreqd&lt;br /&gt;
&lt;br /&gt;
Make sure you add the service:&lt;br /&gt;
&lt;br /&gt;
  sudo rc-update add cpufreqd&lt;br /&gt;
&lt;br /&gt;
=== LCD screen refresh rate ===&lt;br /&gt;
&lt;br /&gt;
The refresh rate sets the maximum framerate.  The more frames pushed the more energy consumed on the battery.  You want this adjusted dynamically per certain events.  For gaming, you want it to be the highest as possible for the laptop and vsync off.  For battery use and traveling, you want it capped at 60 FPS/60 Hz or lower but dynamically adjust when you plug in the AC power supply.  You can adjust the framerate with xrandr.  For movies and YouTube, you want 60FPS and vsync on.&lt;br /&gt;
&lt;br /&gt;
== Hacking the kernel ==&lt;br /&gt;
&lt;br /&gt;
You should refer to the [[Custom Kernel]] page for details.&lt;br /&gt;
&lt;br /&gt;
== Hibernation ==&lt;br /&gt;
&lt;br /&gt;
See [[Custom_Kernel#Hibernation_to_prevent_data_loss|Hibernation to prevent data loss]].&lt;br /&gt;
&lt;br /&gt;
== WiFi management ==&lt;br /&gt;
&lt;br /&gt;
Since you are using WiFi, you need a better WiFi management to quickly find open access WiFi access points.  We don&#039;t have all day to debug complexities of WiFi settings while away from home.&lt;br /&gt;
&lt;br /&gt;
To install NetworkManager do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add networkmanager&lt;br /&gt;
&lt;br /&gt;
To find WiFi access points use the &amp;lt;code&amp;gt;nmtui&amp;lt;/code&amp;gt; ncurses interface.&lt;br /&gt;
&lt;br /&gt;
You also need other programs so install them as well:&lt;br /&gt;
&lt;br /&gt;
  apk add wpa-supplicant dhcpcd chrony macchanger wireless-tools iputils&lt;br /&gt;
&lt;br /&gt;
What these programs do:&lt;br /&gt;
&lt;br /&gt;
* wpa-supplicant -- for WPA encryption&lt;br /&gt;
* dhcpcd -- for getting a dynamic IP address&lt;br /&gt;
* chrony -- for fixing the time with the atomic clock&lt;br /&gt;
* wireless-tools -- for additional information&lt;br /&gt;
* macchanger -- for protecting against WiFi access discrimination or increased anonymity.  (optional)&lt;br /&gt;
* iputils -- for the ping command (optional)&lt;br /&gt;
&lt;br /&gt;
You also need to add those services:&lt;br /&gt;
&lt;br /&gt;
  rc-update add chronyd&lt;br /&gt;
  rc-update add wpa_supplicant&lt;br /&gt;
  rc-update add dhcpcd&lt;br /&gt;
  rc-update add networkmanager&lt;br /&gt;
&lt;br /&gt;
To start the services manually (or just reboot):&lt;br /&gt;
&lt;br /&gt;
  rc-service chronyd start&lt;br /&gt;
  rc-service wpa_supplicant start&lt;br /&gt;
  rc-service dhcpcd start&lt;br /&gt;
  rc-service networkmanager start&lt;br /&gt;
&lt;br /&gt;
== Additional tools ==&lt;br /&gt;
&lt;br /&gt;
=== actkbd ===&lt;br /&gt;
&lt;br /&gt;
To control the sound with fn function keys, you need this daemon.  It is currently not in aports.  You could override the design and meaning of those keys with your own scripts and utilities.  This daemon gives you that freedom.&lt;br /&gt;
&lt;br /&gt;
If your laptop contains a brightness key, you want to set that up with this program.  See also [[Setting_up_a_laptop#Adjusting_the_backlight_dynamically | Adjusting the backlight dynamically]].&lt;br /&gt;
&lt;br /&gt;
=== secure-delete ===&lt;br /&gt;
&lt;br /&gt;
Want to prevent cold-boot attack or decrypted keys in memory falling in the wrong hands?  This maybe could work who knows?  From research from cold boot attack, the data can actually stay in memory in minutes, just enough time for a hacker to copy the contents of the memory to a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
To install secure-delete do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add secure-delete&lt;br /&gt;
&lt;br /&gt;
smem only works for unused ram.[https://github.com/gordonrs/thc-secure-delete]  If you use the vanilla kernel, this may work.  If you use grsecurity, it will automatically sanitize memory if you enable it (but not enabled by default in the Alpine hardened kernel) when the memory page is freed.[https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Sanitize_all_freed_memory]&lt;br /&gt;
&lt;br /&gt;
Close all important programs then call smem.&lt;br /&gt;
&lt;br /&gt;
You call smem in your shutdown script or auto-logoff script.&lt;br /&gt;
&lt;br /&gt;
You can call create a OpenRC shutdown script to run smem when most programs and services are closed.  This will erase all your sensitive plaintext private data just in case.&lt;br /&gt;
&lt;br /&gt;
You may want to create a wrapper script to call smem after your program closes.&lt;br /&gt;
&lt;br /&gt;
You need to write a custom script that does the following:&lt;br /&gt;
  * kill all running processes associated with your user account&lt;br /&gt;
  * auto logoff terminals&lt;br /&gt;
  * for the last terminal closed including all idle xservers, unmount your user home&lt;br /&gt;
  * (optional) use smem to wipe all your plaintext private data in memory after all closed programs in case of cold boot attack&lt;br /&gt;
&lt;br /&gt;
=== Sharing presentations over HDMI ===&lt;br /&gt;
&lt;br /&gt;
If you want to use your laptop to share presentation over HDMI connection, you need libxinerama and xrandr.&lt;br /&gt;
&lt;br /&gt;
To install libxinerama and xrandr do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add libxinerama xrandr&lt;br /&gt;
&lt;br /&gt;
== Important notes ==&lt;br /&gt;
&lt;br /&gt;
If you lose or break your USB key, that is it and you cannot decrypt your drive.  It would be wise to make a backup of it.&lt;br /&gt;
&lt;br /&gt;
By default, suspend-to-ram or hibernate will not sufficiently clear the AES encryption keys off ram in those phases which would invite a cold boot attack.  This has been covered by the TRESOR kernel patch.[https://en.wikipedia.org/wiki/TRESOR][https://www1.cs.fau.de/tresor]  This patch hasn&#039;t been updated since the 4.x kernel series.[https://www1.cs.fau.de/tresor].  This patch currently only works on 32-bit x86 Linux with SSE and MMX, and on processors with the AES-NI instruction set for x86_64 Linux.  TRESOR doesn&#039;t work with DMA attack, but it can be mitigated by disabling DMA.[https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.303.3053&amp;amp;rep=rep1&amp;amp;type=pdf]  The 32-bit version of TRESOR has only a key size of 128.  The AES-NI version of TRESOR has a largest key size of 256 bit.  See [[Setting_up_a_laptop#Choosing_ciphers | Choosing ciphers]] for the number of rounds cracked.&lt;br /&gt;
&lt;br /&gt;
Loop-Amnesia works with LoopAES and is only for 64 bit Linux and only supports 128 bit keys but can result in data loss if their recommendations are not followed. [https://moongate.ydns.eu/amnesia.html]&lt;br /&gt;
&lt;br /&gt;
Please read the Wikipedia article on Cold Boot Attack especially the mitigation section.[https://en.wikipedia.org/wiki/Cold_boot_attack] Full disk encryption will not protect your data especially for older hardware if you do not have the proper mitigation (implying not full proof) prerequisites such as a patched kernel, memory scrambling, permanent memory module mounting for example.&lt;br /&gt;
&lt;br /&gt;
If you have a different but fully encrypted device like iPad, you still can be rubberhosed or interrogated with a perfect deniable encrypted laptop.  This guide doesn&#039;t protect you from that possibility.  If you do not want to be rubberhosed, don&#039;t possess those devices.&lt;br /&gt;
&lt;br /&gt;
Additional tips to mitigate against a DMA Attack to exfiltrate encryption keys:&lt;br /&gt;
&lt;br /&gt;
Disable DMA in the BIOS and set the password for the BIOS according to Wikipedia.[https://en.wikipedia.org/wiki/DMA_attack]&lt;br /&gt;
&lt;br /&gt;
Blacklist kernel modules that use DMA and any unused expansion modules (FireWire, CardBus, ExpressCard, Thunderbolt, USB 3.0, PCI Express and hotplug modules) that use DMA.&lt;br /&gt;
&lt;br /&gt;
You may need a custom (or customize a) BIOS or use Intel TXT or TPM which will authenticate the boot devices or boot from specific serial numbers not just any.  For cold boot attack, it is not required to remove the RAM but to to slow down the rate of decay of the RAM module with liquid air in addition an USB thumb drive containing an encryption key retriever bypassing the operating system.[https://youtu.be/XfUlRsE3ymQ]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[category: Desktop]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32059</id>
		<title>Setting up a laptop</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_a_laptop&amp;diff=32059"/>
		<updated>2026-02-17T10:01:12Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Hiding the keys using steganography */ mention stedghide being in edge/testing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide is about a project to create a &#039;&#039;&#039;secured laptop&#039;&#039;&#039;.  For this project we take in consideration ways to extend battery life.  It covers tools and daemons that are must haves for a laptop setup.&lt;br /&gt;
{{Todo|Instructions given in the page needs testing. Please help test section by section or the entire page. If individual sections have been tested, please update the Talkpage or please move/place this notice in the untested section(s) alone.}}&lt;br /&gt;
&lt;br /&gt;
== Guide features ==&lt;br /&gt;
&lt;br /&gt;
*Deniable full disk encryption&lt;br /&gt;
*Two factor authentication (physical object (USB key), mind) &lt;br /&gt;
*Encrypted swap and hibernation&lt;br /&gt;
*Encrypted home on top of encrypted drive&lt;br /&gt;
*Memory sanitation&lt;br /&gt;
*Dynamic power modes&lt;br /&gt;
*Feature keys support&lt;br /&gt;
&lt;br /&gt;
== Rubberhose Attack ==&lt;br /&gt;
&lt;br /&gt;
Just a reminder that all attacks are subjected to the Rubberhose Attack dilemma, you either give up your encryption keys or be tortured with a rubberhose with the possibly of death.  See [https://en.wikipedia.org/wiki/Rubber-hose_cryptanalysis Wikipedia article].  We try to present [https://en.wikipedia.org/wiki/Deniable_encryption  deniable encryption (Wikipedia)] to avoid a rubberhose attack scenario.  In this article we use the words plausible deniability interchangeably with deniable encryption.  To achieve this we use a facade and require no metadata fingerprints to expose or hint of encrypted or hidden containers or hint as in detect of existence of an encrypted disk.  The keys should be stored using steganography where we dilute the randomness into the facade.  It also requires you not to brag about encryption or mention it because that is an invitation for the attacker to torture the victim.  Deniable encryption requires you not put encrypted as an entry title to your bootloader.  There shouldn&#039;t be an entry for your facade bootloader to the encrypted drive.&lt;br /&gt;
&lt;br /&gt;
== Why full disk? ==&lt;br /&gt;
&lt;br /&gt;
The full disk encryption provides sort of some plausible deniability or a valid alibi that you didn&#039;t encrypt it.  Is the drive just random noise, broken, or is it really encrypted?  The other reason is that it implies that everything is protected.&lt;br /&gt;
&lt;br /&gt;
But there could be problems if not done right.  For example, cryptsetup does leave a plaintext marking or some hints by default that it has been encrypted when using luks/luks2 mode if a detached header with option &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is not presented.[https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/][https://man7.org/linux/man-pages/man8/cryptsetup.8.html]  To gain credibility that we didn&#039;t really do the encryption, you have to wipe the +3 MiB region based on the number of key slots used; or store the headers on an external device.&lt;br /&gt;
&lt;br /&gt;
If you did deniable encryption incorrectly, it is possible to erase and restore the header.  This presents an opportunity to improve obfuscation.  When you pull out the USB key, it should erase the header but store it on the USB key atomically as in completely.  If you plug in the USB key, it will restore back the header.  cryptsetup has luks actions luksHeaderBackup and luksHeaderRestore to do this.&lt;br /&gt;
&lt;br /&gt;
== Starting at the beginning ==&lt;br /&gt;
&lt;br /&gt;
Grab a USB thumb drive with Alpine.  Set it up as usual but don&#039;t let it touch your drive yet.  Then, install all the tools into memory ramdisk but not in the hard drive yet.  The hard drive will be obliterated.&lt;br /&gt;
&lt;br /&gt;
You will then install Alpine using the steps:&lt;br /&gt;
&lt;br /&gt;
First you need WiFi, to get it run do the command below but say no or skip  the hard drive setup stuff:&lt;br /&gt;
&lt;br /&gt;
  setup-alpine&lt;br /&gt;
&lt;br /&gt;
Then, you need to install some tools into RAM temporarly:&lt;br /&gt;
  apk add e2fsprogs grub grub-bios grub-efi mkinitfs nano&lt;br /&gt;
&lt;br /&gt;
== Randomizing the drive with pseudorandom urandom entropy ==&lt;br /&gt;
&lt;br /&gt;
The first part is to erase the drive with random noise but in practical time.  There are many techniques to do this but should be done in one day or two minimum.&lt;br /&gt;
&lt;br /&gt;
You can use shred or dd to accomplish this depending on your needs and the availability of entropy.  Some techniques take longer.  Cryptologist Bruce Schneier recommended 7 times with specified pattern.  See [https://en.wikipedia.org/wiki/Data_erasure Wikipedia Article].  For practical purposes, we just do it random in one pass.  It should be random so that the facade of random noise hides the encrypted data which resembles noise.&lt;br /&gt;
&lt;br /&gt;
To list the drives on the system do &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: make sure you wipe the right specific drive.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To wipe the disk with random entropy do:&lt;br /&gt;
&lt;br /&gt;
  dd if=/dev/urandom of=/dev/sda&lt;br /&gt;
&lt;br /&gt;
== Creating GPG keys ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;As of this time, Alpine&#039;s mkinitfs does only one factor authentication with passphrase.&#039;&#039;&#039; You need to manually edit the initramfs-init.in in mkinitfs to support two factor authentication using cryptsetup.&lt;br /&gt;
&lt;br /&gt;
After you have scrambled the drive, you want to create your GPG keys.  You will use these keys to set the password(s) for your cryptsetup-luks partitions.  These keys should be stored on a USB thumb drive or other memory device but should not be on the USB boot thumb drive or on the encrypted drive.  The key should be a random 128 bit key wrapped in GPG and protected with a password.&lt;br /&gt;
&lt;br /&gt;
If you are using x, you need to do &amp;lt;code&amp;gt;sudo apk add pinentry-gtk&amp;lt;/code&amp;gt; to display password prompt properly for the next step.&lt;br /&gt;
&lt;br /&gt;
To install openssl and gpg do:&lt;br /&gt;
&lt;br /&gt;
  apk add openssl gnupg&lt;br /&gt;
&lt;br /&gt;
Then, to generate a key:&lt;br /&gt;
&lt;br /&gt;
  export GPG_TTY=$(tty) &amp;amp;&amp;amp; openssl rand -base64 512 | gpg --symmetric --cipher-algo aes --armor &amp;gt; /mnt/usb/$(openssl rand -hex 12)&lt;br /&gt;
&lt;br /&gt;
(Make sure your usb is mounted on /mnt/usb first.)&lt;br /&gt;
&lt;br /&gt;
The long file name comes from &amp;lt;code&amp;gt;openssl rand -hex 12&amp;lt;/code&amp;gt; so that we enhance plausible deniability.  The attacker cannot determine the purpose of the key.  Is it used for GitHub? for Email?&lt;br /&gt;
&lt;br /&gt;
The first part will produce 512 random bytes in wrap it in base64.  The random data will be piped to gpg which will wrap it in AES as ciphertext which again gets wrapped in base64 ascii armor.  For every partition including swap in some cases, you should create more gpg keys and store them in your USB thumb drives.  After you have produced your gpg keys, you will then use them as a password for cryptsetup/luks.&lt;br /&gt;
&lt;br /&gt;
You can replace aes above with the ones listed in &amp;lt;code&amp;gt;gpg --version&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There should be a password generated for the swap.  This is to resume for your hibernate.  If you don&#039;t want to hibernate, then password is not required and all you need to do is to create/format the partition each time you boot without a password or with a one time random password.&lt;br /&gt;
&lt;br /&gt;
== Hiding the keys using steganography ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;WARNING:&#039;&#039; This section is considered experimental.  It requires the tool and the dependencies to be placed on another USB separate from the key files, the bootloaders, and encrypted disks.  The tool and dependencies need to be packaged together.  We decentralize these components so that the attacker doesn&#039;t connect the dots easily or immediately jumps to the conclusion for the requirements to decrypt.  Steghide automatically uses 128-bit AES in CBC mode to encrypt data.  This can be change if you don&#039;t like or trust AES with the -e option.  Use &amp;lt;code&amp;gt;steghide encinfo&amp;lt;/code&amp;gt; for other ciphers and modes.&lt;br /&gt;
&lt;br /&gt;
Fortunately, Alpine has a package for steganography called steghide (in the optional edge/testing repository as of February 2026). To install steghide do:&lt;br /&gt;
&lt;br /&gt;
  echo &amp;quot;http://dl-cdn.alpinelinux.org/alpine/edge/testing&amp;quot; &amp;gt;&amp;gt; /etc/apk/repositories&lt;br /&gt;
  apk add steghide&lt;br /&gt;
&lt;br /&gt;
You will place the keyfile in an image file.  The facade image file should be large enough that there is no apparent discernible difference between the original and the modified.  Do not use a small image with a small filesize.&lt;br /&gt;
&lt;br /&gt;
As mentioned previously luks headers could be 3MB large or more and an jpeg image file is not suitable.  Use another format like .au/.wav or another steganography utility that handles mp3s.  The mp3/wav should be fairly large enough to dilute the header.  So, something with long content is suitable.&lt;br /&gt;
&lt;br /&gt;
There are two basic commands to use with steghide embed and extract,&lt;br /&gt;
&lt;br /&gt;
To embed do:&lt;br /&gt;
&lt;br /&gt;
  steghide embed -ef key.gpg -cf image.jpg&lt;br /&gt;
&lt;br /&gt;
To extract do:&lt;br /&gt;
&lt;br /&gt;
  steghide extract -xf key.gpg -sf image.jpg&lt;br /&gt;
&lt;br /&gt;
To get a file list of files to ship out, use:&lt;br /&gt;
&lt;br /&gt;
  apk info -L libgcc libmcrypt libmhash libstdc++ libjpeg-turbo steghide&lt;br /&gt;
&lt;br /&gt;
== Full disk encryption with with cryptsetup-luks volumes ==&lt;br /&gt;
&lt;br /&gt;
=== Partitioning scheme ===&lt;br /&gt;
&lt;br /&gt;
This section presents a conceptual layout.  It should not be a knee-jerk approval to automatically use the partition tool which would compromise your plausible deniability.&lt;br /&gt;
&lt;br /&gt;
For the facade, we use an Ubuntu Live CD (or less skilled distro) to present the impression that we are not sophisticated or tech savvy enough to implement encryption.  Windows is also acceptable even better.  The immutable Live CD and immutable partition ensures that you are not compromised by a third party attacker that implants evidence.&lt;br /&gt;
&lt;br /&gt;
There could be possibly two bootloaders, one for the facade and the other to the encrypted drive stored on an external device.&lt;br /&gt;
&lt;br /&gt;
==== Luks ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you can demonstrate no existence of partitions 2, 3, 4 and no fingerprints/plaintext introduced by cfdisk and cryptsetup-luks.  Use something like TestDisk, fdisk -l, or gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| root&lt;br /&gt;
| /&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Plain dm-crypt ====&lt;br /&gt;
&lt;br /&gt;
Plausible deniability only works if you are able to present #2 as being unused space or untampered.  To check use something like TestDisk, gparted and a disk editor (hex editor for disks).&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Name&lt;br /&gt;
!Mount point&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| facade&lt;br /&gt;
| /&lt;br /&gt;
| (optional) The facade partition contains a pristine normal operating system or Ubuntu Live CD image to lure the attacker in attempt to boost the confidence of the attacker convincing them that there is no encryption on the device.&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| vgroot&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_1&lt;br /&gt;
| vgroot-root&lt;br /&gt;
| /&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 2_2&lt;br /&gt;
| vgroot-swap&lt;br /&gt;
| &lt;br /&gt;
| It should be the same size as your ram for x86_64.  Rationale: it should contain the whole ram image.&lt;br /&gt;
|-&lt;br /&gt;
| 2_3&lt;br /&gt;
| vgroot-rescue&lt;br /&gt;
| /&lt;br /&gt;
| This should contain the Alpine image.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Installing cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
To install cryptsetup you need the package below&lt;br /&gt;
&lt;br /&gt;
  apk add cryptsetup&lt;br /&gt;
&lt;br /&gt;
=== Choosing ciphers ===&lt;br /&gt;
&lt;br /&gt;
When you create your luks drives, you need to decide on the type of ciphers and hashing techniques to use.  The ciphers that you want to use are ones are up to you, but it should be one that is hasn&#039;t been cracked yet or has not suffered a lot of cryptanalysis attacks.  The ones that you might want to use is AES which is hardware accelerated in some Intel CPUs that have the AES-NI cpuflag which you can check by &amp;lt;code&amp;gt;cat /proc/cpuinfo&amp;lt;/code&amp;gt;.  Also consider the ciphers that are SIMD optimized such as serpent and twofish that are available in the Linux kernel.  Also consider ciphers that are unpopular but known to be secure such as Blowfish (which Wikipedia claims to be attacked and the author recommended Twofish).[https://en.wikipedia.org/wiki/Cipher_security_summary]  If it is hardware accelerated, it will save battery life and minimize CPU usage.&lt;br /&gt;
&lt;br /&gt;
For some ciphers weakness also see [https://en.wikipedia.org/wiki/Cipher_security_summary Cipher security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
For some hash function weaknesses also see [https://en.wikipedia.org/wiki/Hash_function_security_summary Hash function security summary (Wikipedia)].&lt;br /&gt;
&lt;br /&gt;
Generally speaking, the swap partition should use a fast cipher.  You want to lower the latency or delay of the memory subsystem as a consequence of being encrypted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; Please read the [[Setting_up_a_laptop#Important_notes | Important notes]] section for details about the problems with AES encryption.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t trust AES shills and endorsed by the NSA, you can try another different one.  Another advantage of using a public vetted cipher is that it provides confidence that it works.&lt;br /&gt;
&lt;br /&gt;
Something like KHAZAD wouldn&#039;t work on &amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt;.  KHAZAD itself is insecure.  Wikipedia reported 5 out of 8 rounds been cracked.[https://en.wikipedia.org/wiki/KHAZAD]&lt;br /&gt;
&lt;br /&gt;
For AES-128 7 out of 10, AES-192 8 out of 12, AES-256-bit 9 out 14 rounds have been cracked according to Wikipedia.[https://en.wikipedia.org/wiki/Advanced_Encryption_Standard]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: Do not use sha1 as the hashing algorithm.&#039;&#039;&#039;  It already has already been compromised.&lt;br /&gt;
&lt;br /&gt;
=== Getting the available ciphers ===&lt;br /&gt;
&lt;br /&gt;
To check the availability of a cipher or hash function use:&lt;br /&gt;
  find $(find /lib/modules -name &amp;quot;crypto&amp;quot; -type d) -type f -name &amp;quot;*.ko&amp;quot; | sort&lt;br /&gt;
&lt;br /&gt;
To check if a cipher is loaded and passed its own tests use:&lt;br /&gt;
  cat /proc/crypto&lt;br /&gt;
&lt;br /&gt;
To test some popular ciphers and hashes do:&lt;br /&gt;
&lt;br /&gt;
  cryptsetup benchmark&lt;br /&gt;
&lt;br /&gt;
The top set is associated with the hashing algorithms.  The bottom set are the ciphers.  Use the commands below but replace the cipher and/or hash algorithm with your preferences.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cryptsetup benchmark&amp;lt;/code&amp;gt; actually doesn&#039;t show all the ciphers like Anubis.  The cipher should also have CBC and/or XTS block cipher mode of operation to encrypt larger block sizes.  AES for example has a block size of 128.  &lt;br /&gt;
&lt;br /&gt;
To test if the unpopular but uncracked cipher works use sometime like:&lt;br /&gt;
  cryptsetup benchmark --cipher anubis&lt;br /&gt;
&lt;br /&gt;
=== General steps for cryptsetup ===&lt;br /&gt;
&lt;br /&gt;
==== Original method with fdisk with no plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
In this method &amp;lt;code&amp;gt;--type luks&amp;lt;/code&amp;gt; is implied which generates metadata.&lt;br /&gt;
&lt;br /&gt;
If you want plausible deniability for luks, you need to pass &amp;lt;code&amp;gt;--header &amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; to all the luks commands, where &amp;lt;code&amp;gt;&amp;lt;path&amp;gt;&amp;lt;/code&amp;gt; is a unix path like /mnt/usb/d6ae10eda66704c8.  The random name comes from &amp;lt;code&amp;gt;openssl rand -hex 8&amp;lt;/code&amp;gt;.  The header is transferred to the external device (but no mention of the key slot area but ciphertext being transferred) in the man page.  The information in that file should be obfuscated with encryption if there is plaintext or fingerprint in it just in case. Then, it should be decrypted when reused.&lt;br /&gt;
&lt;br /&gt;
You need to install cfdisk if you prefer the interactive ncurses console method:&lt;br /&gt;
&lt;br /&gt;
  apk add cfdisk&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Use cfdisk to create partitions.  Make two partitions--a system partition and a swap partition&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cfdisk&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Create and format the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --cipher aes-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sda1 /mnt/usb/$(ls)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Open the luks device&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup --key-file /mnt/usb/$(ls) luksOpen /dev/sda1 root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Format the decrypted drive with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Create the mount point&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Mount the root partition&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Create swap&lt;br /&gt;
| cryptsetup -c blowfish -h sha256 -d /dev/urandom --key-file /mnt/usb/59022506d9f4a714 create swap /dev/sda2 &lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Use swap&lt;br /&gt;
| mkswap /dev/mapper/swap &amp;amp;&amp;amp; swapon /dev/mapper/swap&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Improved method with plausible deniability ====&lt;br /&gt;
&lt;br /&gt;
This method requires lvm2.  To install:&lt;br /&gt;
&lt;br /&gt;
  apk add lvm2&lt;br /&gt;
&lt;br /&gt;
{|| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!#&lt;br /&gt;
!Step&lt;br /&gt;
!Command&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| Open the &#039;&#039;plain dm-crypt&#039;&#039; device generating no metadata&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| Physical volume create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;pvcreate /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| Volume group create with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;vgcreate vgroot /dev/mapper/pvroot&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| Logical volume create the swap volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 4G vgroot -n swap&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| Logical volume create the root volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 2T vgroot -n root&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| Logical volume create the rescue volume with LVM&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;lvcreate -L 110M vgroot -n rescue&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| Format the root volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| Format the swap volume and activate it&lt;br /&gt;
| &amp;lt;code&amp;gt;mkswap /dev/mapper/vgroot-swap &amp;amp;&amp;amp; swapon /dev/mapper/vgroot-swap&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| Format the rescue volume with filesystem&lt;br /&gt;
| &amp;lt;code&amp;gt;mkfs.ext4 /dev/mapper/vgroot-rescue&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| Create mount point for root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mkdir -p /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| Mount the root volume&lt;br /&gt;
| &amp;lt;code&amp;gt;mount /dev/mapper/vgroot-root /mnt/root&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Configuring OpenRC dmcrypt and setting up fstab ===&lt;br /&gt;
&lt;br /&gt;
You need to tell OpenRC init scripts to decrypt the volumes.  See &amp;lt;code&amp;gt;/etc/conf.d/dmcrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You need to add the service to boot well because it needs to decrypt the root volume before OpenRC starts running commands from it.  So you need to do:&lt;br /&gt;
&lt;br /&gt;
  rc-update add dmcrypt boot&lt;br /&gt;
&lt;br /&gt;
==== dmcrypt ====&lt;br /&gt;
The dmcrypt OpenRC service will attempt to decrypt the drive using information provided in &#039;&#039;/etc/conf.d/dmcrypt&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root may not be necessary since it is already mounted.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda1&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/conf.d/dmcrypt|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
  # Mounting root is likely not required since you already mounted it before OpenRC starts to do its thing.&lt;br /&gt;
  target=root&lt;br /&gt;
  source=&#039;/dev/sda&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/2a667ec72774b0d5&#039;&lt;br /&gt;
  options=&#039;--type plain --cipher aes-cbc-essiv:sha256 --key-size 256&#039;&lt;br /&gt;
&lt;br /&gt;
  swap=swap&lt;br /&gt;
  source=&#039;/dev/sda2&#039;&lt;br /&gt;
  key=&#039;/mnt/usb/59022506d9f4a714&#039;&lt;br /&gt;
  pre_mount=&#039;vgchange -ay vgroot ; lvchange -ay vgroot/swap&#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
dm-crypt will just mount the encrypted &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; partition.  What you need to do next is set up fstab located at /etc/fstab.  Examples are shown below.&lt;br /&gt;
&lt;br /&gt;
==== /etc/fstab ====&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;plain dm-crypt&#039;&#039; device with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/root          /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/swap          none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
To mount &#039;&#039;lvm&#039;&#039; volumes with fstab:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/fstab|&lt;br /&gt;
  /dev/sdb                  /boot	ext4	defaults  0 0&lt;br /&gt;
  /dev/mapper/vgroot-root   /		ext4	defaults  0 1&lt;br /&gt;
  /dev/mapper/vgroot-swap   none	swap	sw        0 0&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How to recover from a bad setup ===&lt;br /&gt;
&lt;br /&gt;
Many times you will not get it right perfectly the first try.  To recover from this situation, you need to reopen the &#039;&#039;plain dm-crypt&#039;&#039; drive or the &#039;&#039;luks&#039;&#039; drive and then remount everything back.&lt;br /&gt;
&lt;br /&gt;
To recover from &#039;&#039;luks&#039;&#039;:&lt;br /&gt;
  cryptsetup --key-file /mnt/usb/2a667ec72774b0d5 luksOpen /dev/sda1 root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/root /mnt/root&lt;br /&gt;
&lt;br /&gt;
To recover from the &#039;&#039;plain dm-crypt&#039;&#039;:&lt;br /&gt;
  cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file /mnt/usb/$(ls) /dev/sda root&lt;br /&gt;
  vgchange -ay vgroot&lt;br /&gt;
  lvchange -ay vgroot/root&lt;br /&gt;
  mkdir -p /mnt/root&lt;br /&gt;
  mount /dev/mapper/vgroot-swap /mnt/root&lt;br /&gt;
&lt;br /&gt;
== Next step: Full blown Alpine installation ==&lt;br /&gt;
&lt;br /&gt;
We will setup the /mnt/root encrypted partition:&lt;br /&gt;
  apk add --root=/mnt/root --initdb $(cat /etc/apk/world) --keys-dir /etc/apk/keys --repositories-file /etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, enable edge repositories in both files including community and testing:&lt;br /&gt;
  nano /etc/apk/repositories /mnt/root/etc/apk/repositories&lt;br /&gt;
&lt;br /&gt;
Then, copy the necessary files:&lt;br /&gt;
  cp /etc/resolv.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, install the basic utils:&lt;br /&gt;
  apk add --root=/mnt/root dhcpcd chrony networkmanager wireless-tools wpa_supplicant&lt;br /&gt;
  apk add --root=/mnt/root grub mkinitfs e2fsprogs grub-bios grub-efi&lt;br /&gt;
  apk add --root=/mnt/root sudo nano&lt;br /&gt;
  apk add --root=/mnt/root linux-lts&lt;br /&gt;
&lt;br /&gt;
Then, you need to mount your usb on to /boot:&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Edit grub:&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
Then, install grub on the usb:&lt;br /&gt;
  grub-install --force /dev/sdb&lt;br /&gt;
&lt;br /&gt;
Then, prepare chroot:&lt;br /&gt;
  mount --bind /dev /mnt/root/dev&lt;br /&gt;
  mount --bind /sys /mnt/root/sys&lt;br /&gt;
  cp /etc/reslov.conf /mnt/root/etc&lt;br /&gt;
&lt;br /&gt;
Then, chroot:&lt;br /&gt;
  chroot /mnt/root /bin/sh&lt;br /&gt;
&lt;br /&gt;
Set the root administrator password:&lt;br /&gt;
  passwd&lt;br /&gt;
&lt;br /&gt;
The root password should be very difficult to deter you from using it and force you to use sudo&lt;br /&gt;
&lt;br /&gt;
Edit sudo so that wheel group has administrative :&lt;br /&gt;
  EDITOR=nano visudo&lt;br /&gt;
&lt;br /&gt;
Set:&lt;br /&gt;
  ## Uncomment to allow members of group wheel to execute any command       &lt;br /&gt;
  %wheel ALL=(ALL) ALL                                                 &lt;br /&gt;
&lt;br /&gt;
Then, add wheel (administrator) user:&lt;br /&gt;
  useradd -m myname&lt;br /&gt;
  usermod -a -G video,audio,wheel myname&lt;br /&gt;
&lt;br /&gt;
log in that user:&lt;br /&gt;
  su myname&lt;br /&gt;
&lt;br /&gt;
Then, update and upgrade it&lt;br /&gt;
  sudo apk update&lt;br /&gt;
  sudo apk upgrade&lt;br /&gt;
&lt;br /&gt;
Then, setup xorg:&lt;br /&gt;
  sudo setup-xorg-base&lt;br /&gt;
  sudo apk search xf86-video | sort&lt;br /&gt;
  # pick your xf86 video driver&lt;br /&gt;
  sudo apk add xf86-video-amdgpu&lt;br /&gt;
  # install the mesa driver&lt;br /&gt;
  sudo apk add mesa-dri-gallium  &lt;br /&gt;
&lt;br /&gt;
Then, keep piling on:&lt;br /&gt;
  sudo apk add firefox dwm xfce4-terminal alsa-utils keepassx xfce4 xchat&lt;br /&gt;
  sudo apk add font-noto-emoji font-terminus leafpad xsetroot # See [[Emojis]] to complete installation&lt;br /&gt;
  sudo apk add xf86-input-libinput # or -evdev if libinput doesn&#039;t work&lt;br /&gt;
&lt;br /&gt;
Then, set the desktop:&lt;br /&gt;
  nano .xinitrc&lt;br /&gt;
&lt;br /&gt;
Put both but comment with a # one of them if you don&#039;t want it,&lt;br /&gt;
  #while true; do xsetroot -name &amp;quot;$( date +&amp;quot;%a %b %d %I:%M:%S %Y&amp;quot; )&amp;quot; ; sleep 1; done &amp;amp;&lt;br /&gt;
  #exec dwm&lt;br /&gt;
  exec xfce4-session&lt;br /&gt;
&lt;br /&gt;
For the above xsetroot statement used to provide information in the statusbar for dwm, consider adding information about the battery level.  This information can be found in sysfs at /sys/class/power_supply/BAT0/.&lt;br /&gt;
&lt;br /&gt;
  sync&lt;br /&gt;
  sudo reboot&lt;br /&gt;
&lt;br /&gt;
== Hacking mkinitfs to support cryptsetup with GPG keys ==&lt;br /&gt;
&lt;br /&gt;
This section describes how to assemble a custom initscript chain in multiple parts.  It could be extended with three-factor authentication which adds biometrics along side with mind and physical object.&lt;br /&gt;
&lt;br /&gt;
Most entry to secure systems are not fully automated or do not allow things to quickly pass through freely and often guarded.  This process may seem like a hassle, but it should dissuade the rubberhosers from jumping to the conclusion of the possibility of the existence of a encrypted drive.&lt;br /&gt;
&lt;br /&gt;
Here is the steps required so that the facade initscripts and dependencies are free from encryption.&lt;br /&gt;
* You will separate and archive cryptsetup, ciphers kernel modules, hash function kernel modules, and any additional obfuscation dependencies, and another continuation initscript discussed below.  You need to make sure that you copy /etc/mkinitfs/mkinitfs.conf to your home directory and strip out those features without those modules.&lt;br /&gt;
* You will hide this archive in a mp3 file with another tool you will package or you can use steghide&#039;s .au/.wav support, but .au seems too conspicuous or strange by current trends.&lt;br /&gt;
&lt;br /&gt;
Here we try to clean up the facade so that it presents itself as free without cryptography.  You need the following changes to your initramfs to avoid a sensitive rubberhoser:&lt;br /&gt;
* You will delete everything in the custom initramfs-init referring to encryption.  This includes cryptroot, cryptdm, crypt-anything, etc init options.&lt;br /&gt;
* You need to delete references in nlplug-findfs to cryptsetup and recompile the mkinitfs package.&lt;br /&gt;
* You could program the init script to boot into a facade partition but drop into sh if a hidden special keypress sequence is met.&lt;br /&gt;
&lt;br /&gt;
You need to create a custom init continuation script:&lt;br /&gt;
* Your initscript should drop into single mode which you will mount the encrypted path manually. &lt;br /&gt;
* You will manually steg-unhide the encrypted archive hidden in the mp3 file and extract it to the ramdisk.&lt;br /&gt;
* You will run the custom init continuation script manually.&lt;br /&gt;
* This custom init continuation will automate the process of extracting the gpg keys from another device and image files into the ramdisk.  This will then automate the mounting of the encrypted drive.  This resume continuation script should handle both cold boot and hibernate.&lt;br /&gt;
* You will finish resuming running the other half of mkinitfs-init or specifically where the points after where it typically will mount cryptsetup and hibernate devices.&lt;br /&gt;
&lt;br /&gt;
If you use a USB keyboard, you will unlock the encrypted devices in early userspace. You will need to either compile the USB keyboard drivers in the kernel or you need to add additional modules when generating the mkinitfs.  You will need the hid, hid-generic, ehci-hcd, uhci-hcd, usbcore driver and add those paths in a customized &amp;lt;code&amp;gt;/etc/mkinitfs/features.d/usb-keyboard.modules&amp;lt;/code&amp;gt;.  It should be separate from usb.modules because apk updates may overwrite it.  Use the &amp;lt;code&amp;gt;lsmod&amp;lt;/code&amp;gt; utility from the kmod package to find what drivers your USB keyboard uses.&lt;br /&gt;
&lt;br /&gt;
You need to generate the final mkinitfs.&lt;br /&gt;
First you need the kernelversion to pass into mkinitfs.  To obtain that information do &amp;lt;code&amp;gt;ls /lib/modules&amp;lt;/code&amp;gt; which will show some folders.  Once you found it pass it to mkinitrafs by doing and replacing kernelversion below:&lt;br /&gt;
&lt;br /&gt;
  sudo mkinitramfs -i $HOMEDIR/initramfs-init -c &amp;quot;$HOMEDIR&amp;quot;/mkinitfs.conf kernelversion&lt;br /&gt;
&lt;br /&gt;
The $HOMEDIR should be replaced with the full path if you are not root.&lt;br /&gt;
&lt;br /&gt;
==  Install the bootloader in the USB thumb drive ==&lt;br /&gt;
&lt;br /&gt;
To install grub, you need to install grub on the ramdisk first on the host.  &lt;br /&gt;
&lt;br /&gt;
  apk add grub&lt;br /&gt;
&lt;br /&gt;
To get a list of partitions&lt;br /&gt;
&lt;br /&gt;
  fdisk -l&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition in /boot&lt;br /&gt;
&lt;br /&gt;
  mount /dev/sdb /boot&lt;br /&gt;
&lt;br /&gt;
Make changes to grub&#039;s configuration &lt;br /&gt;
&lt;br /&gt;
  nano /boot/grub/grub.cfg&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You need to customize the initramfs in order to use GPG keys since there is no support from it.&#039;&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
The steps here below assumes that these custom initramfs features have been implemented.  &lt;br /&gt;
&lt;br /&gt;
The following boot loader settings is &#039;&#039;&#039;not sufficient&#039;&#039;&#039; for deniable encryption because it exposes the fact that an encrypted drive exists because an attacker can discover that encryption was used through the edit option of the grub menu.  To protect yourself from a rubberhose attack, you really need to customize the initramfs so that references to anything mentioning encryption, ciphers, hashing are not explicitly mentioned.  These configurations should be considered an intermediate form for used in debugging purposes.  In addition, the attacker just can inspect grub.cfg files directly.&lt;br /&gt;
&lt;br /&gt;
The following are just examples to just get it working but should be modified so that it doesn&#039;t hint to the rubberhoser of a hidden partition or encrypted partitions.&lt;br /&gt;
&lt;br /&gt;
The entry should look like:&lt;br /&gt;
&lt;br /&gt;
For &#039;luks&#039;&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda1 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/root rw modules=sd-mod,usb-storage,ext4,dm-crypt,aes-x86_64,sha256-mb cryptroot=/dev/sda4 cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For &#039;plain dm-crypt&#039;:&lt;br /&gt;
&lt;br /&gt;
The stock mkinitfs may not support plain dm-crypt.  It looks like it only supports luks.  Customization of the initramfs is required.&lt;br /&gt;
&lt;br /&gt;
{{cat|/boot/grub/grub.cfg|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
default=0&lt;br /&gt;
timeout=0&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Windows 10&#039; {&lt;br /&gt;
	set root=(hd0,2)&lt;br /&gt;
        chainloader +1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-root rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=root&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
menuentry &#039;Alpine Linux (Rescue)&#039; {&lt;br /&gt;
	set root=(hd1,1)&lt;br /&gt;
	linux /vmlinuz-hardened root=/dev/mapper/vgroot-rescue rw modules=sd-mod,usb-storage,ext4,dm-crypt,dm-mod,dm-snapshot,aes-x86_64,sha256-mb cryptroot=/dev/sda cryptdm=rescue&lt;br /&gt;
	initrd /initramfs-hardened&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if keystatus; then&lt;br /&gt;
  if keystatus --ctrl; then&lt;br /&gt;
    set timeout=-1&lt;br /&gt;
  else&lt;br /&gt;
    set timeout=0&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The source code of grub could possibly be modified and recompiled to use other non-standard keys.  See [https://github.com/lemenkov/grub2/blob/master/grub-core/commands/keystatus.c].  Ideally, it should be not so obvious or accessible for the attacker.&lt;br /&gt;
&lt;br /&gt;
The above grub.cfg is applied to the USB bootloader.  For the facade bootloader, you just want the Windows 10 or Ubuntu entry, nothing more.&lt;br /&gt;
&lt;br /&gt;
For the modules parameter, you need to add your crypto modules.&lt;br /&gt;
Use &amp;lt;code&amp;gt;find /lib/modules/ -name &amp;quot;*aes*&amp;quot;&amp;lt;/code&amp;gt; where aes is the basename for your cipher or hash algorithm&lt;br /&gt;
Use &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt; to obtain the UUID of your device&lt;br /&gt;
&lt;br /&gt;
Install it to your USB thumb drive&lt;br /&gt;
&lt;br /&gt;
  grub-install /dev/sdb&lt;br /&gt;
&lt;br /&gt;
== Home mounting with eCryptfs ==&lt;br /&gt;
&lt;br /&gt;
We use eCryptfs to encrypt home.  The rationale for having another encrypted file system is that if you leave your laptop unattended on break or accidentally leave your USB key in, your data will not be accessible.  The other rationale is that if another person wants to use your computer, you can just log off and the data will be kept hidden and encrypted.  When you log off due to inactivity, your home directory will be unmounted and encrypted.  eCryptfs will encrypt/decrypt the filename and the contents and will sit on top of ext4 which sits on top of luks.&lt;br /&gt;
&lt;br /&gt;
To install ecryptfs-utils:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add ecryptfs-utils&lt;br /&gt;
&lt;br /&gt;
This does one factor authentication mostly with just the password, but it should be modified to use the USB key too.  You need to reconfigure pam with the pam_usb.so which is not in Alpine aports.&lt;br /&gt;
&lt;br /&gt;
You need to use the pam_ecryptfs PAM module.&lt;br /&gt;
&lt;br /&gt;
== Locking it down ==&lt;br /&gt;
&lt;br /&gt;
Many times you will leave your laptop behind with people you trust.  The following tools will help lock down the system.&lt;br /&gt;
&lt;br /&gt;
=== physlock ===&lt;br /&gt;
&lt;br /&gt;
This will auto lock the tty and when you return will prompt for password.&lt;br /&gt;
&lt;br /&gt;
To install physlock:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add physlock&lt;br /&gt;
&lt;br /&gt;
It is currently bugged.  See [https://bugs.alpinelinux.org/issues/3282].  physlock likely doesn&#039;t do two-factor authentication but it should.&lt;br /&gt;
&lt;br /&gt;
You need to create custom script that will monitor idle time in TTY then call physlock.  You load this script when you log on.&lt;br /&gt;
&lt;br /&gt;
=== xscreensaver ===&lt;br /&gt;
&lt;br /&gt;
This will lock you out of xserver&lt;br /&gt;
&lt;br /&gt;
To install xscreensaver:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add xscreensaver&lt;br /&gt;
&lt;br /&gt;
=== USB key udev rule ===&lt;br /&gt;
&lt;br /&gt;
You need to add a new [[udev]] rule that will suspend-to-ram or hibernate and log off once you pull the USB key.  When you come back on, you should do 2 factor authentication to restore back everything.  Hibernation and suspend-to-ram might mitigate cold-boot attack (but unlikely see notes at the bottom of the page) to extract plaintext private data and encryption keys in memory.&lt;br /&gt;
&lt;br /&gt;
To find out the details of your USB do:&lt;br /&gt;
&lt;br /&gt;
  udevadm monitor --udev -p&lt;br /&gt;
&lt;br /&gt;
The output should look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
UDEV  [181762.722853] add      /devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc (block)&lt;br /&gt;
ACTION=add&lt;br /&gt;
DEVLINKS=/dev/disk/by-id/usb-Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0 /dev/disk/by-path/pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0 /dev/disk/by-uuid/5A96-03E4&lt;br /&gt;
DEVNAME=/dev/sdc&lt;br /&gt;
DEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-5/2-5:1.0/host6/target6:0:0/6:0:0:0/block/sdc&lt;br /&gt;
DEVTYPE=disk&lt;br /&gt;
ID_BUS=usb&lt;br /&gt;
ID_FS_TYPE=vfat&lt;br /&gt;
ID_FS_USAGE=filesystem&lt;br /&gt;
ID_FS_UUID=5A96-03E4&lt;br /&gt;
ID_FS_UUID_ENC=5A96-03E4&lt;br /&gt;
ID_FS_VERSION=FAT32&lt;br /&gt;
ID_INSTANCE=0:0&lt;br /&gt;
ID_MODEL=MSFT_NORB&lt;br /&gt;
ID_MODEL_ENC=MSFT\x20NORB\x20\x20\x20\x20\x20\x20\x20&lt;br /&gt;
ID_MODEL_ID=1645&lt;br /&gt;
ID_PATH=pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0&lt;br /&gt;
ID_PATH_TAG=pci-0000_00_13_2-usb-0_5_1_0-scsi-0_0_0_0&lt;br /&gt;
ID_REVISION=PMAP&lt;br /&gt;
ID_SERIAL=Kingston_MSFT_NORB_MSFTLAKDA300EB3021790009-0:0&lt;br /&gt;
ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&lt;br /&gt;
ID_TYPE=disk&lt;br /&gt;
ID_USB_DRIVER=usb-storage&lt;br /&gt;
ID_USB_INTERFACES=:080650:&lt;br /&gt;
ID_USB_INTERFACE_NUM=00&lt;br /&gt;
ID_VENDOR=Kingston&lt;br /&gt;
ID_VENDOR_ENC=Kingston&lt;br /&gt;
ID_VENDOR_ID=0951&lt;br /&gt;
MAJOR=8&lt;br /&gt;
MINOR=32&lt;br /&gt;
SEQNUM=2027&lt;br /&gt;
SUBSYSTEM=block&lt;br /&gt;
USEC_INITIALIZED=1762722168&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You want to extract the &amp;lt;code&amp;gt;ID_SERIAL_SHORT=MSFTLAKDA300EB3021790009&amp;lt;/code&amp;gt; or whatever is associated with your USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
You need pm-utils for ps-suspend.  So to install it do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add pm-utils&lt;br /&gt;
&lt;br /&gt;
You will create a udev rules so that when you pull out the USB, it will suspend-to-ram or you can use your own script.  To do that create a file with the following contents:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/udev/rules.d/50-usb-thumb-drive.rules|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ACTION==&amp;quot;remove&amp;quot;, SUBSYSTEM==&amp;quot;usb&amp;quot;, ENV{ID_SERIAL_SHORT}==&amp;quot;MSFTLAKDA300EB3021790009&amp;quot;, RUN+=&amp;quot;/usr/sbin/pm-suspend&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Extending battery life ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING: If you do not use the proper mitigation for cold boot attack, you are better off auto-shutdowning the laptop instead of using suspend or hibernate.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== ACPI ===&lt;br /&gt;
&lt;br /&gt;
ACPI is a good daemon to use to execute certain scripts when laptop events are triggered.&lt;br /&gt;
&lt;br /&gt;
To install ACPI do:&lt;br /&gt;
&lt;br /&gt;
  apk add acpi&lt;br /&gt;
&lt;br /&gt;
The events to pay attention to are:&lt;br /&gt;
&lt;br /&gt;
{|  cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Event&lt;br /&gt;
! ACPI Event&lt;br /&gt;
! What your script should do&lt;br /&gt;
|-&lt;br /&gt;
| lid close&lt;br /&gt;
|&lt;br /&gt;
| log off ttys and suspend-to-ram.  ALSA should either set the volume to 0 for the sound card or the sound driver be unloaded.  It might be a good idea to kill or mute any music or movie players if the sound loops loudly after lid open.&lt;br /&gt;
|-&lt;br /&gt;
| lid open&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and all xservers should be locked, possibly reinitialize ALSA and the sound system.&lt;br /&gt;
|-&lt;br /&gt;
| tapped power button&lt;br /&gt;
|&lt;br /&gt;
| lock all ttys and suspend-to-ram&lt;br /&gt;
|-&lt;br /&gt;
| held power button&lt;br /&gt;
|&lt;br /&gt;
| hibernate&lt;br /&gt;
|-&lt;br /&gt;
| unplugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;conservative&#039; cpufreq governor at above 25% power ; &#039;powersave&#039; governor at 25%.  set hdparam spindown rate lower.&lt;br /&gt;
|-&lt;br /&gt;
| plugged power&lt;br /&gt;
|&lt;br /&gt;
| should switch to &#039;performance&#039; governor.  disable hdparam spindown.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The purpose of the power governor is to regulate the running frequency (GHz) of the processor.&lt;br /&gt;
&lt;br /&gt;
Certain event handlers are are managed through laptop-mode-tools.  If you don&#039;t want the dependency, then you could write ACPI handler scripts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;acpi_listen&amp;lt;/code&amp;gt; can be used to retrieve the event name.&lt;br /&gt;
&lt;br /&gt;
TODO: put scripts below&lt;br /&gt;
&lt;br /&gt;
=== Adjusting the backlight dynamically ===&lt;br /&gt;
&lt;br /&gt;
The backlight may be controlled using sysfs.  The setting is a descendant of &amp;lt;code&amp;gt;/sys/class/backlight/&amp;lt;/code&amp;gt;.  The feature may allow you to echo a value to it.  Use trial and error to discover the values.&lt;br /&gt;
&lt;br /&gt;
The adjustment of the backlight should be function of battery life.  So if it is like 33% battery life, you want to run it near lowest settings but readable.  For 50 percent battery energy maybe 40% light.  For 90% battery maybe 75% light.&lt;br /&gt;
&lt;br /&gt;
=== hdparm ===&lt;br /&gt;
&lt;br /&gt;
To install hdparam do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add hdparm&lt;br /&gt;
&lt;br /&gt;
The settings that laptop-mode-tools messes with is the &amp;lt;code&amp;gt;-S&amp;lt;/code&amp;gt; or the spindown timeout.  It was also hinted that acoustic setting &amp;lt;code&amp;gt;-M&amp;lt;/code&amp;gt; is associated with the speed meaning that louder is faster and quieter is slower which could contribute to the amount of energy used or reduced.&lt;br /&gt;
&lt;br /&gt;
Again you want something like laptop-mode-tools or ACPI to dynamically adjust the settings based on ACPI events.&lt;br /&gt;
&lt;br /&gt;
=== laptop-mode-tools ===&lt;br /&gt;
&lt;br /&gt;
This is currently not in aports but worthy mentioning.  It should really be packaged.  This is a set of scripts to define a power policies.  You can manage all the settings in one place here like the hard drive idle spindown time, CPU governor control, dynamic LCD backlight behavior based on running on battery or AC power supply.&lt;br /&gt;
&lt;br /&gt;
=== cpufreqd ===&lt;br /&gt;
&lt;br /&gt;
This is a useful daemon for regulating power.&lt;br /&gt;
&lt;br /&gt;
To install cpufreqd do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add cpufreqd&lt;br /&gt;
&lt;br /&gt;
Make sure you add the service:&lt;br /&gt;
&lt;br /&gt;
  sudo rc-update add cpufreqd&lt;br /&gt;
&lt;br /&gt;
=== LCD screen refresh rate ===&lt;br /&gt;
&lt;br /&gt;
The refresh rate sets the maximum framerate.  The more frames pushed the more energy consumed on the battery.  You want this adjusted dynamically per certain events.  For gaming, you want it to be the highest as possible for the laptop and vsync off.  For battery use and traveling, you want it capped at 60 FPS/60 Hz or lower but dynamically adjust when you plug in the AC power supply.  You can adjust the framerate with xrandr.  For movies and YouTube, you want 60FPS and vsync on.&lt;br /&gt;
&lt;br /&gt;
== Hacking the kernel ==&lt;br /&gt;
&lt;br /&gt;
You should refer to the [[Custom Kernel]] page for details.&lt;br /&gt;
&lt;br /&gt;
== Hibernation ==&lt;br /&gt;
&lt;br /&gt;
See [[Custom_Kernel#Hibernation_to_prevent_data_loss|Hibernation to prevent data loss]].&lt;br /&gt;
&lt;br /&gt;
== WiFi management ==&lt;br /&gt;
&lt;br /&gt;
Since you are using WiFi, you need a better WiFi management to quickly find open access WiFi access points.  We don&#039;t have all day to debug complexities of WiFi settings while away from home.&lt;br /&gt;
&lt;br /&gt;
To install NetworkManager do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add networkmanager&lt;br /&gt;
&lt;br /&gt;
To find WiFi access points use the &amp;lt;code&amp;gt;nmtui&amp;lt;/code&amp;gt; ncurses interface.&lt;br /&gt;
&lt;br /&gt;
You also need other programs so install them as well:&lt;br /&gt;
&lt;br /&gt;
  apk add wpa-supplicant dhcpcd chrony macchanger wireless-tools iputils&lt;br /&gt;
&lt;br /&gt;
What these programs do:&lt;br /&gt;
&lt;br /&gt;
* wpa-supplicant -- for WPA encryption&lt;br /&gt;
* dhcpcd -- for getting a dynamic IP address&lt;br /&gt;
* chrony -- for fixing the time with the atomic clock&lt;br /&gt;
* wireless-tools -- for additional information&lt;br /&gt;
* macchanger -- for protecting against WiFi access discrimination or increased anonymity.  (optional)&lt;br /&gt;
* iputils -- for the ping command (optional)&lt;br /&gt;
&lt;br /&gt;
You also need to add those services:&lt;br /&gt;
&lt;br /&gt;
  rc-update add chronyd&lt;br /&gt;
  rc-update add wpa_supplicant&lt;br /&gt;
  rc-update add dhcpcd&lt;br /&gt;
  rc-update add networkmanager&lt;br /&gt;
&lt;br /&gt;
To start the services manually (or just reboot):&lt;br /&gt;
&lt;br /&gt;
  rc-service chronyd start&lt;br /&gt;
  rc-service wpa_supplicant start&lt;br /&gt;
  rc-service dhcpcd start&lt;br /&gt;
  rc-service networkmanager start&lt;br /&gt;
&lt;br /&gt;
== Additional tools ==&lt;br /&gt;
&lt;br /&gt;
=== actkbd ===&lt;br /&gt;
&lt;br /&gt;
To control the sound with fn function keys, you need this daemon.  It is currently not in aports.  You could override the design and meaning of those keys with your own scripts and utilities.  This daemon gives you that freedom.&lt;br /&gt;
&lt;br /&gt;
If your laptop contains a brightness key, you want to set that up with this program.  See also [[Setting_up_a_laptop#Adjusting_the_backlight_dynamically | Adjusting the backlight dynamically]].&lt;br /&gt;
&lt;br /&gt;
=== secure-delete ===&lt;br /&gt;
&lt;br /&gt;
Want to prevent cold-boot attack or decrypted keys in memory falling in the wrong hands?  This maybe could work who knows?  From research from cold boot attack, the data can actually stay in memory in minutes, just enough time for a hacker to copy the contents of the memory to a USB thumb drive.&lt;br /&gt;
&lt;br /&gt;
To install secure-delete do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add secure-delete&lt;br /&gt;
&lt;br /&gt;
smem only works for unused ram.[https://github.com/gordonrs/thc-secure-delete]  If you use the vanilla kernel, this may work.  If you use grsecurity, it will automatically sanitize memory if you enable it (but not enabled by default in the Alpine hardened kernel) when the memory page is freed.[https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Sanitize_all_freed_memory]&lt;br /&gt;
&lt;br /&gt;
Close all important programs then call smem.&lt;br /&gt;
&lt;br /&gt;
You call smem in your shutdown script or auto-logoff script.&lt;br /&gt;
&lt;br /&gt;
You can call create a OpenRC shutdown script to run smem when most programs and services are closed.  This will erase all your sensitive plaintext private data just in case.&lt;br /&gt;
&lt;br /&gt;
You may want to create a wrapper script to call smem after your program closes.&lt;br /&gt;
&lt;br /&gt;
You need to write a custom script that does the following:&lt;br /&gt;
  * kill all running processes associated with your user account&lt;br /&gt;
  * auto logoff terminals&lt;br /&gt;
  * for the last terminal closed including all idle xservers, unmount your user home&lt;br /&gt;
  * (optional) use smem to wipe all your plaintext private data in memory after all closed programs in case of cold boot attack&lt;br /&gt;
&lt;br /&gt;
=== Sharing presentations over HDMI ===&lt;br /&gt;
&lt;br /&gt;
If you want to use your laptop to share presentation over HDMI connection, you need libxinerama and xrandr.&lt;br /&gt;
&lt;br /&gt;
To install libxinerama and xrandr do:&lt;br /&gt;
&lt;br /&gt;
  sudo apk add libxinerama xrandr&lt;br /&gt;
&lt;br /&gt;
== Important notes ==&lt;br /&gt;
&lt;br /&gt;
If you lose or break your USB key, that is it and you cannot decrypt your drive.  It would be wise to make a backup of it.&lt;br /&gt;
&lt;br /&gt;
By default, suspend-to-ram or hibernate will not sufficiently clear the AES encryption keys off ram in those phases which would invite a cold boot attack.  This has been covered by the TRESOR kernel patch.[https://en.wikipedia.org/wiki/TRESOR][https://www1.cs.fau.de/tresor]  This patch hasn&#039;t been updated since the 4.x kernel series.[https://www1.cs.fau.de/tresor].  This patch currently only works on 32-bit x86 Linux with SSE and MMX, and on processors with the AES-NI instruction set for x86_64 Linux.  TRESOR doesn&#039;t work with DMA attack, but it can be mitigated by disabling DMA.[https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.303.3053&amp;amp;rep=rep1&amp;amp;type=pdf]  The 32-bit version of TRESOR has only a key size of 128.  The AES-NI version of TRESOR has a largest key size of 256 bit.  See [[Setting_up_a_laptop#Choosing_ciphers | Choosing ciphers]] for the number of rounds cracked.&lt;br /&gt;
&lt;br /&gt;
Loop-Amnesia works with LoopAES and is only for 64 bit Linux and only supports 128 bit keys but can result in data loss if their recommendations are not followed. [https://moongate.ydns.eu/amnesia.html]&lt;br /&gt;
&lt;br /&gt;
Please read the Wikipedia article on Cold Boot Attack especially the mitigation section.[https://en.wikipedia.org/wiki/Cold_boot_attack] Full disk encryption will not protect your data especially for older hardware if you do not have the proper mitigation (implying not full proof) prerequisites such as a patched kernel, memory scrambling, permanent memory module mounting for example.&lt;br /&gt;
&lt;br /&gt;
If you have a different but fully encrypted device like iPad, you still can be rubberhosed or interrogated with a perfect deniable encrypted laptop.  This guide doesn&#039;t protect you from that possibility.  If you do not want to be rubberhosed, don&#039;t possess those devices.&lt;br /&gt;
&lt;br /&gt;
Additional tips to mitigate against a DMA Attack to exfiltrate encryption keys:&lt;br /&gt;
&lt;br /&gt;
Disable DMA in the BIOS and set the password for the BIOS according to Wikipedia.[https://en.wikipedia.org/wiki/DMA_attack]&lt;br /&gt;
&lt;br /&gt;
Blacklist kernel modules that use DMA and any unused expansion modules (FireWire, CardBus, ExpressCard, Thunderbolt, USB 3.0, PCI Express and hotplug modules) that use DMA.&lt;br /&gt;
&lt;br /&gt;
You may need a custom (or customize a) BIOS or use Intel TXT or TPM which will authenticate the boot devices or boot from specific serial numbers not just any.  For cold boot attack, it is not required to remove the RAM but to to slow down the rate of decay of the RAM module with liquid air in addition an USB thumb drive containing an encryption key retriever bypassing the operating system.[https://youtu.be/XfUlRsE3ymQ]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[category: Desktop]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=25388</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=25388"/>
		<updated>2023-10-25T06:22:22Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Marcelina H. */ update editor&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina H. ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
=== [https://mjholub.me/ Website]===&lt;br /&gt;
&#039;&#039;&#039;Current city:&#039;&#039;&#039; Kraków, PL&lt;br /&gt;
&lt;br /&gt;
Tech stack (mostly): Go, Rust, TS&lt;br /&gt;
&lt;br /&gt;
Setup: Sway, Waybar, Rofi, Fish, Lazyvim, foot, Librewolf&lt;br /&gt;
 &lt;br /&gt;
Libre software and privacy/digital rights enthusiast and advocate (aren&#039;t we all?).&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=25387</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=25387"/>
		<updated>2023-10-25T06:22:01Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Marcelina Hołub */ refactor&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina H. ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
=== [https://mjholub.me/ Website]===&lt;br /&gt;
&#039;&#039;&#039;Current city:&#039;&#039;&#039; Kraków, PL&lt;br /&gt;
&lt;br /&gt;
Tech stack (mostly): Go, Rust, TS&lt;br /&gt;
&lt;br /&gt;
Setup: Sway, Waybar, Rofi, Fish, Lapce, foot, Librewolf&lt;br /&gt;
 &lt;br /&gt;
Libre software and privacy/digital rights enthusiast and advocate (aren&#039;t we all?).&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=25386</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=25386"/>
		<updated>2023-10-25T06:20:03Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Creating additional profiles */ mention that kernel log level should be set back to less verbose afterwards&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC right}}&lt;br /&gt;
&lt;br /&gt;
AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install &amp;lt;code&amp;gt;apparmor-utils&amp;lt;/code&amp;gt; if you want to use the &amp;lt;code&amp;gt;aa&amp;lt;/code&amp;gt; command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use sudo -e) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the &amp;lt;code&amp;gt;&#039;&#039;&#039;APPEND&#039;&#039;&#039;&amp;lt;/code&amp;gt; line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &amp;lt;code&amp;gt;&#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039;&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;/etc/default/grub&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell [[OpenRC]] to start it on boot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command &amp;lt;code&amp;gt;aa-enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot following installation&lt;br /&gt;
&lt;br /&gt;
=== Enabling Extra Profiles ===&lt;br /&gt;
&lt;br /&gt;
Extra profiles reside in {{Path|/usr/share/apparmor/extra-profiles/}}. In order to enable to profile, it needs to be copied to {{Path|/etc/apparmor.d/}}:&lt;br /&gt;
&lt;br /&gt;
If you want to enable the profile for &amp;lt;code&amp;gt;usr.bin.chromium-browser&amp;lt;/code&amp;gt;, for example:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# cp /usr/share/apparmor/extra-profiles/usr.bin.chromium-browser /etc/apparmor.d/}}&lt;br /&gt;
&lt;br /&gt;
This will &#039;&#039;install&#039;&#039; the profile, it then needs to be set to &#039;&#039;&#039;complain&#039;&#039;&#039; or &#039;&#039;&#039;enforce&#039;&#039;&#039; mode:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-complain /etc/apparmor.d/usr.bin.chromium-browser}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Note|Use &amp;lt;code&amp;gt;aa-enforce&amp;lt;/code&amp;gt; to set it to enforce mode, &#039;&#039;&#039;but beware that this could break functionality&#039;&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
=== Creating additional profiles ===&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-genprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that for this to work you&#039;ll probably need to set a more verbose [https://linuxconfig.org/introduction-to-the-linux-kernel-log-levels kernel log level]. For improved security, set it back to a higher level afterwards.&lt;br /&gt;
&lt;br /&gt;
== Use ==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running &amp;lt;code&amp;gt;aa-status&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;aa-enabled&amp;lt;/code&amp;gt; in the terminal. If the output mentions AppArmor being disabled at boot, re-open your &amp;lt;code&amp;gt;/boot/extlinux.conf&amp;lt;/code&amp;gt; file and make sure the &#039;&#039;&#039;APPEND&#039;&#039;&#039; line still ends with &amp;lt;code&amp;gt;lsm=landlock,yama,apparmor&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.apparmor.net/ AppArmor Wiki]&lt;br /&gt;
* [https://wiki.debian.org/AppArmor/HowToUse Debian Wiki: How to use AppArmor]&lt;br /&gt;
* [https://wiki.archlinux.org/title/AppArmor AppArmor entry on ArchWiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Kernel]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=25385</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=25385"/>
		<updated>2023-10-25T06:17:11Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Steam games launched via Proton crash before creating a window */ mention proton-ge with a disclaimer that it&amp;#039;ll only work with nix, with a warning on potential privacy risks, with a link to steam&amp;#039;s TOSDR&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{:Include:Setup_Device_Manager}}&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# adduser $USER input&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; adduser $USER video&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add font-dejavu}}&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add seatd&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; rc-update add seatd&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; rc-service seatd start&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; adduser $USER seat&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add sway&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
For complimentary software alternatives, see for example [https://wiki.gentoo.org/wiki/List_of_software_for_Wayland this list at Gentoo Wiki.]&lt;br /&gt;
&lt;br /&gt;
Configure [[Wayland#XDG_RUNTIME_DIR|XDG_RUNTIME_DIR]].&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable [[D-Bus]] and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to the value exported by &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt;. In order to ensure that Pipewire and related services inherit the right environment variables, it is recommended to start these services via a process that is a direct descendant of sway itself.&lt;br /&gt;
&lt;br /&gt;
Launch Sway with a D-Bus server available, use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|dbus-run-session -- sway #prepend with exec in your login shell init script}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch pipewire on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* xdg-desktop-portal will start xdg-desktop-portal-wlr when needed, but needs a few environment variables. Unless &amp;lt;code&amp;gt;dbus-daemon&amp;lt;/code&amp;gt; is a descendant of the &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt; process, add to the sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|export MOZ_ENABLE_WAYLAND {{=}}&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP{{=}}sway&lt;br /&gt;
export QT_QPA_PLATFORM{{=}}&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Flatpaks ===&lt;br /&gt;
&lt;br /&gt;
Due to their sandboxing, flatpaks require the use of a portal frontend (xdg-desktop-portal) and backends (such as xdg-desktop-portal-wlr, xdg-desktop-portal-gtk, xdg-desktop-portal-gnome) that implement the methods. When in doubt, install multiple backends. For more information on backends, see [https://github.com/flatpak/xdg-desktop-portal/#using-portals flatpak&#039;s page on the subject]. In addition to the steps under the &amp;quot;Firefox Screensharing&amp;quot; section, it may also be necessary to launch additional backends in your Sway config file. Otherwise, you may run into GDBus errors as your flatpak fails to interface with the portal. This can cause issues such as with opening your file directories from a flatpak application.&lt;br /&gt;
&lt;br /&gt;
After installing different backends, you might need to add the relevant backends to your sway config file similarly to in the &amp;quot;Firefox Screensharing&amp;quot; section above. For example, an autostart section of your sway config file may include:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-gtk&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-gnome&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is only needed if they are not started automatically via other means.&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE{{=}}2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI{{=}}&amp;quot;physical&amp;quot;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI{{=}}192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM{{=}}&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strike&amp;gt;Install clipman from testing repo and add the following to sway config:&amp;lt;/strike&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the clipman project has been abandoned and deleted from GitHub. Use [https://github.com/sentriz/cliphist cliphist] instead, which is also available in the testing repository. &lt;br /&gt;
See [https://github.com/sentriz/cliphist#picker-examples picker examples] section on the project&#039;s page to add an appropriate keybinding line to your sway config.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Firefox picture-in-picture mode/floating windows ===&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Screenshots ===&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/swaywm/sway/wiki/Useful-add-ons-for-sway the sway wiki&#039;s article] for a list of screenshot tools.&lt;br /&gt;
&lt;br /&gt;
=== Start with NumLock enabled ===&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change cursor theme and size ===&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
=== Start as a service ===&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/init.d/sway|#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description{{=}}&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command{{=}}&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args{{=}}&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile{{=}}&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args{{=}}&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Then run&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# chmod +x /etc/init.d/sway}}&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-update add sway default}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have {{Pkg|elogind}} installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
=== Custom keyboard layout ===&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
=== Firefox (Flatpak) and/or GTK apps ===&lt;br /&gt;
==== Disappearing cursor ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;about:config&#039;&#039; and set &amp;lt;code&amp;gt;widget.use-xdg-desktop-portal.file-picker&amp;lt;/code&amp;gt; to 0.&lt;br /&gt;
&lt;br /&gt;
=== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ===&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
=== Sway socket not detected ===&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Steam games launched via Proton crash before creating a window ===&lt;br /&gt;
&lt;br /&gt;
Instead of just using the in-Steam menu to install and select a Proton version, try installing the flatpak community build for Proton onto your system. There are several versions, depending on your desired stability, and the experimental version available in Flathub is called &amp;quot;com.valvesoftware.Steam.CompatibilityTool.Proton-Exp&amp;quot;. After you install your chosen version, go into Steam to specify compatibility tool for a game as usual. The installed community build will now be an option. Select that and try launching the game again.&lt;br /&gt;
&lt;br /&gt;
As your last resort, you can try installing [https://github.com/GloriousEggroll/proton-ge-custom proton-ge-custom], but please note that in order for this to be even detected by Steam, you will need to install Steam via Nix due to high level of isolation that Flatpaks utilize. This can however come at the expense of your [https://tosdr.org/en/service/180 privacy].&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/title/Sway Archwiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
[[Category:Window Managers]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=25384</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=25384"/>
		<updated>2023-10-25T06:04:39Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Make clipboard content persistent */ mention cliphist since clipman has been abandoned&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{:Include:Setup_Device_Manager}}&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# adduser $USER input&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; adduser $USER video&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add font-dejavu}}&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add seatd&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; rc-update add seatd&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; rc-service seatd start&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; adduser $USER seat&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add sway&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
For complimentary software alternatives, see for example [https://wiki.gentoo.org/wiki/List_of_software_for_Wayland this list at Gentoo Wiki.]&lt;br /&gt;
&lt;br /&gt;
Configure [[Wayland#XDG_RUNTIME_DIR|XDG_RUNTIME_DIR]].&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable [[D-Bus]] and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to the value exported by &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt;. In order to ensure that Pipewire and related services inherit the right environment variables, it is recommended to start these services via a process that is a direct descendant of sway itself.&lt;br /&gt;
&lt;br /&gt;
Launch Sway with a D-Bus server available, use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|dbus-run-session -- sway #prepend with exec in your login shell init script}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch pipewire on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* xdg-desktop-portal will start xdg-desktop-portal-wlr when needed, but needs a few environment variables. Unless &amp;lt;code&amp;gt;dbus-daemon&amp;lt;/code&amp;gt; is a descendant of the &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt; process, add to the sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|export MOZ_ENABLE_WAYLAND {{=}}&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP{{=}}sway&lt;br /&gt;
export QT_QPA_PLATFORM{{=}}&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Flatpaks ===&lt;br /&gt;
&lt;br /&gt;
Due to their sandboxing, flatpaks require the use of a portal frontend (xdg-desktop-portal) and backends (such as xdg-desktop-portal-wlr, xdg-desktop-portal-gtk, xdg-desktop-portal-gnome) that implement the methods. When in doubt, install multiple backends. For more information on backends, see [https://github.com/flatpak/xdg-desktop-portal/#using-portals flatpak&#039;s page on the subject]. In addition to the steps under the &amp;quot;Firefox Screensharing&amp;quot; section, it may also be necessary to launch additional backends in your Sway config file. Otherwise, you may run into GDBus errors as your flatpak fails to interface with the portal. This can cause issues such as with opening your file directories from a flatpak application.&lt;br /&gt;
&lt;br /&gt;
After installing different backends, you might need to add the relevant backends to your sway config file similarly to in the &amp;quot;Firefox Screensharing&amp;quot; section above. For example, an autostart section of your sway config file may include:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-gtk&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-gnome&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is only needed if they are not started automatically via other means.&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE{{=}}2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI{{=}}&amp;quot;physical&amp;quot;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI{{=}}192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM{{=}}&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strike&amp;gt;Install clipman from testing repo and add the following to sway config:&amp;lt;/strike&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the clipman project has been abandoned and deleted from GitHub. Use [https://github.com/sentriz/cliphist cliphist] instead, which is also available in the testing repository. &lt;br /&gt;
See [https://github.com/sentriz/cliphist#picker-examples picker examples] section on the project&#039;s page to add an appropriate keybinding line to your sway config.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Firefox picture-in-picture mode/floating windows ===&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Screenshots ===&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/swaywm/sway/wiki/Useful-add-ons-for-sway the sway wiki&#039;s article] for a list of screenshot tools.&lt;br /&gt;
&lt;br /&gt;
=== Start with NumLock enabled ===&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change cursor theme and size ===&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
=== Start as a service ===&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/init.d/sway|#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description{{=}}&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command{{=}}&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args{{=}}&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile{{=}}&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args{{=}}&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Then run&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# chmod +x /etc/init.d/sway}}&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-update add sway default}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have {{Pkg|elogind}} installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
=== Custom keyboard layout ===&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
=== Firefox (Flatpak) and/or GTK apps ===&lt;br /&gt;
==== Disappearing cursor ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;about:config&#039;&#039; and set &amp;lt;code&amp;gt;widget.use-xdg-desktop-portal.file-picker&amp;lt;/code&amp;gt; to 0.&lt;br /&gt;
&lt;br /&gt;
=== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ===&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
=== Sway socket not detected ===&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Steam games launched via Proton crash before creating a window ===&lt;br /&gt;
&lt;br /&gt;
Instead of just using the in-Steam menu to install and select a Proton version, try installing the flatpak community build for Proton onto your system. There are several versions, depending on your desired stability, and the experimental version available in Flathub is called &amp;quot;com.valvesoftware.Steam.CompatibilityTool.Proton-Exp&amp;quot;. After you install your chosen version, go into Steam to specify compatibility tool for a game as usual. The installed community build will now be an option. Select that and try launching the game again.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/title/Sway Archwiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
[[Category:Window Managers]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=25383</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=25383"/>
		<updated>2023-10-25T05:52:25Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Installation */ link with alt. complimentary software list from gentoo wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{:Include:Setup_Device_Manager}}&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# adduser $USER input&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; adduser $USER video&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add font-dejavu}}&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add seatd&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; rc-update add seatd&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; rc-service seatd start&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; adduser $USER seat&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add sway&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
For complimentary software alternatives, see for example [https://wiki.gentoo.org/wiki/List_of_software_for_Wayland this list at Gentoo Wiki.]&lt;br /&gt;
&lt;br /&gt;
Configure [[Wayland#XDG_RUNTIME_DIR|XDG_RUNTIME_DIR]].&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable [[D-Bus]] and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to the value exported by &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt;. In order to ensure that Pipewire and related services inherit the right environment variables, it is recommended to start these services via a process that is a direct descendant of sway itself.&lt;br /&gt;
&lt;br /&gt;
Launch Sway with a D-Bus server available, use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|dbus-run-session -- sway #prepend with exec in your login shell init script}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch pipewire on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* xdg-desktop-portal will start xdg-desktop-portal-wlr when needed, but needs a few environment variables. Unless &amp;lt;code&amp;gt;dbus-daemon&amp;lt;/code&amp;gt; is a descendant of the &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt; process, add to the sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|export MOZ_ENABLE_WAYLAND {{=}}&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP{{=}}sway&lt;br /&gt;
export QT_QPA_PLATFORM{{=}}&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Flatpaks ===&lt;br /&gt;
&lt;br /&gt;
Due to their sandboxing, flatpaks require the use of a portal frontend (xdg-desktop-portal) and backends (such as xdg-desktop-portal-wlr, xdg-desktop-portal-gtk, xdg-desktop-portal-gnome) that implement the methods. When in doubt, install multiple backends. For more information on backends, see [https://github.com/flatpak/xdg-desktop-portal/#using-portals flatpak&#039;s page on the subject]. In addition to the steps under the &amp;quot;Firefox Screensharing&amp;quot; section, it may also be necessary to launch additional backends in your Sway config file. Otherwise, you may run into GDBus errors as your flatpak fails to interface with the portal. This can cause issues such as with opening your file directories from a flatpak application.&lt;br /&gt;
&lt;br /&gt;
After installing different backends, you might need to add the relevant backends to your sway config file similarly to in the &amp;quot;Firefox Screensharing&amp;quot; section above. For example, an autostart section of your sway config file may include:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-gtk&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-gnome&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is only needed if they are not started automatically via other means.&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE{{=}}2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI{{=}}&amp;quot;physical&amp;quot;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI{{=}}192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM{{=}}&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Firefox picture-in-picture mode/floating windows ===&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Screenshots ===&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [https://github.com/swaywm/sway/wiki/Useful-add-ons-for-sway the sway wiki&#039;s article] for a list of screenshot tools.&lt;br /&gt;
&lt;br /&gt;
=== Start with NumLock enabled ===&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change cursor theme and size ===&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
=== Start as a service ===&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/init.d/sway|#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description{{=}}&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command{{=}}&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args{{=}}&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile{{=}}&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args{{=}}&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Then run&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# chmod +x /etc/init.d/sway}}&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-update add sway default}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have {{Pkg|elogind}} installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
=== Custom keyboard layout ===&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
=== Firefox (Flatpak) and/or GTK apps ===&lt;br /&gt;
==== Disappearing cursor ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;about:config&#039;&#039; and set &amp;lt;code&amp;gt;widget.use-xdg-desktop-portal.file-picker&amp;lt;/code&amp;gt; to 0.&lt;br /&gt;
&lt;br /&gt;
=== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ===&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
=== Sway socket not detected ===&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Steam games launched via Proton crash before creating a window ===&lt;br /&gt;
&lt;br /&gt;
Instead of just using the in-Steam menu to install and select a Proton version, try installing the flatpak community build for Proton onto your system. There are several versions, depending on your desired stability, and the experimental version available in Flathub is called &amp;quot;com.valvesoftware.Steam.CompatibilityTool.Proton-Exp&amp;quot;. After you install your chosen version, go into Steam to specify compatibility tool for a game as usual. The installed community build will now be an option. Select that and try launching the game again.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/title/Sway Archwiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
[[Category:Window Managers]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23129</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23129"/>
		<updated>2023-04-11T01:24:11Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Additional profiles */ fix spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use sudo -e) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039; to /etc/default/grub:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
or&lt;br /&gt;
{{Cmd|# aa-genprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that for this to work you&#039;ll probably need to set a more verbose [https://linuxconfig.org/introduction-to-the-linux-kernel-log-levels kernel log level.]&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23128</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23128"/>
		<updated>2023-04-11T01:23:33Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Additional profiles */ add info that profiling requires a more verbose kernel log level.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use sudo -e) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039; to /etc/default/grub:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
or&lt;br /&gt;
{{Cmd|# aa-genprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that for this to work you&#039;ll probably need to set a more vebose [https://linuxconfig.org/introduction-to-the-linux-kernel-log-levels kernel log level.]&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23127</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23127"/>
		<updated>2023-04-11T01:18:37Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* With GRUB */ clarify which file to edit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use sudo -e) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039; to /etc/default/grub:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
or&lt;br /&gt;
{{Cmd|# aa-genprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23118</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23118"/>
		<updated>2023-04-09T03:05:40Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: fix: missing line break&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
=== [https://mjholub.me/ Website]===&lt;br /&gt;
&#039;&#039;&#039;Current city:&#039;&#039;&#039; Kraków, PL&lt;br /&gt;
&lt;br /&gt;
Tech stack (mostly): Go, Rust, TS&lt;br /&gt;
&lt;br /&gt;
Setup: Sway, Waybar, Rofi, Fish, Lapce, foot, Librewolf&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. A staunch privacy/digital rights enthusiast and advocate.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23117</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23117"/>
		<updated>2023-04-09T03:05:16Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: fix city formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
=== [https://mjholub.me/ Website]===&lt;br /&gt;
&#039;&#039;&#039;Current city:&#039;&#039;&#039; Kraków, PL&lt;br /&gt;
&lt;br /&gt;
Tech stack (mostly): Go, Rust, TS&lt;br /&gt;
Setup: Sway, Waybar, Rofi, Fish, Lapce, foot, Librewolf&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. A staunch privacy/digital rights enthusiast and advocate.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23116</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23116"/>
		<updated>2023-04-09T03:04:53Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: add country&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
=== [https://mjholub.me/ Website]===&lt;br /&gt;
=== &#039;&#039;&#039;Current city:&#039;&#039;&#039; === Kraków, PL&lt;br /&gt;
&lt;br /&gt;
Tech stack (mostly): Go, Rust, TS&lt;br /&gt;
Setup: Sway, Waybar, Rofi, Fish, Lapce, foot, Librewolf&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. A staunch privacy/digital rights enthusiast and advocate.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23115</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=23115"/>
		<updated>2023-04-09T03:04:34Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Marcelina Hołub */ add setup, simplify tech stack, add website&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
=== [https://mjholub.me/ Website]===&lt;br /&gt;
===== &#039;&#039;&#039;Current city:&#039;&#039;&#039; ===== Kraków&lt;br /&gt;
&lt;br /&gt;
Tech stack (mostly): Go, Rust, TS&lt;br /&gt;
Setup: Sway, Waybar, Rofi, Fish, Lapce, foot, Librewolf&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. A staunch privacy/digital rights enthusiast and advocate.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23114</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23114"/>
		<updated>2023-04-09T03:01:24Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Additional profiles */ feat: add aa-genprof as an alternative&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use sudo -e) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
or&lt;br /&gt;
{{Cmd|# aa-genprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23113</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23113"/>
		<updated>2023-04-09T03:00:33Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* With SYSLINUX */ fix: rm nonexistent inline code template ref. for sudo -e&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use sudo -e) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23112</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23112"/>
		<updated>2023-04-09T02:59:51Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* With GRUB */ fix: remove nonexistent ref to inline code tpl&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use {{Inline-code |sudo -e}}) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key &#039;&#039;&#039;GRUB_CMDLINE_LINUX_DEFAULT&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23111</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23111"/>
		<updated>2023-04-09T02:58:56Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: deduplicate profile obtaining instructions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use {{Inline-code |sudo -e}}) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key {{Inline-code |GRUB_CMDLINE_LINUX_DEFAULT}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23110</id>
		<title>AppArmor</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppArmor&amp;diff=23110"/>
		<updated>2023-04-09T02:56:25Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Setup */ add instructions for GRUB, describe creating your own profiles and getting the default ones&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AppArmor is a kernel security module that restricts individual programs&#039; capabilities. This can allow administrators to prevent programs accessing system resources in malicious ways according to per-applications specifications. AppArmor works by following profiles, which dictate what each application is and is not allowed to do. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should also install apparmor-utils if you want to use the aa command to interact with AppArmor.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-utils}}}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
Run the command {{Cmd|# cat /sys/kernel/security/lsm}} to see what linux security modules are currently setup. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== With SYSLINUX ===&lt;br /&gt;
&lt;br /&gt;
Use a text editor of your choice (preferably a TUI based one since some GUI setups don&#039;t work with privilege escalation, unless you use {{Inline-code |sudo -e}}) to edit &amp;lt;pre&amp;gt;/boot/extlinux.conf&amp;lt;/pre&amp;gt; such that the APPEND line ends with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
lsm=landlock,yama,apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that because you&#039;re including lsm in this .conf file you are overriding the default lsm. Thus, you should include any lsm that you saw previously running in the above cat command. Additionally, lsm initializes these modules in order, so their position is important in regards to major/minor modules. Ensure that apparmor is placed first among major modules. Note for convenience that yama, capability, and landlock, which come with Alpine Linux, are not major modules, and apparmor can be placed after them. The module called capability is automatically included and does not need to be written in. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With GRUB ===&lt;br /&gt;
&lt;br /&gt;
Add the following at the end of the value for key {{Inline-code |GRUB_CMDLINE_LINUX_DEFAULT}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apparmor=1 security=apparmor&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then apply with:&lt;br /&gt;
{{Cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, start AppArmor and tell openrc to start it on boot.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# rc-service apparmor start}}&lt;br /&gt;
{{Cmd|# rc-update add apparmor boot}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can check if AppArmor is running with the command aa-enabled&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-enabled}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you notice that&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
doesn&#039;t report any profiles to be loaded, then you should run&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add apparmor-profiles}}&lt;br /&gt;
&lt;br /&gt;
then reload apparmor by restarting the system.&lt;br /&gt;
&lt;br /&gt;
== Additional profiles ==&lt;br /&gt;
&lt;br /&gt;
The profiles provided by the apparmor-profiles package are just a starter. You can create your own profiles by running&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-easyprof &amp;lt;binary name&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
AppArmor works using rules established in profiles. A set of pre-made profiles is available for ease of use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add {{Pkg|apparmor-profiles}}}}&lt;br /&gt;
&lt;br /&gt;
Reboot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use==&lt;br /&gt;
&lt;br /&gt;
View AppArmor&#039;s report with the command aa-status&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# aa-status}}&lt;br /&gt;
&lt;br /&gt;
This details how many and what profiles are in use as well as relevant findings, such as how many profiles are in complain mode or in kill mode.&lt;br /&gt;
&lt;br /&gt;
==Troubleshoot==&lt;br /&gt;
&lt;br /&gt;
If you notice a bunch of AppArmor errors on boot, try running aa-status and aa-enabled in the terminal. If the output mentions AppArmor being disabled at boot, re-open your /boot/extlinux.conf file and make sure the APPEND line still ends with lsm=landlock,yama,apparmor&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Rsnapshot&amp;diff=23088</id>
		<title>Rsnapshot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Rsnapshot&amp;diff=23088"/>
		<updated>2023-03-26T05:49:44Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Automation */ add a script to write the contents of each file&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://rsnapshot.org/ &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt;] is a filesystem backup utility based on [[rsync|&amp;lt;samp&amp;gt;rsync&amp;lt;/samp&amp;gt;]]. Using &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt;, it is possible to take snapshots of your filesystems at different points in time. Using hard links, rsnapshot creates the illusion of multiple full backups, while only taking up the space of one full backup plus differences. When coupled with &amp;lt;samp&amp;gt;ssh&amp;lt;/samp&amp;gt;, it is possible to take snapshots of remote filesystems as well. This document is a tutorial on the installation and configuration of rsnapshot.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
To install rsnapshot:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apk add rsnapshot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
To configure &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt;, copy the example configuration &amp;lt;samp&amp;gt;/etc/rsnapshot.conf.default&amp;lt;/samp&amp;gt; to &amp;lt;samp&amp;gt;/etc/rsnapshot.conf&amp;lt;/samp&amp;gt;, and edit it to your needs based on the comments and the [http://rsnapshot.org/rsnapshot/docs/docbook/rest.html official documentation]. Note that &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt; requires tabs between options and values in &amp;lt;samp&amp;gt;rsnapshot.conf&amp;lt;/samp&amp;gt;. This is done so spaces can be included in filenames without requiring any extra escaping or quoting.&lt;br /&gt;
&lt;br /&gt;
The most important parts to modify are where to store the backups:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
snapshot_root	/mnt/backup&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
How many backups to retain:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
retain	daily	7&lt;br /&gt;
retain	weekly	4&lt;br /&gt;
retain	monthly	12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And what to backup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Local&lt;br /&gt;
backup	/home/			local/&lt;br /&gt;
backup	/etc/			local/&lt;br /&gt;
&lt;br /&gt;
# Remote&lt;br /&gt;
backup	user@remote:/home/user/	remote/		exclude=/home/user/Downloads&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, every 7th &amp;lt;samp&amp;gt;daily&amp;lt;/samp&amp;gt; backup is saved as a &amp;lt;samp&amp;gt;weekly&amp;lt;/samp&amp;gt; backup, every 4th &amp;lt;samp&amp;gt;weekly&amp;lt;/samp&amp;gt; backup is retained as a &amp;lt;samp&amp;gt;monthly&amp;lt;/samp&amp;gt; backup, and every 12th &amp;lt;samp&amp;gt;monthly&amp;lt;/samp&amp;gt; backup is deleted. The folders &amp;lt;samp&amp;gt;/home&amp;lt;/samp&amp;gt; and &amp;lt;samp&amp;gt;/etc&amp;lt;/samp&amp;gt; from the local machine are backed up to &amp;lt;samp&amp;gt;/mnt/backup/local/&amp;lt;/samp&amp;gt;, while it uses &amp;lt;samp&amp;gt;ssh&amp;lt;/samp&amp;gt; to back up the folder &amp;lt;samp&amp;gt;/home/user&amp;lt;/samp&amp;gt; on the machine &amp;lt;samp&amp;gt;remote&amp;lt;/samp&amp;gt; to &amp;lt;samp&amp;gt;/mnt/backup/remote/&amp;lt;/samp&amp;gt;. Make sure &amp;lt;samp&amp;gt;root&amp;lt;/samp&amp;gt; has passwordless &amp;lt;samp&amp;gt;ssh&amp;lt;/samp&amp;gt; access to the machines you want to backup over the internet (i.e. run &amp;lt;samp&amp;gt;ssh-keygen&amp;lt;/samp&amp;gt; and &amp;lt;samp&amp;gt;ssh-copy-id&amp;lt;/samp&amp;gt; as &amp;lt;samp&amp;gt;root&amp;lt;/samp&amp;gt;).&amp;lt;BR&amp;gt;&lt;br /&gt;
The last line also shows an example of how you can exclude parts of the location from backups.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
To test that your config file has the correct syntax:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rsnapshot configtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To check what the system would do when running a backup without executing the commands, i.e. a dry run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rsnapshot -t daily&lt;br /&gt;
rsnapshot -t weekly&lt;br /&gt;
rsnapshot -t monthly&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, perform the first backup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rsnapshot daily&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The last part might take a while. Subsequent backups should be much faster, as it will then only have to copy files that have changed since the last backup.&lt;br /&gt;
&lt;br /&gt;
== Automation ==&lt;br /&gt;
After setting up and testing &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt; as described above, the next step is to make [[cron|&amp;lt;samp&amp;gt;cron&amp;lt;/samp&amp;gt;]] automatically run &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt; at fixed intervals. The easiest way to achieve this is to create a few scripts in the folders &amp;lt;samp&amp;gt;/etc/periodic/*&amp;lt;/samp&amp;gt; that &amp;lt;samp&amp;gt;crond&amp;lt;/samp&amp;gt; monitors. The script below will write the appropriate contents to those files and make them executable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
cd /etc/periodic&lt;br /&gt;
dirs=(&amp;quot;daily&amp;quot; &amp;quot;weekly&amp;quot; &amp;quot;monthly&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
for dir in &amp;quot;${dirs[@]}&amp;quot;; do&lt;br /&gt;
    echo -e &amp;quot;#!/bin/sh\nexec /usr/bin/rsnapshot $dir&amp;quot; &amp;gt; &amp;quot;$dir/rsnapshot&amp;quot;&lt;br /&gt;
    chmod +x &amp;quot;$dir/rsnapshot&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/periodic/daily/rsnapshot|#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
exec /usr/bin/rsnapshot daily&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/periodic/weekly/rsnapshot|#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
exec /usr/bin/rsnapshot weekly&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/periodic/monthly/rsnapshot|#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
exec /usr/bin/rsnapshot monthly&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remember to make the scripts executable:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chmod +x /etc/periodic/*/rsnapshot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
After that, test that the scripts work as expected:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
run-parts /etc/periodic/daily&lt;br /&gt;
run-parts /etc/periodic/weekly&lt;br /&gt;
run-parts /etc/periodic/monthly&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Assuming &amp;lt;samp&amp;gt;crond&amp;lt;/samp&amp;gt; is set to start at boot (the default), your system should now make backups automatically.&lt;br /&gt;
&lt;br /&gt;
[[Category:System Administration]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22843</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22843"/>
		<updated>2023-01-03T22:14:18Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: Merge tips&amp;amp;tricks with configuration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Firefox picture-in-picture mode/floating windows ===&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Screenshots ===&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Start with NumLock enabled ===&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Change cursor theme and size ===&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
=== Start as a service ===&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
=== Custom keyboard layout ===&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
=== Firefox (Flatpak) and/or GTK apps ===&lt;br /&gt;
==== Disappearing cursor ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;about:config&#039;&#039; and set &amp;lt;code&amp;gt;widget.use-xdg-desktop-portal.file-picker&amp;lt;/code&amp;gt; to 0.&lt;br /&gt;
&lt;br /&gt;
=== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ===&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
=== Sway socket not detected ===&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22842</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22842"/>
		<updated>2023-01-03T22:10:55Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Troubleshooting */ increase heading levels, reorganize sections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
=== Firefox (Flatpak) and/or GTK apps ===&lt;br /&gt;
==== Disappearing cursor ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;about:config&#039;&#039; and set &amp;lt;code&amp;gt;widget.use-xdg-desktop-portal.file-picker&amp;lt;/code&amp;gt; to 0.&lt;br /&gt;
&lt;br /&gt;
=== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ===&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
=== Sway socket not detected ===&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22841</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22841"/>
		<updated>2023-01-03T22:07:23Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Missing file picker in Firefox (Flatpak)/cannot download */ fix formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;about:config&#039;&#039; and set &amp;lt;code&amp;gt;widget.use-xdg-desktop-portal.file-picker&amp;lt;/code&amp;gt; to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22840</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22840"/>
		<updated>2023-01-03T22:06:40Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Missing file picker in Firefox (Flatpak)/cannot download */ fix URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to about:config and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22839</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22839"/>
		<updated>2023-01-03T22:06:18Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Missing file picker in Firefox (Flatpak)/cannot download */ fix URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to [about:config about:config] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22838</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22838"/>
		<updated>2023-01-03T22:04:40Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Screenshots */ add missing &amp;lt;pre&amp;gt; tags&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22837</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22837"/>
		<updated>2023-01-03T22:04:00Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Firefox picture-in-picture mode/floating windows */  change librewolf to firefox&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;firefox&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22836</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22836"/>
		<updated>2023-01-03T22:03:18Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Custom keyboard layout */  fix unclosed &amp;lt;pre&amp;gt; tags&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;my_layout&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22835</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22835"/>
		<updated>2023-01-03T22:00:38Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Tips and tricks */ convert numbered lists into headers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
==== Firefox picture-in-picture mode/floating windows ====&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Screenshots ====&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
==== Start with NumLock enabled ====&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Change cursor theme and size ====&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
==== Start as a service ====&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
==== Custom keyboard layout ====&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;niro&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22834</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22834"/>
		<updated>2023-01-03T21:59:25Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Troubleshooting */ change numbered lists into headers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
==== Disappearing cursor in GTK apps or in Firefox (Flatpak) ====&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme      for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Missing file picker in Firefox (Flatpak)/cannot download ====&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
==== Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start ====&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Sway socket not detected ====&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
# Firefox picture-in-picture mode/floating windows&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Screenshots&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
# Start with NumLock enabled&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Change cursor theme and size&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
#Start as a service&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
# Custom keyboard layout&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;niro&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22833</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22833"/>
		<updated>2023-01-03T21:55:42Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Installation */  fix a typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt;), or lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
# Disappearing cursor in GTK apps or in Firefox (Flatpak)&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Missing file picker in Firefox (Flatpak)/cannot download&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
# Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
# Sway socket not detected&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
# Firefox picture-in-picture mode/floating windows&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Screenshots&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
# Start with NumLock enabled&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Change cursor theme and size&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
#Start as a service&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
# Custom keyboard layout&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;niro&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22828</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22828"/>
		<updated>2022-12-31T01:52:23Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Installation */ fix incorrectly closed &amp;lt;code&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt; on lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/code&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
# Disappearing cursor in GTK apps or in Firefox (Flatpak)&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Missing file picker in Firefox (Flatpak)/cannot download&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
# Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
# Sway socket not detected&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
# Firefox picture-in-picture mode/floating windows&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Screenshots&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
# Start with NumLock enabled&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Change cursor theme and size&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
#Start as a service&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
# Custom keyboard layout&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;niro&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22827</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22827"/>
		<updated>2022-12-31T01:01:02Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: fix missing command for suspending without elogind&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run &amp;lt;code&amp;gt;echo mem &amp;gt; /sys/power/state as a root&amp;lt;/code&amp;gt; on lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/sock&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
# Disappearing cursor in GTK apps or in Firefox (Flatpak)&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Missing file picker in Firefox (Flatpak)/cannot download&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
# Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
# Sway socket not detected&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
# Firefox picture-in-picture mode/floating windows&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Screenshots&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
# Start with NumLock enabled&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Change cursor theme and size&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
#Start as a service&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
# Custom keyboard layout&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;niro&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22826</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22826"/>
		<updated>2022-12-31T00:59:35Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: Add tips and tricks and troubleshooting sections.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspending with a key (otherwise you can run  on lid close support {{Note|Even though elogind may be installed and the service running, you may still need to configure some values. Otherwise you may for example be able to suspend with a key, but encounter a freeze upon waking. It is always vital to verify it is set up correctly with &amp;lt;code&amp;gt;loginctl list-sessions&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator. Modify $term in config for a different one.&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]] and set &amp;lt;code&amp;gt;SWAYSOCK&amp;lt;/code&amp;gt; environmental variable to&lt;br /&gt;
&amp;lt;code&amp;gt;/tmp/$(id -u)-runtime-dir/sway-ipc.1000.$(pgrep -x sway).sock&amp;lt;/sock&amp;gt; in your login shell&#039;s init script.&lt;br /&gt;
Note that it has to be set after the line responsible for launching Sway.&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect. &lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If you encounter any issues, try running &amp;lt;code&amp;gt;sway -Vc /etc/sway/config&amp;lt;/code&amp;gt;. It will run sway with the default config file and set the output to be more verbose. It is generally a good idea to track your config files with git (when and if at all you use a remote repository for them, keep it private for security reasons). &lt;br /&gt;
&lt;br /&gt;
# Disappearing cursor in GTK apps or in Firefox (Flatpak)&lt;br /&gt;
You may need to get an icon pack and possibly a theme from [https://www.pling.com/browse?cat=107&amp;amp;ord=latest Pling store] and set &amp;lt;code&amp;gt;GTK_THEME&amp;lt;/code&amp;gt; environmental variable. Alternatively you can install a theme for all users (search [https://pkgs.alpinelinux.org/ Alpine Linux Packages] for &#039;&#039;*-icon-theme&#039;&#039;) using &amp;lt;code&amp;gt;apk add&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# Missing file picker in Firefox (Flatpak)/cannot download&lt;br /&gt;
&lt;br /&gt;
Go to [[about:config]] and set widget.use-xdg-desktop-portal.file-picker to 0.&lt;br /&gt;
&lt;br /&gt;
# Failing to start under certain graphics cards/multiple wlroots stacked windows spawning upon start&lt;br /&gt;
As of Dec 31 2022, [https://developer.nvidia.com/docs/drive/drive-os/latest/linux/sdk/common/topics/window_system_stub/Gnome-WaylandDesktopShellSupport136.html Nvidia still doesn&#039;t fully support Wayland]. Therefore, the possible solutions are as outlined in the link, or setting your WLR_BACKENDS environmental variables to &amp;lt;code&amp;gt;drm,libinput&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;x11&amp;lt;/code&amp;gt; (add libinput here as well if you cannot use your mouse and keyboard after starting Sway). The latter also works for AMD/ATI cards (&#039;&#039;&#039;make sure to install libinput first&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
# Sway socket not detected&lt;br /&gt;
&lt;br /&gt;
See [[Sway#Installation|Installation]] for instructions on how to set this environmental variable. This issue may occur with terminal multiplexers, such as [[Tmux terminal multiplexer|tmux]]&lt;br /&gt;
&lt;br /&gt;
=== Tips and tricks ===&lt;br /&gt;
&lt;br /&gt;
Sway configuration is mostly backwards-compatible with that of [[I3wm|i3]] and if you are looking for a solution for a specific issue, you may also try checking if it hasn&#039;t been provided for i3WM.&lt;br /&gt;
&lt;br /&gt;
# Firefox picture-in-picture mode/floating windows&lt;br /&gt;
Add this to your sway config file (modify the numeric values to suit your needs and your display):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for_window [app_id=&amp;quot;librewolf&amp;quot; title=&amp;quot;^Picture-in-Picture$&amp;quot;] floating enable, move position 877 450, sticky enable, border none&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Screenshots&lt;br /&gt;
A simple tool that works well under Wayland is Grimshot. Example keybindings:&lt;br /&gt;
&lt;br /&gt;
bindsym Print exec grimshot copy area&lt;br /&gt;
bindsym Shift+Print exec grimshot copy screen&lt;br /&gt;
bindsym Control+Print exec grimshot save area ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
bindsym Control+Shift+Print exec grimshot save screen ~/Pictures/$(date +%d-%m-%Y-%H-%M-%S).png&lt;br /&gt;
&lt;br /&gt;
# Start with NumLock enabled&lt;br /&gt;
Add this to your sway config file:&lt;br /&gt;
&amp;lt;code&amp;gt;input type:keyboard xkb_numlock enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#Change cursor theme and size&lt;br /&gt;
Add to your sway config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
seat seat0 xcursor_theme my_cursor_theme my_cursor_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can inspect their values with &amp;lt;code&amp;gt;echo $XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;echo $XCURSOR_THEME&amp;lt;/code&amp;gt;. If reloading your config does not result in change, try logging out and in.&lt;br /&gt;
{{Note|Wayland uses client-side cursors. It is possible that applications do not evaluate the values of &amp;lt;code&amp;gt;$XCURSOR_SIZE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;$XCURSOR_THEME&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
#Start as a service&lt;br /&gt;
Although this is not necessary, you may write an init script like the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{/etc/init.d/sway|&lt;br /&gt;
#!/sbin/openrc-run&lt;br /&gt;
&lt;br /&gt;
description=&amp;quot;Sway Compositor&amp;quot;&lt;br /&gt;
&lt;br /&gt;
command=&amp;quot;/usr/bin/sway&amp;quot;&lt;br /&gt;
command_args=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
pidfile=&amp;quot;/run/sway.pid&amp;quot;&lt;br /&gt;
&lt;br /&gt;
start_stop_daemon_args=&amp;quot;--background --pidfile ${pidfile}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
  need localmount&lt;br /&gt;
  after elogind&lt;br /&gt;
  use seatd dbus&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then as a root run &amp;lt;code&amp;gt;chmod +x /etc/init.d/seat&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rc-update add sway default&amp;lt;/code&amp;gt;. Make sure you have elogind installed or specify another service, like your display/login manager after which the sway service will run.&lt;br /&gt;
&lt;br /&gt;
# Custom keyboard layout&lt;br /&gt;
&lt;br /&gt;
Since wayland does not support setxkbmap, you will also need to add similar content to your &#039;&#039;/usr/share/X11/xkb/rules/evdev.xml&#039;&#039;, after &amp;lt;code&amp;gt;&amp;lt;/modelList&amp;gt;&amp;lt;/code&amp;gt; and after &amp;lt;code&amp;gt;&amp;lt;layoutList&amp;gt;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;layout&amp;gt;&lt;br /&gt;
      &amp;lt;configItem&amp;gt;&lt;br /&gt;
        &amp;lt;name&amp;gt;[the name of your layout, same as the name of the file in /usr/share/X11/xkb/symbols]&amp;lt;/name&amp;gt;&lt;br /&gt;
        &amp;lt;shortDescription&amp;gt;[usually just two letters]&amp;lt;/shortDescription&amp;gt;&lt;br /&gt;
        &amp;lt;description&amp;gt;[description of your layout]&amp;lt;/description&amp;gt;&lt;br /&gt;
        &amp;lt;countryList&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;US&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
          &amp;lt;iso3166Id&amp;gt;NO&amp;lt;/iso3166Id&amp;gt;&lt;br /&gt;
        &amp;lt;/countryList&amp;gt;&lt;br /&gt;
        &amp;lt;languageList&amp;gt;&lt;br /&gt;
          &amp;lt;iso639Id&amp;gt;eng&amp;lt;/iso639Id&amp;gt;&lt;br /&gt;
        &amp;lt;/languageList&amp;gt;&lt;br /&gt;
      &amp;lt;/configItem&amp;gt;&lt;br /&gt;
    &amp;lt;/layout&amp;gt;&lt;br /&gt;
&amp;lt;!--[other layouts]--&amp;gt;&lt;br /&gt;
Then, to enable for all keyboards, navigate to the input section of &#039;&#039;~/.config/sway/config&#039;&#039; and modify it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input * {&lt;br /&gt;
  xkb_layout &amp;quot;niro&amp;quot; &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you have enabled &amp;lt;code&amp;gt;xkb_numlock&amp;lt;/code&amp;gt;, include this setting inside those braces as well.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22825</id>
		<title>Sway</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Sway&amp;diff=22825"/>
		<updated>2022-12-30T23:06:31Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Installation */ add env variables required by pam&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://swaywm.org Sway] is a tiling [[Wayland]] compositor. It&#039;s a drop-in replacement for the i3 window manager.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
eudev:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add eudev&lt;br /&gt;
# setup-devd udev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Graphics drivers:&lt;br /&gt;
&lt;br /&gt;
* [[Intel Video]]&lt;br /&gt;
* [[Radeon Video]]&lt;br /&gt;
* [[Nvidia Video]]&lt;br /&gt;
Add user to the input and video groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# adduser $USER input&lt;br /&gt;
# adduser $USER video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install some TTF fonts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add ttf-dejavu&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
seatd daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add seatd&lt;br /&gt;
# rc-update add seatd&lt;br /&gt;
# rc-service seatd start&lt;br /&gt;
# adduser $USER seat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[elogind]], optional for suspend on lid close support.&lt;br /&gt;
&lt;br /&gt;
Install sway:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# apk add sway sway-doc&lt;br /&gt;
# apk add                \ # Install optional dependencies:&lt;br /&gt;
    xwayland             \ # recommended for compatibility reasons&lt;br /&gt;
    foot                 \ # default terminal emulator&lt;br /&gt;
    bemenu               \ # wayland menu&lt;br /&gt;
    swaylock swaylockd   \ # lockscreen tool&lt;br /&gt;
    swaybg               \ # wallpaper daemon&lt;br /&gt;
    swayidle               # idle management (DPMS) daemon&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure XDG_RUNTIME_DIR.  Add the following to shell init scripts, for the default ash shell it is ~/.profile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if test -z &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir&lt;br /&gt;
  if ! test -d &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;; then&lt;br /&gt;
    mkdir &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
    chmod 0700 &amp;quot;${XDG_RUNTIME_DIR}&amp;quot;&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have also installed elogind, which depends on the package linux-pam, you will also need to prepend the above code with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export XDG_SEAT=seat0&lt;br /&gt;
export XDG_SESSION_CLASS=user&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For inter-program communication and functionality such as screensharing, install and enable dbus and PipeWire, see [[PipeWire]].&lt;br /&gt;
&lt;br /&gt;
Re-login or reboot to allow above modifications to take effect.&lt;br /&gt;
&lt;br /&gt;
Launch Sway with dbus support:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dbus-run-session -- sway #prepend with exec in your login shell init script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
An example config is provided at &amp;lt;code&amp;gt;/etc/sway/config&amp;lt;/code&amp;gt;. Copy it to &amp;lt;code&amp;gt;~/.config/sway/config&amp;lt;/code&amp;gt; and read through it to learn the default keybindings.&lt;br /&gt;
&lt;br /&gt;
For additional information, start at &amp;lt;code&amp;gt;man 5 sway&amp;lt;/code&amp;gt; and read the [https://github.com/swaywm/sway/wiki upstream wiki].&lt;br /&gt;
&lt;br /&gt;
=== Firefox screensharing ===&lt;br /&gt;
&lt;br /&gt;
For some programs, additional configuration is needed to launch them natively under Wayland and to support special features such as screen sharing.&lt;br /&gt;
&lt;br /&gt;
To launch Firefox natively under Wayland and to enable support for screensharing, you need:&lt;br /&gt;
&lt;br /&gt;
* Install and configure [[PipeWire]]&lt;br /&gt;
* Install xdg-desktop-portal and xdg-desktop-portal-wlr package&lt;br /&gt;
* Install wofi for screen selection&lt;br /&gt;
* Launch support programs on sway startup:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec /usr/libexec/pipewire-launcher #pipewire must be launched first&lt;br /&gt;
exec /usr/libexec/xdg-desktop-portal-wlr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Export the following variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export MOZ_ENABLE_WAYLAND=&amp;quot;1&amp;quot;&lt;br /&gt;
export XDG_CURRENT_DESKTOP=sway&lt;br /&gt;
export XDG_SESSION_TYPE=wayland&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scaling for high resolution screens ===&lt;br /&gt;
&lt;br /&gt;
Without further configuration, program interfaces might be too small to use on high resolution screens.&lt;br /&gt;
&lt;br /&gt;
==== Via sway ====&lt;br /&gt;
&lt;br /&gt;
Sway supports the per-display configuration of&lt;br /&gt;
&lt;br /&gt;
* fractional (e.g., 1.5x), and&lt;br /&gt;
* integer scaling (e.g., 2x) &lt;br /&gt;
&lt;br /&gt;
However, fractional scaling is discouraged due to both the performance impact and the blurry output it produces. In this case, where 1x scaling is too small and 2x scaling is too large, program-specific GTK/QT based scaling is recommended.  See below.&lt;br /&gt;
&lt;br /&gt;
To enable Sway scaling, the user can first preview different scaling factors with &amp;lt;code&amp;gt;wdisplays&amp;lt;/code&amp;gt; package.  Note the output name (eDP-1, LVDS-1) and try apply scaling factors such as 1 and 2.  To make changes permanent, add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output &amp;lt;name&amp;gt; scale &amp;lt;factor&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to ~/.config/sway/config.&lt;br /&gt;
&lt;br /&gt;
==== Via GTK/Qt ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# for GTK-based programs such as firefox and emacs:&lt;br /&gt;
export GDK_DPI_SCALE=2&lt;br /&gt;
&lt;br /&gt;
# for QT-based programs&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=&amp;quot;physical&amp;quot;&lt;br /&gt;
# or if still too small, use a custom DPI&lt;br /&gt;
export QT_WAYLAND_FORCE_DPI=192 # 2x scaling&lt;br /&gt;
export QT_QPA_PLATFORM=&amp;quot;wayland-egl&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Make clipboard content persistent ===&lt;br /&gt;
By default the clipboard content does not persist after terminating the program: you copy some text from Firefox and then exit Firefox, the copied text is also lost.&lt;br /&gt;
&lt;br /&gt;
Install clipman from test repo and add the following to sway config:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
exec wl-paste --type text/plain --watch clipman store --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
bindsym $mod+h exec clipman pick --tool wofi --histpath=&amp;quot;~/.local/state/clipman-primary.json&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=PipeWire&amp;diff=22824</id>
		<title>PipeWire</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=PipeWire&amp;diff=22824"/>
		<updated>2022-12-30T22:51:35Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* XDG_RUNTIME_DIR */ add additional instructions for Sway&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft|The instructions below have not been thoroughly tested and may break things.}}&lt;br /&gt;
&lt;br /&gt;
[https://pipewire.org/ PipeWire] is a multimedia processing engine that aims to improve audio and video handling on Linux.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
=== Device access ===&lt;br /&gt;
&lt;br /&gt;
PipeWire needs proper permissions to access devices. If you do not use [[Elogind|elogind]], your user should be in &amp;lt;code&amp;gt;audio&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;video&amp;lt;/code&amp;gt; groups:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# addgroup &amp;lt;user&amp;gt; audio&lt;br /&gt;
# addgroup &amp;lt;user&amp;gt; video&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure to re-login for these changes to take effect.&lt;br /&gt;
&lt;br /&gt;
=== D-Bus ===&lt;br /&gt;
&lt;br /&gt;
PipeWire optionally requires a running [[D-Bus]] system and/or session bus for some of its functionality.&lt;br /&gt;
&lt;br /&gt;
For certain configurations (e.g. only audio playback and recording) D-Bus setup is not necessary. Edit [[#Disable_D-Bus_support|configuration files]] to disable D-Bus support.&lt;br /&gt;
&lt;br /&gt;
You can start a dbus session-wide like this: &amp;lt;code&amp;gt;export $(dbus-launch)&amp;lt;/code&amp;gt;, or system-wide: &amp;lt;code&amp;gt;rc-service dbus start&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you start dbus session-wide, make sure to start PipeWire in that same session.&lt;br /&gt;
&lt;br /&gt;
=== XDG_RUNTIME_DIR ===&lt;br /&gt;
&lt;br /&gt;
If you are not using a Desktop Manager, ensure that your &amp;lt;code&amp;gt;XDG_RUNTIME_DIR&amp;lt;/code&amp;gt; is set to a user-writable location. By default for pulseaudio this is {{Path|/run/user/1000/}} or {{Path|/tmp}}. If this is not set, pipewire will create a directory in your home folder instead, called &amp;lt;code&amp;gt;~/pulse&amp;lt;/code&amp;gt;, and on attempting to run Pavucontrol or pactl, you will get the following error:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ pactl list&lt;br /&gt;
Connection failure: Connection refused&lt;br /&gt;
pa_context_connect() failed: Connection refused&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Under [[Sway]], in order for &amp;lt;code&amp;gt;xdg-desktop-portal-wlr&amp;lt;/code&amp;gt; to work it may also be necessary to set &amp;lt;code&amp;gt;XDG_CURRENT_DESKTOP&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;XDG_SESSION_DESKTOP&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;sway&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install the {{Pkg|pipewire}} package.&lt;br /&gt;
&lt;br /&gt;
=== Session Manager ===&lt;br /&gt;
PipeWire delegates plumbing work to session manager. There are two options available:&lt;br /&gt;
* &#039;&#039;&#039;[https://gitlab.freedesktop.org/pipewire/wireplumber WirePlumber]&#039;&#039;&#039;. It has modular design and supports Lua plugins. &#039;&#039;&#039;This is the recommended session manager. If you do not know which session manager you need, use WirePlumber.&#039;&#039;&#039;&amp;lt;br/&amp;gt;Package: {{Pkg|wireplumber}}&lt;br /&gt;
* &#039;&#039;&#039;[https://gitlab.freedesktop.org/pipewire/media-session pipewire-media-session]&#039;&#039;&#039;. It is much more simpler and covers only basic use cases. It was used for testing purposes. Now it does not make much sense since WirePlumber is available.&amp;lt;br/&amp;gt;Package: {{Pkg|pipewire-media-session}}&lt;br /&gt;
&lt;br /&gt;
{{Note|This page assumes that you are using WirePlumber.}}&lt;br /&gt;
&lt;br /&gt;
=== PulseAudio compatibility ===&lt;br /&gt;
Install {{Pkg|pipewire-pulse}} package, which provides a daemon so PulseAudio applications could use PipeWire as backend.&lt;br /&gt;
&lt;br /&gt;
=== JACK compatibility ===&lt;br /&gt;
Install {{Pkg|pipewire-jack}} package, which provides ABI-compatible libraries for JACK applications.&lt;br /&gt;
&lt;br /&gt;
=== ALSA support ===&lt;br /&gt;
Install {{Pkg|pipewire-alsa}} package.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
PipeWire and WirePlumber store their default configuration in &amp;lt;code&amp;gt;/usr/share/pipewire&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/usr/share/wireplumber&amp;lt;/code&amp;gt; respectively. If you want to edit the configuration, you need to move it to &amp;lt;code&amp;gt;/etc&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cp -a /usr/share/pipewire /etc&lt;br /&gt;
# cp -a /usr/share/wireplumber /etc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Disable D-Bus support ===&lt;br /&gt;
Edit the following configuration parameters:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;/etc/pipewire/pipewire.conf&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context.properties = {&lt;br /&gt;
    ... &lt;br /&gt;
    support.dbus = false&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;/etc/wireplumber/wireplumber.conf&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context.properties = {&lt;br /&gt;
    ... &lt;br /&gt;
    support.dbus = false&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;/etc/wireplumber/bluetooth.lua.d/50-bluez-config.lua&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bluez_monitor.properties = {&lt;br /&gt;
  ...&lt;br /&gt;
  [&amp;quot;with-logind&amp;quot;] = false,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;/etc/wireplumber/main.lua.d/50-alsa-config.lua&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alsa_monitor.properties = {&lt;br /&gt;
  ...&lt;br /&gt;
  [&amp;quot;alsa.reserve&amp;quot;] = false,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;/etc/wireplumber/main.lua.d/50-default-access-config.lua&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
default_access.properties = {&lt;br /&gt;
  ...&lt;br /&gt;
  [&amp;quot;enable-flatpak-portal&amp;quot;] = false,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Realtime scheduling ===&lt;br /&gt;
&lt;br /&gt;
For realtime scheduling, it is recommended to use {{Pkg|rtkit}}. Add your user to the &amp;lt;code&amp;gt;rtkit&amp;lt;/code&amp;gt; group.&lt;br /&gt;
&lt;br /&gt;
Alternatively, ensure your user has the right ulimit permissions. You generally need (limits.conf format):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
@audio - memlock 256&lt;br /&gt;
@audio - nice -11&lt;br /&gt;
@audio - rtprio 88&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This allows a member of the audio group to have the right permissions for PipeWire to use realtime scheduling without rtkit.&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
Video should work out-of-the-box with v4l2 devices (e.g. a lot of webcams) and [https://gstreamer.freedesktop.org/ GStreamer] applications.&lt;br /&gt;
&lt;br /&gt;
=== Bluetooth audio ===&lt;br /&gt;
&lt;br /&gt;
* Enable PulseAudio support as described above&lt;br /&gt;
* Install bluetooth service packages: &amp;lt;code&amp;gt;bluez bluez-openrc pipewire-spa-bluez&amp;lt;/code&amp;gt;&lt;br /&gt;
* Optional: install GUI manager for bluetooth &amp;lt;code&amp;gt;blueman&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable and start bluetooth service: &amp;lt;code&amp;gt;rc-update add bluetooth; rc-service bluetooth start&amp;lt;/code&amp;gt;&lt;br /&gt;
* Restart PipeWire&lt;br /&gt;
* Use commandline program  &amp;lt;code&amp;gt;bluetoothctl&amp;lt;/code&amp;gt; or GUI program &amp;lt;code&amp;gt;blueman-manager&amp;lt;/code&amp;gt; to scan and pair bluetooth audio devices.&lt;br /&gt;
* Use pavucontrol to adjust volume and manually select high definition bluetooth codecs.&lt;br /&gt;
&lt;br /&gt;
=== Screen sharing on Wayland ===&lt;br /&gt;
&lt;br /&gt;
You will need the right [https://github.com/flatpak/xdg-desktop-portal xdg-desktop-portal] backend for your desktop environment. Screen sharing is known to work on:&lt;br /&gt;
* GNOME with &amp;lt;code&amp;gt;xdg-desktop-portal-gtk&amp;lt;/code&amp;gt;&lt;br /&gt;
* KDE Plasma with &amp;lt;code&amp;gt;xdg-desktop-portal-kde&amp;lt;/code&amp;gt; and Firefox&lt;br /&gt;
* Sway with &amp;lt;code&amp;gt;xdg-desktop-portal-wlr&amp;lt;/code&amp;gt; and Firefox, see [[Sway]] for details&lt;br /&gt;
&lt;br /&gt;
== Running ==&lt;br /&gt;
&lt;br /&gt;
{{Note|&amp;lt;code&amp;gt;pipewire-launcher&amp;lt;/code&amp;gt; script is provided by Alpine Linux, not by upstream. Please report issues to Alpine Linux maintainers first.}}&lt;br /&gt;
&lt;br /&gt;
Start the PipeWire media server. You&#039;ll probably get quite a few errors but just ignore them for now.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ /usr/libexec/pipewire-launcher&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do not have D-Bus session bus running (e.g. you are in tty or you are using minimalistic DE or window manager which does not launch D-Bus session) and you did not disable D-Bus in PipeWire configuration, use &amp;lt;code&amp;gt;dbus-launch&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ dbus-launch /usr/libexec/pipewire-launcher&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note| PipeWire doesn&#039;t auto-start a session manager anymore. &lt;br /&gt;
In 3.14 and earlier, the PipeWire default config was edited in packaging to auto-start pipewire-media-session as the default session manager. Since we now have wireplumber available as an alternative session manager, this has been changed in favor of a launch wrapper for pipewire at /usr/libexec/pipewire-launcher. When executed, this will launch pipewire, pipewire-media-session or wireplumber, and pipewire-pulse, depending on what modules are available. If you were launching /usr/bin/pipewire and the session manager manually before, please use the new launcher wrapper instead. WirePlumber can now also be used as a proper alternative for pipewire-media-session.}}&lt;br /&gt;
&lt;br /&gt;
=== Auto launching ===&lt;br /&gt;
You can add &amp;lt;code&amp;gt;/usr/libexec/pipewire-launcher&amp;lt;/code&amp;gt; to your &amp;lt;code&amp;gt;.xinitrc&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you do not use GUI by default and have D-Bus enabled in configuration, add the following stanza to your shell configuration file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export $(dbus-launch)&lt;br /&gt;
/usr/libexec/pipewire-launcher&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
In a different terminal window check the default output device. I don&#039;t yet know how this default can be changed for all applications, so you&#039;d better hope it&#039;s right!&lt;br /&gt;
&lt;br /&gt;
=== WirePlumber ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ wpctl status&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== pw-cat playback ===&lt;br /&gt;
&lt;br /&gt;
Test sound is working using an audio file in a format supported by [http://www.mega-nerd.com/libsndfile/ libsndfile] (e.g. flac, opus, ogg, wav). Use &amp;lt;code&amp;gt;pw-cat&amp;lt;/code&amp;gt; utility from {{Pkg|pipewire-tools}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ pw-cat -p test.flac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== pw-cat recording ===&lt;br /&gt;
If you have a microphone test audio recording is working.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ pw-cat -r --list-targets&lt;br /&gt;
$ pw-cat -r recording.flac&lt;br /&gt;
(Speak for a while then stop it with Ctrl+c)&lt;br /&gt;
$ pw-cat -p recording.flac&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PulseAudio ===&lt;br /&gt;
Test PulseAudio clients using a media player, as most use PulseAudio.&lt;br /&gt;
&lt;br /&gt;
=== JACK ===&lt;br /&gt;
Use &amp;lt;code&amp;gt;jack_simple_client&amp;lt;/code&amp;gt; from {{Pkg|jack-simple-clients}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ jack_simple_client&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should hear a sustained beep.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== `wpctl status` shows no targets ===&lt;br /&gt;
&lt;br /&gt;
First, check whether ALSA knows about your sound card:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
aplay -l&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If sound devices are found, the issue is with your pipewire configuration.  Consider double-checking the instructions above.&lt;br /&gt;
&lt;br /&gt;
Otherwise, your sound card may not be supported in the version of the Linux Kernel you&#039;re running.  You should search online for fixes relating to your current kernel version and the codec of your sound card.  You can find each of these with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
uname -r&lt;br /&gt;
cat /proc/asound/card0/codec* | grep Codec&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Error acquiring bus address: Cannot autolaunch D-Bus without X11 $DISPLAY ===&lt;br /&gt;
This means D-Bus session bus is not started and GUI is not active (i.e. you are in a tty). Use &amp;lt;code&amp;gt;dbus-launch&amp;lt;/code&amp;gt; as outlined [[#Running|above]]. Alternatively, [[#D-Bus|disable D-Bus support]].&lt;br /&gt;
&lt;br /&gt;
== Quick Configuration ==&lt;br /&gt;
&lt;br /&gt;
You might want to use {{Pkg|pavucontrol}} to have a simple GUI app for controlling sound, outputs, etc.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [https://gitlab.freedesktop.org/pipewire/pipewire PipeWire source repository]&lt;br /&gt;
* [https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/home PipeWire Wiki]&lt;br /&gt;
* [https://wiki.archlinux.org/index.php/PipeWire PipeWire on the ArchWiki]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Pipewire PipeWire on the Gentoo Wiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Desktop]]&lt;br /&gt;
[[Category:Multimedia]]&lt;br /&gt;
[[Category:Sound]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=22257</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=22257"/>
		<updated>2022-09-06T20:50:02Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Marcelina Hołub */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
==== [https://hosted.weblate.org/user/154pinkchairs/ Weblate] ====&lt;br /&gt;
===== &#039;&#039;&#039;Age:&#039;&#039;&#039; ===== 24&amp;lt;br&amp;gt;&lt;br /&gt;
===== &#039;&#039;&#039;Current city:&#039;&#039;&#039; ===== Kraków&lt;br /&gt;
&lt;br /&gt;
Tech stack: Go, Python, Bash, node, Vue, Lua&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. A staunch privacy/digital rights enthusiast and advocate. Linux distros I&#039;ve used: Ubuntu, Mint, Android (ungoogled), Debian, Fedora, Devuan, Manjaro, Puppy Linux, Tails, DD-WRT, openWRT and of course Alpine.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=21751</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=21751"/>
		<updated>2022-04-28T03:19:55Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Increase upload size */ update from /etc/php to /etc/php8 as this is the current name of the folder created after installing the latest PHP version for 3.15&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql postgresql postgresql-client}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
Set postgresql to start on boot:&lt;br /&gt;
{{cmd|rc-update add postgresql}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
service mariadb start&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
{{pkg|nextcloud-initscript}} facilitates running the webserver with php-fpm.&lt;br /&gt;
&lt;br /&gt;
{{cmd|apk add nextcloud-initscript}}&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php8-fpm}}&lt;br /&gt;
&lt;br /&gt;
Delete the default nginx website configuration:&lt;br /&gt;
{{cmd|rm /etc/nginx/http.d/default.conf}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/http.d/mysite.mydomain.com.conf}}:&lt;br /&gt;
{{Cat|/etc/nginx/http.d/mysite.mydomain.com.conf|server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/&amp;amp;#124;$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                #fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
		fastcgi_pass unix:/run/nextcloud/fastcgi.sock; # From the nextcloud-initscript package&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
        # Help pass nextcloud&#039;s configuration checks after install:&lt;br /&gt;
        # Per https://docs.nextcloud.com/server/22/admin_manual/issues/general_troubleshooting.html#service-discovery&lt;br /&gt;
        location ^~ /.well-known/carddav { return 301 /remote.php/dav/; }&lt;br /&gt;
        location ^~ /.well-known/caldav { return 301 /remote.php/dav/; }&lt;br /&gt;
        location ^~ /.well-known/webfinger { return 301 /index.php/.well-known/webfinger; }&lt;br /&gt;
        location ^~ /.well-known/nodeinfo { return 301 /index.php/.well-known/nodeinfo; }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
If you plan to enable uploads - and you probably do) - then you need to modify the default:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
client_max_body_size 1m;&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
setting in {{path|/etc/nginx/nginx.conf}}. For testing purposes, I disabled the limit by changing it to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
client_max_body_size 0;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This enabled large file uploads and auto-uploads to work. Note, this is a file-size restriction in addition to the restriction set in {{path|/etc/php8/php-fpm.d/nextcloud.conf}}. That second restriction defaults to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
; Maximal size of a file that can be uploaded via web interface.&lt;br /&gt;
php_admin_value[memory_limit] = 512M&lt;br /&gt;
php_admin_value[post_max_size] = 513M&lt;br /&gt;
php_admin_value[upload_max_filesize] = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another setting that may limit file-size is in configuration file {{path|/etc/php8/php.ini}}, where I set the restriction to to:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to match the {{path|/etc/php8/php-fpm.d/nextcloud.conf}} file-size restriction.&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving several users make sure to tune the *&#039;&#039;pm.max_children&#039;&#039; setting in {{path|/etc/php8/php-fpm.d/nextcloud.conf}}}}&lt;br /&gt;
&lt;br /&gt;
{{path|/etc/nginx/nginx.conf}} should already be configured to load your site config from this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
include /etc/nginx/http.d/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|service nginx start&lt;br /&gt;
service nextcloud start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add nginx&lt;br /&gt;
rc-update add nextcloud}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-files_pdfviewer nextcloud-text nextcloud-notifications nextcloud-files_videoplayer}}&lt;br /&gt;
You can also install a [https://pkgs.alpinelinux.org/package/v3.15/community/x86_64/nextcloud-default-apps meta-package] which installs all 30 core Nextcloud apps (listed as dependencies under aforementioned link):&lt;br /&gt;
{{cmd|apk add nextcloud-default-apps}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
Install openssl:&lt;br /&gt;
{{cmd|apk add openssl}}&lt;br /&gt;
Generate your self signed certificate and its private key:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl1.1/private/nextcloud-selfsigned.key -out /etc/ssl1.1/certs/nextcloud-selfsigned.crt&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Edit your nginx configuration:&lt;br /&gt;
{{cat|/etc/nginx/http.d/mysite.mydomain.com.conf|&lt;br /&gt;
ssl_certificate      /etc/ssl1.1/certs/nextcloud-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key  /etc/ssl1.1/private/nextcloud-selfsigned.key;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How To Install and Set Up Auto-Renewing LetsEncrypt SSL Certificate ===&lt;br /&gt;
After first setting up the Nextcloud server using the instructions in the &#039;Configure and use Nextcloud&#039; section below, I then followed the SSL-setup instructions at: [[https://techjogging.com/create-letsencrypt-certificate-alpine-nginx.html Tech Jogging]].&lt;br /&gt;
&lt;br /&gt;
I also had to add my Nextcloud servers Fully Qualified Domain Name (FQDN) to the list of trusted domains in /etc/nextcloud/config.php. In the section labelled: &#039;trusted_domains&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039;trusted_domains&#039; =&amp;gt;&lt;br /&gt;
  array (&lt;br /&gt;
    0 =&amp;gt; &#039;&amp;lt;machine&#039;s local IP address&amp;gt;&#039;,&lt;br /&gt;
    1 =&amp;gt; &#039;nextcloud.mydomain.com&#039;,&lt;br /&gt;
  ),&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
 {{path|/etc/php8/php-fpm.d/nextcloud.conf}} has overridden default file sizes, but they can be modified further to suit your needs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
; Maximal size of a file that can be uploaded via web interface.&lt;br /&gt;
php_admin_value[memory_limit] = 512M&lt;br /&gt;
php_admin_value[post_max_size] = 513M&lt;br /&gt;
php_admin_value[upload_max_filesize] = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php8 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php8-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php8/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128 //you can reduce this slightly when short on RAM&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm8&lt;br /&gt;
{{cmd|rc-service php-fpm8 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21747</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21747"/>
		<updated>2022-04-24T16:08:12Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Marcelina Hołub */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
==== [https://hosted.weblate.org/user/154pinkchairs/ Weblate] ====&lt;br /&gt;
===== &#039;&#039;&#039;Age:&#039;&#039;&#039; ===== 24&amp;lt;br&amp;gt;&lt;br /&gt;
===== &#039;&#039;&#039;Current city:&#039;&#039;&#039; ===== Kraków&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. Self learning programmer, currently quite well skilled in Python, Shell scripts, web design and to some extent in JS/TS; looking forward to learn C++ or Go. A staunch privacy/digital rights enthusiast and advocate. Neuroatypical and queer 🌈️♾️🏳️‍🌈️, cat lover 😺️ and brutalism appreciator 🪨️. Using Manjaro XFCE as my daily driver and Alpine on my VPS. I love the very low memory footprint whereas OpenRC also doesn&#039;t seem to be as affected by adding new services as systemd. Tried migrating to Artix on my desktop, but it resulted in too many problems.&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
└─(17:30:51)──&amp;gt; neofetch                                                                                                                                ──(Sun,Apr24)─┘&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████   x@Aurora&amp;lt;br&amp;gt; &lt;br /&gt;
██████████████████  ████████   ------- &amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████    OS: Manjaro Linux x86_64 &amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████    Host: Lenovo IdeaPad Y580 Lenovo IdeaPad Y580 &amp;lt;br&amp;gt;&lt;br /&gt;
████████            ████████    Kernel: 5.17.1-3-MANJARO &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Uptime: 2 days, 19 hours, 31 mins &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Packages: 2331 (pacman) &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Shell: zsh 5.8.1 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Resolution: 1366x768, 1920x1080 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    DE: Xfce 4.16 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    WM: Xfwm4 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    WM Theme: Fluent-dark &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Theme: Fluent-dark [GTK2], adwaita-creamy [GTK3] &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Icons: Zafiro-icons-Dark [GTK2], Adwaita [GTK3] &amp;lt;br&amp;gt;&lt;br /&gt;
                                Terminal: xfce4-terminal &amp;lt;br&amp;gt;&lt;br /&gt;
                                Terminal Font: Inconsolata 12&amp;lt;br&amp;gt; &lt;br /&gt;
                                CPU: Intel i7-3630QM (8) @ 2.040GHz&amp;lt;br&amp;gt; &lt;br /&gt;
                                GPU: Intel 3rd Gen Core processor Graphics Controller&amp;lt;br&amp;gt; &lt;br /&gt;
                                GPU: NVIDIA GeForce GTX 660M &amp;lt;br&amp;gt;&lt;br /&gt;
                                Memory: 4666MiB / 7846MiB &amp;lt;br&amp;gt;&lt;br /&gt;
}&amp;lt;br&amp;gt;&lt;br /&gt;
Second PC: also runs Manjaro (Budgie), plus Windows solely for gaming with multiple spyware blocking solutions; i5-6660K, 24 GB DDR4 2400MHz, need to buy a SSD and GPU for it. Haven&#039;t decided yet what to install on the SSD, might give a try to Gentoo. Linux distros I&#039;ve used: Ubuntu, Mint, Android (ungoogled), Debian, Fedora, Devuan, Manjaro, Puppy Linux, Tails, DD-WRT and of course Alpine.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21746</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21746"/>
		<updated>2022-04-24T16:07:53Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Marcelina Hołub */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
==== [https://hosted.weblate.org/user/154pinkchairs/ Weblate] ====&lt;br /&gt;
===== &#039;&#039;&#039;Age:&#039;&#039;&#039; ===== 24&amp;lt;br&amp;gt;&lt;br /&gt;
===== &#039;&#039;&#039;Current city:&#039;&#039;&#039; ===== Kraków&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. Self learning programmer, currently quite well skilled in Python, Shell scripts, web design and to some extent in JS/TS; looking forward to learn C++ or Go. A staunch privacy/digital rights enthusiast and advocate. Neuroatypical and queer 🌈️♾️🏳️‍🌈️, cat lover 😺️ and brutalism appreciator 🪨️. Using Manjaro XFCE as my daily driver and Alpine on my VPS. I love the very low memory footprint whereas OpenRC also doesn&#039;t seem to be as affected by adding new services as systemd. Tried migrating to Artix on my desktop, but it resulted in too many problems.&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
└─(17:30:51)──&amp;gt; neofetch                                                                                                                                ──(Sun,Apr24)─┘&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████   x@Aurora&amp;lt;br&amp;gt; &lt;br /&gt;
██████████████████  ████████   ------- &amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████    OS: Manjaro Linux x86_64 &amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████    Host: Lenovo IdeaPad Y580 Lenovo IdeaPad Y580 &amp;lt;br&amp;gt;&lt;br /&gt;
████████            ████████    Kernel: 5.17.1-3-MANJARO&lt;br /&gt;
████████  ████████  ████████&amp;lt;br&amp;gt;Uptime: 2 days, 19 hours, 31 mins &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Packages: 2331 (pacman) &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Shell: zsh 5.8.1 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Resolution: 1366x768, 1920x1080 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    DE: Xfce 4.16 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    WM: Xfwm4 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    WM Theme: Fluent-dark &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Theme: Fluent-dark [GTK2], adwaita-creamy [GTK3] &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████    Icons: Zafiro-icons-Dark [GTK2], Adwaita [GTK3] &amp;lt;br&amp;gt;&lt;br /&gt;
                                Terminal: xfce4-terminal &amp;lt;br&amp;gt;&lt;br /&gt;
                                Terminal Font: Inconsolata 12&amp;lt;br&amp;gt; &lt;br /&gt;
                                CPU: Intel i7-3630QM (8) @ 2.040GHz&amp;lt;br&amp;gt; &lt;br /&gt;
                                GPU: Intel 3rd Gen Core processor Graphics Controller&amp;lt;br&amp;gt; &lt;br /&gt;
                                GPU: NVIDIA GeForce GTX 660M &amp;lt;br&amp;gt;&lt;br /&gt;
                                Memory: 4666MiB / 7846MiB &amp;lt;br&amp;gt;&lt;br /&gt;
}&amp;lt;br&amp;gt;&lt;br /&gt;
Second PC: also runs Manjaro (Budgie), plus Windows solely for gaming with multiple spyware blocking solutions; i5-6660K, 24 GB DDR4 2400MHz, need to buy a SSD and GPU for it. Haven&#039;t decided yet what to install on the SSD, might give a try to Gentoo. Linux distros I&#039;ve used: Ubuntu, Mint, Android (ungoogled), Debian, Fedora, Devuan, Manjaro, Puppy Linux, Tails, DD-WRT and of course Alpine.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21745</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21745"/>
		<updated>2022-04-24T16:06:34Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: fix newlines&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
==== [https://hosted.weblate.org/user/154pinkchairs/ Weblate] ====&lt;br /&gt;
===== &#039;&#039;&#039;Age:&#039;&#039;&#039; ===== 24&amp;lt;br&amp;gt;&lt;br /&gt;
===== &#039;&#039;&#039;Current city:&#039;&#039;&#039; ===== Kraków&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. Self learning programmer, currently quite well skilled in Python, Shell scripts, web design and to some extent in JS/TS; looking forward to learn C++ or Go. A staunch privacy/digital rights enthusiast and advocate. Neuroatypical and queer 🌈️♾️🏳️‍🌈️, cat lover 😺️ and brutalism appreciator 🪨️. Using Manjaro XFCE as my daily driver and Alpine on my VPS. I love the very low memory footprint whereas OpenRC also doesn&#039;t seem to be as affected by adding new services as systemd. Tried migrating to Artix on my desktop, but it resulted in too many problems.&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
└─(17:30:51)──&amp;gt; neofetch                                                                                                                                ──(Sun,Apr24)─┘&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████   x@Aurora&amp;lt;br&amp;gt; &lt;br /&gt;
██████████████████  ████████   ------- &amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████   OS: Manjaro Linux x86_64 &amp;lt;br&amp;gt;&lt;br /&gt;
██████████████████  ████████   Host: Lenovo IdeaPad Y580 Lenovo IdeaPad Y580 &amp;lt;br&amp;gt;&lt;br /&gt;
████████            ████████   Kernel: 5.17.1-3-MANJARO &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   Uptime: 2 days, 19 hours, 31 mins &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   Packages: 2331 (pacman) &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   Shell: zsh 5.8.1 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   Resolution: 1366x768, 1920x1080 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   DE: Xfce 4.16 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   WM: Xfwm4 &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   WM Theme: Fluent-dark &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   Theme: Fluent-dark [GTK2], adwaita-creamy [GTK3] &amp;lt;br&amp;gt;&lt;br /&gt;
████████  ████████  ████████   Icons: Zafiro-icons-Dark [GTK2], Adwaita [GTK3] &amp;lt;br&amp;gt;&lt;br /&gt;
                               Terminal: xfce4-terminal &amp;lt;br&amp;gt;&lt;br /&gt;
                               Terminal Font: Inconsolata 12&amp;lt;br&amp;gt; &lt;br /&gt;
                               CPU: Intel i7-3630QM (8) @ 2.040GHz&amp;lt;br&amp;gt; &lt;br /&gt;
                               GPU: Intel 3rd Gen Core processor Graphics Controller&amp;lt;br&amp;gt; &lt;br /&gt;
                               GPU: NVIDIA GeForce GTX 660M &amp;lt;br&amp;gt;&lt;br /&gt;
                               Memory: 4666MiB / 7846MiB &amp;lt;br&amp;gt;&lt;br /&gt;
}&amp;lt;br&amp;gt;&lt;br /&gt;
Second PC: also runs Manjaro (Budgie), plus Windows solely for gaming with multiple spyware blocking solutions; i5-6660K, 24 GB DDR4 2400MHz, need to buy a SSD and GPU for it. Haven&#039;t decided yet what to install on the SSD, might give a try to Gentoo. Linux distros I&#039;ve used: Ubuntu, Mint, Android (ungoogled), Debian, Fedora, Devuan, Manjaro, Puppy Linux, Tails, DD-WRT and of course Alpine.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21744</id>
		<title>User:154pinkchairs</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:154pinkchairs&amp;diff=21744"/>
		<updated>2022-04-24T16:04:44Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: self-intro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Marcelina Hołub ==&lt;br /&gt;
=== [https://github.com/154pinkchairs/ Github] ===&lt;br /&gt;
==== [https://hosted.weblate.org/user/154pinkchairs/ Weblate] ====&lt;br /&gt;
===== &#039;&#039;&#039;Age:&#039;&#039;&#039; ===== 24&lt;br /&gt;
===== &#039;&#039;&#039;Current city:&#039;&#039;&#039; ===== Kraków&lt;br /&gt;
 &lt;br /&gt;
Libre software enthusiast since the age of 12. Self learning programmer, currently quite well skilled in Python, Shell scripts, web design and to some extent in JS/TS; looking forward to learn C++ or Go. A staunch privacy/digital rights enthusiast and advocate. Neuroatypical and queer 🌈️♾️🏳️‍🌈️, cat lover 😺️ and brutalism appreciator 🪨️. Using Manjaro XFCE as my daily driver and Alpine on my VPS. I love the very low memory footprint whereas OpenRC also doesn&#039;t seem to be as affected by adding new services as systemd. Tried migrating to Artix on my desktop, but it resulted in too many problems.&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
└─(17:30:51)──&amp;gt; neofetch                                                                                                                                ──(Sun,Apr24)─┘&lt;br /&gt;
██████████████████  ████████   x@Aurora &lt;br /&gt;
██████████████████  ████████   ------- &lt;br /&gt;
██████████████████  ████████   OS: Manjaro Linux x86_64 &lt;br /&gt;
██████████████████  ████████   Host: Lenovo IdeaPad Y580 Lenovo IdeaPad Y580 &lt;br /&gt;
████████            ████████   Kernel: 5.17.1-3-MANJARO &lt;br /&gt;
████████  ████████  ████████   Uptime: 2 days, 19 hours, 31 mins &lt;br /&gt;
████████  ████████  ████████   Packages: 2331 (pacman) &lt;br /&gt;
████████  ████████  ████████   Shell: zsh 5.8.1 &lt;br /&gt;
████████  ████████  ████████   Resolution: 1366x768, 1920x1080 &lt;br /&gt;
████████  ████████  ████████   DE: Xfce 4.16 &lt;br /&gt;
████████  ████████  ████████   WM: Xfwm4 &lt;br /&gt;
████████  ████████  ████████   WM Theme: Fluent-dark &lt;br /&gt;
████████  ████████  ████████   Theme: Fluent-dark [GTK2], adwaita-creamy [GTK3] &lt;br /&gt;
████████  ████████  ████████   Icons: Zafiro-icons-Dark [GTK2], Adwaita [GTK3] &lt;br /&gt;
                               Terminal: xfce4-terminal &lt;br /&gt;
                               Terminal Font: Inconsolata 12 &lt;br /&gt;
                               CPU: Intel i7-3630QM (8) @ 2.040GHz &lt;br /&gt;
                               GPU: Intel 3rd Gen Core processor Graphics Controller &lt;br /&gt;
                               GPU: NVIDIA GeForce GTX 660M &lt;br /&gt;
                               Memory: 4666MiB / 7846MiB &lt;br /&gt;
}&lt;br /&gt;
Second PC: also runs Manjaro (Budgie), plus Windows solely for gaming with multiple spyware blocking solutions; i5-6660K, 24 GB DDR4 2400MHz, need to buy a SSD and GPU for it. Haven&#039;t decided yet what to install on the SSD, might give a try to Gentoo. Linux distros I&#039;ve used: Ubuntu, Mint, Android (ungoogled), Debian, Fedora, Devuan, Manjaro, Puppy Linux, Tails, DD-WRT and of course Alpine.&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=21740</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=21740"/>
		<updated>2022-04-24T14:59:17Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* enable opcache for nginx/php7 */  » /* (...)/php8 */ update to current php version. Add a comment that opcache.memory_consumption might be reduced when the user has limited RAM available.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql postgresql postgresql-client}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
Set postgresql to start on boot:&lt;br /&gt;
{{cmd|rc-update add postgresql}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
service mariadb start&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
{{pkg|nextcloud-initscript}} facilitates running the webserver with php-fpm.&lt;br /&gt;
&lt;br /&gt;
{{cmd|apk add nextcloud-initscript}}&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php8-fpm}}&lt;br /&gt;
&lt;br /&gt;
Delete the default nginx website configuration:&lt;br /&gt;
{{cmd|rm /etc/nginx/http.d/default.conf}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/http.d/mysite.mydomain.com.conf}}:&lt;br /&gt;
{{Cat|/etc/nginx/http.d/mysite.mydomain.com.conf|server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/&amp;amp;#124;$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                #fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
		fastcgi_pass unix:/run/nextcloud/fastcgi.sock; # From the nextcloud-initscript package&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
        # Help pass nextcloud&#039;s configuration checks after install:&lt;br /&gt;
        # Per https://docs.nextcloud.com/server/22/admin_manual/issues/general_troubleshooting.html#service-discovery&lt;br /&gt;
        location ^~ /.well-known/carddav { return 301 /remote.php/dav/; }&lt;br /&gt;
        location ^~ /.well-known/caldav { return 301 /remote.php/dav/; }&lt;br /&gt;
        location ^~ /.well-known/webfinger { return 301 /index.php/.well-known/webfinger; }&lt;br /&gt;
        location ^~ /.well-known/nodeinfo { return 301 /index.php/.well-known/nodeinfo; }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
If you plan to enable uploads - and you probably do) - then you need to modify the default:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
client_max_body_size 1m;&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
setting in {{path|/etc/nginx/nginx.conf}}. For testing purposes, I disabled the limit by changing it to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
client_max_body_size 0;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This enabled large file uploads and auto-uploads to work. Note, this is a file-size restriction in addition to the restriction set in {{path|/etc/php8/php-fpm.d/nextcloud.conf}}. That second restriction defaults to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
; Maximal size of a file that can be uploaded via web interface.&lt;br /&gt;
php_admin_value[memory_limit] = 512M&lt;br /&gt;
php_admin_value[post_max_size] = 513M&lt;br /&gt;
php_admin_value[upload_max_filesize] = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another setting that may limit file-size is in configuration file {{path|/etc/php8/php.ini}}, where I set the restriction to to:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to match the {{path|/etc/php8/php-fpm.d/nextcloud.conf}} file-size restriction.&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving several users make sure to tune the *&#039;&#039;pm.max_children&#039;&#039; setting in {{path|/etc/php8/php-fpm.d/nextcloud.conf}}}}&lt;br /&gt;
&lt;br /&gt;
{{path|/etc/nginx/nginx.conf}} should already be configured to load your site config from this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
include /etc/nginx/http.d/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|service nginx start&lt;br /&gt;
service nextcloud start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add nginx&lt;br /&gt;
rc-update add nextcloud}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-files_pdfviewer nextcloud-text nextcloud-notifications nextcloud-files_videoplayer}}&lt;br /&gt;
You can also install a [https://pkgs.alpinelinux.org/package/v3.15/community/x86_64/nextcloud-default-apps meta-package] which installs all 30 core Nextcloud apps (listed as dependencies under aforementioned link):&lt;br /&gt;
{{cmd|apk add nextcloud-default-apps}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
Install openssl:&lt;br /&gt;
{{cmd|apk add openssl}}&lt;br /&gt;
Generate your self signed certificate and its private key:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl1.1/private/nextcloud-selfsigned.key -out /etc/ssl1.1/certs/nextcloud-selfsigned.crt&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Edit your nginx configuration:&lt;br /&gt;
{{cat|/etc/nginx/http.d/mysite.mydomain.com.conf|&lt;br /&gt;
ssl_certificate      /etc/ssl1.1/certs/nextcloud-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key  /etc/ssl1.1/private/nextcloud-selfsigned.key;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How To Install and Set Up Auto-Renewing LetsEncrypt SSL Certificate ===&lt;br /&gt;
After first setting up the Nextcloud server using the instructions in the &#039;Configure and use Nextcloud&#039; section below, I then followed the SSL-setup instructions at: [[https://techjogging.com/create-letsencrypt-certificate-alpine-nginx.html Tech Jogging]].&lt;br /&gt;
&lt;br /&gt;
I also had to add my Nextcloud servers Fully Qualified Domain Name (FQDN) to the list of trusted domains in /etc/nextcloud/config.php. In the section labelled: &#039;trusted_domains&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039;trusted_domains&#039; =&amp;gt;&lt;br /&gt;
  array (&lt;br /&gt;
    0 =&amp;gt; &#039;&amp;lt;machine&#039;s local IP address&amp;gt;&#039;,&lt;br /&gt;
    1 =&amp;gt; &#039;nextcloud.mydomain.com&#039;,&lt;br /&gt;
  ),&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
 {{path|/etc/php/php-fpm.d/nextcloud.conf}} has overridden default file sizes, but they can be modified further to suit your needs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
; Maximal size of a file that can be uploaded via web interface.&lt;br /&gt;
php_admin_value[memory_limit] = 512M&lt;br /&gt;
php_admin_value[post_max_size] = 513M&lt;br /&gt;
php_admin_value[upload_max_filesize] = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php8 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php8-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php8/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128 //you can reduce this slightly when short on RAM&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm8&lt;br /&gt;
{{cmd|rc-service php-fpm8 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=21739</id>
		<title>Nextcloud</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nextcloud&amp;diff=21739"/>
		<updated>2022-04-24T13:50:51Z</updated>

		<summary type="html">&lt;p&gt;154pinkchairs: /* Additional packages */ update package names, mention nextcloud-default-apps meta-package. Src: https://pkgs.alpinelinux.org/packages?name=nextcloud-*&amp;amp;branch=v3.15&amp;amp;arch=x86_64&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nextcloud.com/ Nextcloud] is WedDAV-based solution for storing and sharing on-line your data, files, images, video, music, calendars and contacts. [http://karlitschek.de/2016/06/nextcloud/ Nextcloud is a fork of ownCloud with enterprise features included].&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{pkg|nextcloud}} is available from Alpine 3.5 and greater.&lt;br /&gt;
&lt;br /&gt;
Before you start installing anything, make sure you have the latest packages available. Make sure you are using an &#039;http&#039; repository in your {{path|/etc/apk/repositories}} file, then:&lt;br /&gt;
{{cmd|apk update}}&lt;br /&gt;
{{tip|Detailed information is found in [[Include:Upgrading_to_latest_release|this]] doc.}}&lt;br /&gt;
&lt;br /&gt;
== Database ==&lt;br /&gt;
First you have to decide which database to use. Use one of the databases listed below.&lt;br /&gt;
&lt;br /&gt;
=== Sqlite ===&lt;br /&gt;
All you need to do is to install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-sqlite}}&lt;br /&gt;
&lt;br /&gt;
=== PostgreSQL ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-pgsql postgresql postgresql-client}}&lt;br /&gt;
&lt;br /&gt;
Next thing is to configure and start the database:&lt;br /&gt;
{{cmd|/etc/init.d/postgresql setup&lt;br /&gt;
/etc/init.d/postgresql start}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and temporarily grant the CREATEDB privilege:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
CREATE USER mycloud WITH PASSWORD &#039;test123&#039;;&lt;br /&gt;
ALTER ROLE mycloud CREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
Set postgresql to start on boot:&lt;br /&gt;
{{cmd|rc-update add postgresql}}&lt;br /&gt;
&lt;br /&gt;
=== MariaDB ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add nextcloud-mysql mariadb mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
Now configure and start {{pkg|mariadb}}:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;mysql_install_db --user=mysql --datadir=/var/lib/mysql&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
service mariadb start&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
mysql_secure_installation}}&lt;br /&gt;
Follow the wizard to setup passwords, etc.&lt;br /&gt;
{{Note|Remember the usernames/passwords that you set using the wizard. You will need them later.}}&lt;br /&gt;
&lt;br /&gt;
Next, you need to create a user and database and set permissions:&lt;br /&gt;
{{cmd|mysql -u root -p&lt;br /&gt;
CREATE DATABASE nextcloud;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
GRANT ALL ON nextcloud.* TO &#039;mycloud&#039;@&#039;localhost.localdomain&#039; IDENTIFIED BY &#039;test123&#039;;&lt;br /&gt;
FLUSH PRIVILEGES;&lt;br /&gt;
EXIT}}&lt;br /&gt;
{{Note|Replace the above username &#039;mycloud&#039; and password &#039;test123&#039; with something secure. Remember these settings. You will need them later when setting up nextcloud.}}&lt;br /&gt;
&lt;br /&gt;
{{pkg|mariadb-client}} is not needed anymore. Let&#039;s uninstall it:&lt;br /&gt;
{{cmd|apk del mariadb-client}}&lt;br /&gt;
&lt;br /&gt;
== Webserver ==&lt;br /&gt;
Next thing is to choose, install, and configure a webserver. In this example we will install {{pkg|nginx}} or {{pkg|lighttpd}}. &#039;&#039;Nginx&#039;&#039; is preferred over &#039;&#039;Lighttpd&#039;&#039; since the latter will consume a lot of memory when working with large files (see [http://redmine.lighttpd.net/issues/1283 lighty bug #1283]). You are free to install any other webserver of your choice as long as it supports PHP and FastCGI. Generating an SSL certificate for your webserver is outside of the scope of this document.&lt;br /&gt;
&lt;br /&gt;
{{pkg|nextcloud-initscript}} facilitates running the webserver with php-fpm.&lt;br /&gt;
&lt;br /&gt;
{{cmd|apk add nextcloud-initscript}}&lt;br /&gt;
&lt;br /&gt;
=== Nginx ===&lt;br /&gt;
Install the needed packages:&lt;br /&gt;
{{cmd|apk add nginx php8-fpm}}&lt;br /&gt;
&lt;br /&gt;
Delete the default nginx website configuration:&lt;br /&gt;
{{cmd|rm /etc/nginx/http.d/default.conf}}&lt;br /&gt;
&lt;br /&gt;
Create a configuration file for your site in {{path|/etc/nginx/http.d/mysite.mydomain.com.conf}}:&lt;br /&gt;
{{Cat|/etc/nginx/http.d/mysite.mydomain.com.conf|server {&lt;br /&gt;
        #listen       [::]:80; #uncomment for IPv6 support&lt;br /&gt;
        listen       80;&lt;br /&gt;
	return 301 https://$host$request_uri;&lt;br /&gt;
	server_name mysite.mydomain.com;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
        #listen       [::]:443 ssl; #uncomment for IPv6 support&lt;br /&gt;
        listen       443 ssl;&lt;br /&gt;
        server_name  mysite.mydomain.com;&lt;br /&gt;
&lt;br /&gt;
	root /usr/share/webapps/nextcloud;&lt;br /&gt;
        index  index.php index.html index.htm;&lt;br /&gt;
	disable_symlinks off;&lt;br /&gt;
&lt;br /&gt;
        ssl_certificate      /etc/ssl/cert.pem;&lt;br /&gt;
        ssl_certificate_key  /etc/ssl/key.pem;&lt;br /&gt;
        ssl_session_timeout  5m;&lt;br /&gt;
&lt;br /&gt;
        #Enable Perfect Forward Secrecy and ciphers without known vulnerabilities&lt;br /&gt;
        #Beware! It breaks compatibility with older OS and browsers (e.g. Windows XP, Android 2.x, etc.)&lt;br /&gt;
	#ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA;&lt;br /&gt;
        #ssl_prefer_server_ciphers  on;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        location / {&lt;br /&gt;
            try_files $uri $uri/ /index.html;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000&lt;br /&gt;
        location ~ [^/]\.php(/&amp;amp;#124;$) {&lt;br /&gt;
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
                if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                        return 404;&lt;br /&gt;
                }&lt;br /&gt;
                #fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
		#fastcgi_pass unix:/run/php-fpm/socket;&lt;br /&gt;
		fastcgi_pass unix:/run/nextcloud/fastcgi.sock; # From the nextcloud-initscript package&lt;br /&gt;
                fastcgi_index index.php;&lt;br /&gt;
                include fastcgi.conf;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
        # Help pass nextcloud&#039;s configuration checks after install:&lt;br /&gt;
        # Per https://docs.nextcloud.com/server/22/admin_manual/issues/general_troubleshooting.html#service-discovery&lt;br /&gt;
        location ^~ /.well-known/carddav { return 301 /remote.php/dav/; }&lt;br /&gt;
        location ^~ /.well-known/caldav { return 301 /remote.php/dav/; }&lt;br /&gt;
        location ^~ /.well-known/webfinger { return 301 /index.php/.well-known/webfinger; }&lt;br /&gt;
        location ^~ /.well-known/nodeinfo { return 301 /index.php/.well-known/nodeinfo; }&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
If you plan to enable uploads - and you probably do) - then you need to modify the default:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
client_max_body_size 1m;&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
setting in {{path|/etc/nginx/nginx.conf}}. For testing purposes, I disabled the limit by changing it to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
client_max_body_size 0;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This enabled large file uploads and auto-uploads to work. Note, this is a file-size restriction in addition to the restriction set in {{path|/etc/php8/php-fpm.d/nextcloud.conf}}. That second restriction defaults to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
; Maximal size of a file that can be uploaded via web interface.&lt;br /&gt;
php_admin_value[memory_limit] = 512M&lt;br /&gt;
php_admin_value[post_max_size] = 513M&lt;br /&gt;
php_admin_value[upload_max_filesize] = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another setting that may limit file-size is in configuration file {{path|/etc/php8/php.ini}}, where I set the restriction to to:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
upload_max_filesize = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to match the {{path|/etc/php8/php-fpm.d/nextcloud.conf}} file-size restriction.&lt;br /&gt;
&lt;br /&gt;
If you are running from RAM and you&#039;re dealing with large files you might need to move the FastCGI temp file from {{path|/tmp}} to {{path|/var/tmp}} or to a directory that is mounted on hdd:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_temp_path /var/tmp/nginx/fastcgi 1 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Large file uploads take some time to be processed by php-fpm, so you need to bump the Nginx default read timeout:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fastcgi_read_timeout 300s;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are serving several users make sure to tune the *&#039;&#039;pm.max_children&#039;&#039; setting in {{path|/etc/php8/php-fpm.d/nextcloud.conf}}}}&lt;br /&gt;
&lt;br /&gt;
{{path|/etc/nginx/nginx.conf}} should already be configured to load your site config from this directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# Includes virtual hosts configs.&lt;br /&gt;
include /etc/nginx/http.d/*;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start services:&lt;br /&gt;
{{cmd|service nginx start&lt;br /&gt;
service nextcloud start}}&lt;br /&gt;
&lt;br /&gt;
Enable automatic startup of services:&lt;br /&gt;
{{cmd|rc-update add nginx&lt;br /&gt;
rc-update add nextcloud}}&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd ===&lt;br /&gt;
Install the package:&lt;br /&gt;
{{cmd|apk add lighttpd php5-cgi}}&lt;br /&gt;
&lt;br /&gt;
Make sure you have FastCGI enabled in {{pkg|lighttpd}}:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
include &amp;quot;mod_fastcgi.conf&amp;quot;&lt;br /&gt;
...}}&lt;br /&gt;
&lt;br /&gt;
Start up the webserver:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
{{tip|You might want to follow the [http://wiki.alpinelinux.org/wiki/Lighttpd_Https_access Lighttpd_Https_access] doc in order to configure lighttpd to use https &#039;&#039;(securing your connections to your nextcloud server)&#039;&#039;.}}&lt;br /&gt;
&lt;br /&gt;
Link {{pkg|nextcloud}} installation to web server directory:&lt;br /&gt;
{{cmd|ln -s /usr/share/webapps/nextcloud /var/www/localhost/htdocs}}&lt;br /&gt;
&lt;br /&gt;
== Other settings ==&lt;br /&gt;
=== Hardening ===&lt;br /&gt;
Consider updating the variable &amp;lt;code&amp;gt;url.access-deny&amp;lt;/code&amp;gt; in {{path|/etc/lighttpd/lighttpd.conf}} for additional security. Add &amp;lt;code&amp;gt;&amp;quot;config.php&amp;quot;&amp;lt;/code&amp;gt; to the variable &#039;&#039;(that&#039;s where the database is stored)&#039;&#039; so it looks something like this:&lt;br /&gt;
{{cat|/etc/lighttpd/lighttpd.conf|...&lt;br /&gt;
url.access-deny {{=}} (&amp;quot;~&amp;quot;, &amp;quot;.inc&amp;quot;, &amp;quot;config.php&amp;quot;)&lt;br /&gt;
...}}&lt;br /&gt;
Restart {{pkg|lighttpd}} to activate the changes:&lt;br /&gt;
{{cmd|/etc/init.d/lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
=== Additional packages ===&lt;br /&gt;
Some large apps, such as pdfviewer, texteditor, notifications and videoplayer are in separate packages:&lt;br /&gt;
{{cmd|apk add nextcloud-files_pdfviewer nextcloud-text nextcloud-notifications nextcloud-files_videoplayer}}&lt;br /&gt;
You can also install a [https://pkgs.alpinelinux.org/package/v3.15/community/x86_64/nextcloud-default-apps meta-package] which installs all 30 core Nextcloud apps (listed as dependencies under aforementioned link):&lt;br /&gt;
{{cmd|apk add nextcloud-default-apps}}&lt;br /&gt;
&lt;br /&gt;
=== How To Create a Self-Signed SSL Certificate ===&lt;br /&gt;
Install openssl:&lt;br /&gt;
{{cmd|apk add openssl}}&lt;br /&gt;
Generate your self signed certificate and its private key:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl1.1/private/nextcloud-selfsigned.key -out /etc/ssl1.1/certs/nextcloud-selfsigned.crt&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Edit your nginx configuration:&lt;br /&gt;
{{cat|/etc/nginx/http.d/mysite.mydomain.com.conf|&lt;br /&gt;
ssl_certificate      /etc/ssl1.1/certs/nextcloud-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key  /etc/ssl1.1/private/nextcloud-selfsigned.key;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== How To Install and Set Up Auto-Renewing LetsEncrypt SSL Certificate ===&lt;br /&gt;
After first setting up the Nextcloud server using the instructions in the &#039;Configure and use Nextcloud&#039; section below, I then followed the SSL-setup instructions at: [[https://techjogging.com/create-letsencrypt-certificate-alpine-nginx.html Tech Jogging]].&lt;br /&gt;
&lt;br /&gt;
I also had to add my Nextcloud servers Fully Qualified Domain Name (FQDN) to the list of trusted domains in /etc/nextcloud/config.php. In the section labelled: &#039;trusted_domains&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&#039;trusted_domains&#039; =&amp;gt;&lt;br /&gt;
  array (&lt;br /&gt;
    0 =&amp;gt; &#039;&amp;lt;machine&#039;s local IP address&amp;gt;&#039;,&lt;br /&gt;
    1 =&amp;gt; &#039;nextcloud.mydomain.com&#039;,&lt;br /&gt;
  ),&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configure and use Nextcloud =&lt;br /&gt;
&lt;br /&gt;
== Configure ==&lt;br /&gt;
Point your browser at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://mysite.mydomain.com&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and follow the on-screen instructions to complete the installation, supplying the database user and password created before.&lt;br /&gt;
&lt;br /&gt;
== Hardening PostgreSQL ==&lt;br /&gt;
If you have chosen PGSQL backend, revoke CREATEDB privilege from &#039;mycloud&#039; user:&lt;br /&gt;
{{cmd|psql -U postgres&lt;br /&gt;
ALTER ROLE mycloud NOCREATEDB;&lt;br /&gt;
\q}}&lt;br /&gt;
&lt;br /&gt;
== Increase upload size ==&lt;br /&gt;
 {{path|/etc/php/php-fpm.d/nextcloud.conf}} has overridden default file sizes, but they can be modified further to suit your needs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
; Maximal size of a file that can be uploaded via web interface.&lt;br /&gt;
php_admin_value[memory_limit] = 512M&lt;br /&gt;
php_admin_value[post_max_size] = 513M&lt;br /&gt;
php_admin_value[upload_max_filesize] = 513M&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== enable opcache for nginx/php7 ==&lt;br /&gt;
To increase performace install&lt;br /&gt;
{{cmd|apk add php7-opcache}}&lt;br /&gt;
&lt;br /&gt;
Now uncomment/edit lines in /etc/php7/php.ini:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
opcache.enable=1&lt;br /&gt;
opcache.enable_cli=1&lt;br /&gt;
opcache.interned_strings_buffer=8&lt;br /&gt;
opcache.max_accelerated_files=10000&lt;br /&gt;
opcache.memory_consumption=128&lt;br /&gt;
opcache.save_comments=1&lt;br /&gt;
opcache.revalidate_freq=1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart php-fpm7&lt;br /&gt;
{{cmd|rc-service php-fpm7 restart}}&lt;br /&gt;
&lt;br /&gt;
== Clients ==&lt;br /&gt;
There are clients available for many platforms, Android included:&lt;br /&gt;
* http://nextcloud.org/sync-clients/ &#039;&#039;(nextcloud Sync clients)&#039;&#039;&lt;br /&gt;
* http://nextcloud.org/support/android/ &#039;&#039;(Android client)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://pkgs.alpinelinux.org/packages?name=nextcloud-client&amp;amp;branch=&amp;amp;repo=&amp;amp;arch=&amp;amp;maintainer= nextcloud-client] is currently available in the testing repo.&lt;br /&gt;
&lt;br /&gt;
= Video Communication =&lt;br /&gt;
One of the major features of Nextcloud 11, available on Alpine 3.6 (currently edge) is a [https://nextcloud.com/webrtc/ WebRTC app], which relies on Spreed WebRTC server, which is available in the Alpine testing repository. Everything is still beta, so be aware of it :-). If you want a private video conferencing server install Nextcloud using Nginx and do the following (you can use Apache as well and follow the &#039;&#039;Apache config&#039;&#039; instructions [https://nextcloud.com/webrtc/ nextcloud.com]):&lt;br /&gt;
&lt;br /&gt;
Put the following config in the &#039;&#039;server&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Spreed WebRTC&lt;br /&gt;
location ^~ /webrtc {&lt;br /&gt;
  proxy_pass http://127.0.0.1:8080;&lt;br /&gt;
  proxy_http_version 1.1;&lt;br /&gt;
  proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
  proxy_set_header Connection $connection_upgrade;&lt;br /&gt;
  proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
  proxy_set_header Host $http_host;&lt;br /&gt;
  proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
&lt;br /&gt;
  proxy_buffering             on;&lt;br /&gt;
  proxy_ignore_client_abort   off;&lt;br /&gt;
  proxy_redirect              off;&lt;br /&gt;
  proxy_connect_timeout       90;&lt;br /&gt;
  proxy_send_timeout          90;&lt;br /&gt;
  proxy_read_timeout          90;&lt;br /&gt;
  proxy_buffer_size           4k;&lt;br /&gt;
  proxy_buffers               4 32k;&lt;br /&gt;
  proxy_busy_buffers_size     64k;&lt;br /&gt;
  proxy_temp_file_write_size  64k;&lt;br /&gt;
  proxy_next_upstream         error timeout invalid_header http_502 http_503 http_504;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Put the following section in the &#039;&#039;http&#039;&#039; section of Nginx:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
map $http_upgrade $connection_upgrade {&lt;br /&gt;
  default upgrade;&lt;br /&gt;
  &#039;&#039;      close;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reload Nginx:&lt;br /&gt;
{{cmd|rc-service nginx reload}}&lt;br /&gt;
&lt;br /&gt;
Install Spreed WedRTC server (make sure you have the testing [https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management#Packages_and_Repositories repository] enabled):&lt;br /&gt;
{{cmd|apk add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Using the configuration file in &#039;&#039;/etc/spreed-webrtc/spreed-webrtc-server.conf&#039;&#039; follow the instructions at [https://nextcloud.com/webrtc/ nextcloud.com] to configure Spreed WebRTC server. Then start the server:&lt;br /&gt;
{{cmd|rc-service spreed-web-server start}}&lt;br /&gt;
{{cmd|rc-update add spreed-web-server}}&lt;br /&gt;
&lt;br /&gt;
Install the &#039;&#039;Spreed video calls&#039;&#039; app in Nextcloud and enjoy your private video calls.&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>154pinkchairs</name></author>
	</entry>
</feed>