1
0
mirror of https://github.com/Dejvino/pinephone-sway-poc.git synced 2024-09-20 22:33:36 +00:00

Power management supports suspend. Mentioned ALARM.

This commit is contained in:
Dejvino 2021-01-10 19:23:35 +01:00
parent a81ff33c76
commit bf413bae80
6 changed files with 57 additions and 25 deletions

View File

@ -1,17 +1,18 @@
# pinephone-sway-poc # pinephone-sway-poc
Sway UI configured for PINE64 PinePhone (Proof Of Concept) Sway UI configured for PINE64 PinePhone (Proof Of Concept)
You can find ready-made config files, scripts and installation instructions on how to set up Sway on postmarketOS and use it with a PinePhone. You can find ready-made config files, scripts and installation instructions on how to set up Sway on Arch Linux ARM or postmarketOS and use it with a PinePhone.
![Screenshots](./screenshots.png) ![Screenshots](./screenshots.png)
## Install ## Install
### postmarketOS
Start with a [postmarketOS](https://wiki.postmarketos.org/wiki/PINE64_PinePhone_(pine64-pinephone)) for PinePhone image with `postmarketos-ui-sway` installed. Either use the pre-built demo image or build a custom one with `pmbootstrap`. Start with a [postmarketOS](https://wiki.postmarketos.org/wiki/PINE64_PinePhone_(pine64-pinephone)) for PinePhone image with `postmarketos-ui-sway` installed. Either use the pre-built demo image or build a custom one with `pmbootstrap`.
Flash the system onto the phone (either to an SD card or directly to the eMMC with Jumpdrive). Flash the system onto the phone (either to an SD card or directly to the eMMC with Jumpdrive).
Open a terminal on the phone (either through SSH, the serial connection or directly on the screen) and run this: Open a terminal on the phone (either through SSH, the serial connection or directly on the screen) and run this:
``` ```bash
# system components # system components
$ sudo apk add waybar bemenu swaylock swayidle squeekboard bash dialog tzdata $ sudo apk add waybar bemenu swaylock swayidle squeekboard bash dialog tzdata
@ -20,12 +21,25 @@ $ sudo apk add networkmanager htop pavucontrol
# build tools # build tools
$ sudo apk add git make meson ninja cargo linux-headers libinput-dev eudev-dev $ sudo apk add git make meson ninja cargo linux-headers libinput-dev eudev-dev
```
### Arch Linux ARM
Start with a [Pine64-Arch](https://github.com/dreemurrs-embedded/Pine64-Arch/) image flashed to the phone. You'll need the `sway` package and most of what is mentioned in the `postmarketOS` section. Disable (or remove) the default `phosh` package so that it doesn't get loaded on boot.
### Common
```bash
# installation # installation
$ git clone --recurse-submodules https://github.com/Dejvino/pinephone-sway-poc $ git clone --recurse-submodules https://github.com/Dejvino/pinephone-sway-poc
$ cd pinephone-sway-poc $ cd pinephone-sway-poc
$ make install_user $ make install_user
$ sudo make install_system $ sudo make install_system
# power button
sudo vim /etc/systemd/logind.conf # or /etc/elogind/logind.conf for non-systemd distros (pmOS)
# replace:
# #HandlePowerKey=poweroff
# with:
# HandlePowerKey=suspend
``` ```
That's it. You should now have everything in place. Reboot to use the new settings. That's it. You should now have everything in place. Reboot to use the new settings.
@ -34,7 +48,7 @@ That's it. You should now have everything in place. Reboot to use the new settin
Study the provided config files and shell scripts to get more details. The following is just an introduction. Study the provided config files and shell scripts to get more details. The following is just an introduction.
### Power Button ### Power Button
The power button activates or deactivates a "sleep mode", in which the backlight is turned off, all the CPUs except for the primary one are shut down and the red LED is turned on to indicate the phone is turned on. The power button activates or deactivates a "sleep mode" (suspend). This mode is automatically entered after a period of inactivity (via swayidle). Before that, the backlight is first turned low, then the backlight is turned off and all the CPUs except for the primary one are shut down. The indicator LED is used to indicate the power mode: 1) green = running, low power usage, 2) blue = suspend.
### Top and bottom waybar ### Top and bottom waybar
The bars show you CPU/MEM usage, backlight brightness, time, etc. Touching them opens a relevant app (e.g. NetworkManager or htop). Touching the date opens a custom "quick execute" menu to launch an app. The **[x]** icon closes the active window. Touching the backlight indicator brings up a custom brightness setting app. The bars show you CPU/MEM usage, backlight brightness, time, etc. Touching them opens a relevant app (e.g. NetworkManager or htop). Touching the date opens a custom "quick execute" menu to launch an app. The **[x]** icon closes the active window. Touching the backlight indicator brings up a custom brightness setting app.
@ -53,19 +67,20 @@ $ make fetch
Running this command gathers the relevant config files from your running system and replaces the files in the repository. You can then `git add` and `commit` your own changes, straight from the phone! This is actually how the config files here were created. Running this command gathers the relevant config files from your running system and replaces the files in the repository. You can then `git add` and `commit` your own changes, straight from the phone! This is actually how the config files here were created.
## Components ## Components
* postmarketOS - base Linux distribution (though any other would work as well) * postmarketOS / Arch Linux ARM - base Linux distribution (though any other would work as well)
* sway (pmos package) - tiling Wayland compositor * sway (packaged) - tiling Wayland compositor
* * swayidle, swaylock - utils for sway * * swayidle, swaylock - utils for sway
* bemenu (pmos package) - app launcher * bemenu (packaged) - app launcher
* waybar (pmos package) - Wayland status bar * waybar (packaged) - Wayland status bar
* * [carlosdss22/dotfiles](https://github.com/carlosdss22/dotfiles/tree/master/waybar) - styles used * * [carlosdss22/dotfiles](https://github.com/carlosdss22/dotfiles/tree/master/waybar) - styles used
* squeekboard (pmos package) - on-screen keyboard for Wayland * squeekboard (packaged) - on-screen keyboard for Wayland
* * [terminal.yaml](https://source.puri.sm/btantau/squeekboard/blob/btantau-master-patch-76686/data/keyboards/terminal.yaml) - keyboard layout based on this improved version * * [terminal.yaml](https://source.puri.sm/btantau/squeekboard/blob/btantau-master-patch-76686/data/keyboards/terminal.yaml) - keyboard layout based on this improved version
* [pinephone-toolkit](https://github.com/Dejvino/pinephone-toolkit) - various utilities for the PinePhone * [pinephone-toolkit](https://github.com/Dejvino/pinephone-toolkit) - various utilities for the PinePhone
* [sxmo-lisgd](https://git.sr.ht/~mil/lisgd) - gesture detection daemon * [sxmo-lisgd](https://git.sr.ht/~mil/lisgd) - gesture detection daemon
* [rot8](https://github.com/efernau/rot8) - screen rotation daemon using data from the accelerometer * [rot8](https://github.com/efernau/rot8) - screen rotation daemon using data from the accelerometer
* htop (pmos package) - Processes monitoring * htop (packaged) - Processes monitoring
* pavucontrol (pmos package) - PulseAudio control panel * pavucontrol (packaged) - PulseAudio control panel
* mako (packaged) - Notify daemon
(*pmos package* = available as a package directly from the postmarketOS repository) (*packaged* = available as a package directly from the repository)

View File

@ -217,19 +217,24 @@ bindsym $mod+r mode "resize"
set $pplock 'swayphone_power_sleep' set $pplock 'swayphone_power_sleep'
set $ppunlock 'swayphone_power_wakeup' set $ppunlock 'swayphone_power_wakeup'
set $lockapp swaylock set $lockapp swaylock
set $lock '$lockapp -f -c 000000' set $lock '$lockapp -f -c 555555'
set $unlock 'killall $lockapp' set $unlock 'killall $lockapp'
## wish this worked... ## wish this worked...
#bindsym XF86PowerOff exec $lock #bindsym XF86PowerOff exec $lock
#bindsym --locked XF86PowerOff exec $unlock #bindsym --locked XF86PowerOff exec $unlock
# alternative: # alternative:
bindcode 124 exec $lock; exec $pplock bindcode 124 exec '$lock ; swayphone_power_presleep'
bindcode --locked 124 exec $unlock; exec $ppunlock bindcode --locked 124 exec '$unlock ; swayphone_power_wakeup'
exec swayidle -w \ exec swayidle -w \
timeout 15 'swaymsg exec $lock; $pplock' \ timeout 30 'pptk-backlight set_percent 10' \
resume 'swaymsg exec $unlock; $ppunlock' \ resume 'swayphone_power_wakeup' \
before-sleep 'swaymsg exec $lock; $pplock' timeout 60 'swayphone_power_rest' \
resume 'swayphone_power_wakeup' \
timeout 120 'swayphone_power_sleep' \
before-sleep 'swayphone_power_presleep' \
after-resume 'killall swaylock; swayphone_power_wakeup' \
unlock 'killall swaylock'
# Scale the touchscreen LCD UI # Scale the touchscreen LCD UI
output DSI-1 scale 2 output DSI-1 scale 2

View File

@ -0,0 +1,7 @@
#!/bin/bash
pptk-led set red 0
pptk-led set green 0
pptk-led set blue 1
pptk-backlight set 0

View File

@ -0,0 +1,7 @@
#!/bin/bash
pptk-led set green 1
pptk-cpu-sleep enable
pptk-backlight set 0

View File

@ -1,10 +1,6 @@
#!/bin/bash #!/bin/bash
pptk-led set red 1 swayphone_power_presleep
pptk-cpu-sleep enable
# save current backlight for wakeup systemctl suspend
pptk-backlight get > ~/.backlight
# shut down backlight
pptk-backlight set 0

View File

@ -1,12 +1,14 @@
#!/bin/bash #!/bin/bash
BACKLIGHT_FILE=~/.backlight BACKLIGHT_FILE=~/.backlight
BACKLIGHT_MIN=3 BACKLIGHT_MIN=10
pptk-led set red 0 pptk-led set red 0
pptk-led set green 0
pptk-led set blue 0
pptk-cpu-sleep disable pptk-cpu-sleep disable
# restore last saved backlight level # restore last saved backlight level
BACKLIGHT=$((`cat $BACKLIGHT_FILE` >= $BACKLIGHT_MIN ? `cat $BACKLIGHT_FILE` : $BACKLIGHT_MIN)) BACKLIGHT=$((`cat $BACKLIGHT_FILE` >= $BACKLIGHT_MIN ? `cat $BACKLIGHT_FILE` : $BACKLIGHT_MIN))
pptk-backlight set $BACKLIGHT pptk-backlight set_percent $BACKLIGHT