From 59058763752c89b54ad18103d2026092d10778a2 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Tue, 16 Jun 2020 23:41:58 +0200 Subject: [PATCH] Add vertical waybar for landscape mode --- .gitmodules | 2 +- home/config/sway/config | 51 ++++---- home/config/waybar/config_0 | 8 +- home/config/waybar/config_v | 202 ++++++++++++++++++++++++++++++++ home/config/waybar/style.css | 32 ++++- usr/local/bin/swayphone_rotated | 35 ++++++ 6 files changed, 302 insertions(+), 28 deletions(-) create mode 100755 home/config/waybar/config_v create mode 100755 usr/local/bin/swayphone_rotated diff --git a/.gitmodules b/.gitmodules index c35eef6..4707c7b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,7 +4,7 @@ [submodule "rot8"] path = rot8 url = https://github.com/Dejvino/rot8.git - branch = accelerometer_param + branch = pinephone [submodule "lisgd"] path = lisgd url = https://git.sr.ht/~mil/lisgd diff --git a/home/config/sway/config b/home/config/sway/config index 24fb1a0..c2f0b7b 100755 --- a/home/config/sway/config +++ b/home/config/sway/config @@ -111,34 +111,41 @@ output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill # # Workspaces: # + set $W1 '1' + set $W2 '2' set $W3 '3:F' + set $W4 '4:4' + set $W5 '5:P' + set $W6 '6:6' + set $W7 '7:7' + set $W8 '8:M' set $W9 '9:K' for_window [app_id="firefox"] move workspace $W3; workspace $W3; border none for_window [app_id="keepassxc"] move workspace $W9; workspace $W9; border none # Switch to workspace - bindsym $mod+1 workspace 1 - bindsym $mod+2 workspace 2 + bindsym $mod+1 workspace $W1 + bindsym $mod+2 workspace $W2 bindsym $mod+3 workspace $W3 - bindsym $mod+4 workspace 4 - bindsym $mod+5 workspace 5 - bindsym $mod+6 workspace 6 - bindsym $mod+7 workspace 7 - bindsym $mod+8 workspace 8 + bindsym $mod+4 workspace $W4 + bindsym $mod+5 workspace $W5 + bindsym $mod+6 workspace $W6 + bindsym $mod+7 workspace $W7 + bindsym $mod+8 workspace $W8 bindsym $mod+9 workspace $W9 - bindsym $mod+0 workspace 10 + bindsym $mod+0 workspace $W10 # Move focused container to workspace - bindsym $mod+Shift+1 move container to workspace 1 - bindsym $mod+Shift+2 move container to workspace 2 + bindsym $mod+Shift+1 move container to workspace $W1 + bindsym $mod+Shift+2 move container to workspace $W2 bindsym $mod+Shift+3 move container to workspace $W3 - bindsym $mod+Shift+4 move container to workspace 4 - bindsym $mod+Shift+5 move container to workspace 5 - bindsym $mod+Shift+6 move container to workspace 6 - bindsym $mod+Shift+7 move container to workspace 7 - bindsym $mod+Shift+8 move container to workspace 8 + bindsym $mod+Shift+4 move container to workspace $W4 + bindsym $mod+Shift+5 move container to workspace $W5 + bindsym $mod+Shift+6 move container to workspace $W6 + bindsym $mod+Shift+7 move container to workspace $W7 + bindsym $mod+Shift+8 move container to workspace $W8 bindsym $mod+Shift+9 move container to workspace $W9 - bindsym $mod+Shift+0 move container to workspace 10 + bindsym $mod+Shift+0 move container to workspace $W10 # Note: workspaces can have any name you want, not just numbers. # We just use 1-10 as the default. # @@ -233,7 +240,7 @@ input 1046:4097:Goodix_Capacitive_TouchScreen map_to_output DSI-1 output DSI-1 transform 0 # Display rotation daemon -exec 'rot8 --display DSI-1 --threshold 0.97 --x-file /sys/bus/iio/devices/iio:device2/in_accel_y_raw --y-file /sys/bus/iio/devices/iio:device2/in_accel_x_raw --y-invert' +exec 'rot8 --display DSI-1 --threshold 0.97 --x-file /sys/bus/iio/devices/iio:device2/in_accel_y_raw --y-file /sys/bus/iio/devices/iio:device2/in_accel_x_raw --y-invert --on-change swayphone_rotated' # Keyboard exec squeekboard @@ -259,9 +266,13 @@ exec lisgd \ -g "4,u,d, swaymsg move down" \ -g "4,d,u, swaymsg move up" -# Top and bottom status bar -exec "waybar -c ~/.config/waybar/config_0 -b b0" -exec "waybar -c ~/.config/waybar/config_1 -b b1" +# Status Bar +# side +exec "rm /tmp/sway_rotation" +exec "waybar -c ~/.config/waybar/config_v -b side" +exec "sleep 2 ; kill -10 `pgrep -f 'waybar.*-b side'`" +exec "waybar -c ~/.config/waybar/config_0 -b top" +exec "waybar -c ~/.config/waybar/config_1 -b bottom" # Restore backlight exec 'swayphone_power_wakeup' diff --git a/home/config/waybar/config_0 b/home/config/waybar/config_0 index 854039e..4505858 100755 --- a/home/config/waybar/config_0 +++ b/home/config/waybar/config_0 @@ -105,19 +105,15 @@ "disable-scroll": true, "persistent_workspaces": { "1": [], - "2:T": [], "3:F": [], "8:M": [], "9:K": [] }, "format": "{name}", "format-icons": { - "1:T": "", // Icon: terminal - "2:F": "龜", // Icon: firefox-browser + //"1:T": "", // Icon: terminal + "3:F": "龜", // Icon: firefox-browser "8:M": "", // Icon: mail - "3:editor": "", // Icon: code - "4:terminals": "", // Icon: terminal - "5:portal": "", // Icon: terminal "urgent": "", "focused": "", "default": "" diff --git a/home/config/waybar/config_v b/home/config/waybar/config_v new file mode 100755 index 0000000..8b6d9f5 --- /dev/null +++ b/home/config/waybar/config_v @@ -0,0 +1,202 @@ + +{ + //GLOBAL + + + "layer": "top", + + "position": "right", + "width": 100, + + "modules-left": [ + "clock#time", + "clock#date", + "battery", + "tray" + ], + + "modules-center": [ + "sway/workspaces" + ], + + "modules-right": [ + "custom/kill", + "cpu", + "memory", +// "disk" + "network", + "backlight", + "pulseaudio" + ], + +//MODULES + + "clock#time": { + "interval": 10, + "locale": "C", + "timezone": "Europe/Berlin", + "format": "{:%H:%M}", + "tooltip": false + }, + + + "clock#date": { + "interval": 20, + "locale": "C", + "timezone": "Europe/Berlin", + "format": " {:%e %b %Y}", // Icon: calendar-alt + //"tooltip-format": "{:%e %B %Y}" + "tooltip": true, + "on-click": "termite -e swayphone_menuselect" + }, + + "battery": { + "interval": 1, + "states": { + "warning": 30, + "critical": 15 + }, + // Connected to AC + "format": " {capacity}%", // Icon: bolt + // Not connected to AC + "format-discharging": " {capacity}%", + "format-icons": [ + "", // Icon: battery-full + "", // Icon: battery-three-quarters + "", // Icon: battery-half + "", // Icon: battery-quarter + "" // Icon: battery-empty + ], + "tooltip": false + }, + + + + + "sway/mode": { + "format": " {}", + "tooltip": true + }, + + + "sway/workspaces": { + "all-outputs": false, + "disable-scroll": true, + "persistent_workspaces": { + "1": [], + "3:F": [], + "8:M": [], + "9:K": [] + }, + "format": "{name}", + "format-icons": { + //"1:T": "", // Icon: terminal + "3:F": "龜", // Icon: firefox-browser + "8:M": "", // Icon: mail + "urgent": "", + "focused": "", + "default": "" + } + }, + + "custom/kill": { + "on-click": "swaymsg kill", + "format": "[x]" + }, + + "battery": { + "interval": 1, + "states": { + "warning": 30, + "critical": 15 + }, + // Connected to AC + "format": " {capacity}%", // Icon: bolt + // Not connected to AC + "format-discharging": " {capacity}%", + "format-icons": [ + "", // Icon: battery-full + "", // Icon: battery-three-quarters + "", // Icon: battery-half + "", // Icon: battery-quarter + "" // Icon: battery-empty + ], + "tooltip": false + }, + + + + "cpu": { + "interval": 5, + "tooltip": false, + "format": " {usage}%", //Icon: microchip + "states": { + "warning": 70, + "critical": 90 + }, + "on-click": "termite -e \"htop --sort-key=PERCENT_CPU\"" + }, + + + "memory": { + "interval": 5, + "format": " {}%", // Icon: memory + "states": { + "warning": 70, + "critical": 90 + }, + "on-click": "termite -e \"htop --sort-key=PERCENT_MEM\"" + }, + + "network": { + "interval": 5, + "format-wifi": "  {essid}", // Icon: wifi + "format-ethernet": " {ifname}", // Icon: ethernet + "format-disconnected": "Disconnected", + "tooltip-format": "{ifname}: {ipaddr}", + "on-click": "swaymsg exec \"termite -e nmtui\"" + }, + + "pulseaudio": { + "scroll-step": 1, + "format": "{icon} {volume}%", + "format-bluetooth": "{icon} {volume}%", + "format-muted": "", + "format-icons": { + "headphones": "", + "handsfree": "", + "headset": "", + "phone": "", + "portable": "", + "car": "", + "default": ["", ""] + }, + "on-click": "pavucontrol" + }, + + "disk": { + "interval": 5, + "format": " {percentage_used:2}%", + "path": "/" + + }, + "backlight": { + // "device": "acpi_video1", + "format": "{icon} {percent}% ", + "states": [0,50], + "format-icons": ["", ""], + "on-click": "termite -e swayphone_backlightselect" + }, + "tray": { + "icon-size": 22 + + //"spacing": 10 + }, + + + "custom/bar": { + "format": "", + "tooltip": false + } +} + diff --git a/home/config/waybar/style.css b/home/config/waybar/style.css index 22e8147..a960dc0 100755 --- 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: 12px; + font-size: 10px; font-weight: bold; } @@ -34,8 +34,37 @@ padding-right: 8px; margin-left: 2px; margin-right: 2px; + padding-top: 2px; + padding-bottom: 2px; } +#disk, +#backlight, +#battery, +#clock, +#cpu, +#custom-keyboard-layout, +#memory, +#mode, +#network, +#pulseaudio, +#custom-alsa, +#custom-kill, +#custom.kill, +#tray { + padding-top: 4px; + padding-bottom: 4px; + margin-top: 2px; + margin-bottom: 2px; +} + + +/*@media (width > 800px) { + #clock { + padding: 10px; + } +}*/ + /*modules style*/ #disk { background: #d79921; @@ -69,6 +98,7 @@ background: #eceff4; color: #282828; font-weight: bold; + font-size: 12px; } #cpu { diff --git a/usr/local/bin/swayphone_rotated b/usr/local/bin/swayphone_rotated new file mode 100755 index 0000000..e42d3a4 --- /dev/null +++ b/usr/local/bin/swayphone_rotated @@ -0,0 +1,35 @@ +#!/bin/bash + +function rotate +{ + kill -10 `pidof waybar` +} + +ROTFILE=/tmp/sway_rotation +PREV=-1 +if [[ -f $ROTFILE ]] +then + PREV=$(<$ROTFILE) +fi +TRANSFORM=`swaymsg -p -t get_outputs | grep -A 15 "Output DSI-1" | grep "Transform:"` +NOW=-1 + +if [[ $TRANSFORM == *"normal"* ]]; then + NOW=0 +elif [[ $TRANSFORM == *"90"* ]]; then + NOW=1 +elif [[ $TRANSFORM == *"180"* ]]; then + NOW=2 +elif [[ $TRANSFORM == *"270"* ]]; then + NOW=3 +fi + +echo $NOW > $ROTFILE + +if [[ $(($PREV % 2)) -eq $(($NOW % 2)) ]]; then + echo "No change." +else + echo Rotated from $PREV to $NOW. + rotate +fi +