From ad71068a6a1aa0190e914e68f9308e3f18f85507 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Mon, 1 Jun 2020 21:33:26 +0200 Subject: [PATCH] Added pinephone-toolkit build. Extracted script for power sleep and wake. --- Makefile | 7 ++++++- home/config/sway/config | 18 ++++++++++++++---- home/config/waybar/config_0 | 12 ++++++++++-- home/config/waybar/style.css | 2 +- usr/local/bin/swayphone_backlightselect | 2 +- usr/local/bin/swayphone_power_sleep | 10 ++++++++++ usr/local/bin/swayphone_power_wakeup | 12 ++++++++++++ 7 files changed, 54 insertions(+), 9 deletions(-) mode change 100644 => 100755 home/config/waybar/style.css create mode 100755 usr/local/bin/swayphone_power_sleep create mode 100755 usr/local/bin/swayphone_power_wakeup diff --git a/Makefile b/Makefile index 585d6c1..625cdd1 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ install_user_htop: ### # INSTALL - SYSTEM ### -install_system: install_system_check install_system_lightdm install_system_bin +install_system: install_system_check install_system_lightdm install_system_bin install_pptk install_system_check: @echo "Note: install needs to be run as root." @@ -40,6 +40,11 @@ install_system_bin: chmod go+rx usr/local/bin/* cp usr/local/bin/* /usr/local/bin/ +install_pptk: + cd pinephone-toolkit && meson build + ninja -C pinephone-toolkit/build + ninja -C pinephone-toolkit/build install + ### # FETCH ### diff --git a/home/config/sway/config b/home/config/sway/config index b6dbcdb..1f4a595 100755 --- a/home/config/sway/config +++ b/home/config/sway/config @@ -201,11 +201,11 @@ bindsym $mod+r mode "resize" # # Power Button # +set $pplock 'swayphone_power_sleep' +set $ppunlock 'swayphone_power_wakeup' set $lockapp swaylock set $lock '$lockapp -f -c 000000' set $unlock 'killall $lockapp' -set $pplock 'pptk-led set red 1; pptk-cpu-sleep enable; pptk-backlight get > ~/.backlight ; pptk-backlight set 0' -set $ppunlock 'pptk-led set red 0; pptk-cpu-sleep disable; pptk-backlight set `cat ~/.backlight`' ## wish this worked... #bindsym XF86PowerOff exec $lock #bindsym --locked XF86PowerOff exec $unlock @@ -213,8 +213,18 @@ set $ppunlock 'pptk-led set red 0; pptk-cpu-sleep disable; pptk-backlight set `c bindcode 124 exec $lock; exec $pplock bindcode --locked 124 exec $unlock; exec $ppunlock +exec swayidle -w \ + timeout 15 'swaymsg exec $lock; $pplock' \ + resume 'swaymsg exec $unlock; $ppunlock' \ + before-sleep 'swaymsg exec $lock; $pplock' + # Scale the touchscreen LCD 2x -output DSI-1 scale 2 +#output DSI-1 scale 2 + +# Bind input and output for correct rotation support +input 1046:4097:Goodix_Capacitive_TouchScreen map_to_output DSI-1 +#output DSI-1 transform 90 +output DSI-1 transform 0 # Keyboard exec squeekboard @@ -243,5 +253,5 @@ exec "waybar -c ~/.config/waybar/config_0 -b b0" exec "waybar -c ~/.config/waybar/config_1 -b b1" # Restore backlight -exec "cat ~/.backlight && pptk-backlight set `cat ~/.backlight`" +exec 'swayphone_power_wakeup' diff --git a/home/config/waybar/config_0 b/home/config/waybar/config_0 index 541ffbb..854039e 100755 --- a/home/config/waybar/config_0 +++ b/home/config/waybar/config_0 @@ -103,10 +103,18 @@ "sway/workspaces": { "all-outputs": false, "disable-scroll": true, + "persistent_workspaces": { + "1": [], + "2:T": [], + "3:F": [], + "8:M": [], + "9:K": [] + }, "format": "{name}", "format-icons": { - "1:www": "龜", // Icon: firefox-browser - "2:mail": "", // Icon: mail + "1:T": "", // Icon: terminal + "2:F": "龜", // Icon: firefox-browser + "8:M": "", // Icon: mail "3:editor": "", // Icon: code "4:terminals": "", // Icon: terminal "5:portal": "", // Icon: terminal diff --git a/home/config/waybar/style.css b/home/config/waybar/style.css old mode 100644 new mode 100755 index 09043ac..af191b5 --- a/home/config/waybar/style.css +++ b/home/config/waybar/style.css @@ -12,7 +12,7 @@ background: #282828; color: white; font-family: "awesome 5"; - font-size: 10px; + font-size: 24px; font-weight: bold; } diff --git a/usr/local/bin/swayphone_backlightselect b/usr/local/bin/swayphone_backlightselect index 638eace..4fcf28a 100755 --- a/usr/local/bin/swayphone_backlightselect +++ b/usr/local/bin/swayphone_backlightselect @@ -2,7 +2,7 @@ BACKLIGHT=~/.backlight -dialog --menu EXECUTE 20 40 10 \ +dialog --menu Backlight 0 0 10 \ 10 FULL \ 9 . \ 8 . \ diff --git a/usr/local/bin/swayphone_power_sleep b/usr/local/bin/swayphone_power_sleep new file mode 100755 index 0000000..77da5c4 --- /dev/null +++ b/usr/local/bin/swayphone_power_sleep @@ -0,0 +1,10 @@ +#!/bin/bash + +pptk-led set red 1 +pptk-cpu-sleep enable + +# save current backlight for wakeup +pptk-backlight get > ~/.backlight +# shut down backlight +pptk-backlight set 0 + diff --git a/usr/local/bin/swayphone_power_wakeup b/usr/local/bin/swayphone_power_wakeup new file mode 100755 index 0000000..bc9d529 --- /dev/null +++ b/usr/local/bin/swayphone_power_wakeup @@ -0,0 +1,12 @@ +#!/bin/bash + +BACKLIGHT_FILE=~/.backlight +BACKLIGHT_MIN=3 + +pptk-led set red 0 +pptk-cpu-sleep disable + +# restore last saved backlight level +BACKLIGHT=$((`cat $BACKLIGHT_FILE` >= $BACKLIGHT_MIN ? `cat $BACKLIGHT_FILE` : $BACKLIGHT_MIN)) +pptk-backlight set $BACKLIGHT +