From 59784525c0b55742c61f4e960e1427b295c4bb6b Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 8 Apr 2022 15:47:38 +0200 Subject: [PATCH] feat: some cleanup --- configs/sway/config | 17 +++++++++++++---- configs/sway/create_floating.sh | 18 ++++++++++++++++++ configs/sway/debug_window.sh | 15 ++++++++------- configs/sway/toggle_bar.sh | 8 +++++--- configs/sway/toggle_layout.sh | 12 +++++++++--- configs/waybar/config | 4 ++++ configs/waybar/cpu_speed.sh | 2 ++ configs/waybar/style.css | 3 ++- configs/wofi/config | 2 +- 9 files changed, 62 insertions(+), 19 deletions(-) create mode 100644 configs/sway/create_floating.sh diff --git a/configs/sway/config b/configs/sway/config index 29447dc..94a18e7 100644 --- a/configs/sway/config +++ b/configs/sway/config @@ -34,8 +34,8 @@ set $windowshot wl-copy < "$($grimshot --notify save window $screenshot_dir/scrn set $term kitty -e "tmux" set $explorer nautilus set $mail geary -set $browser google-chrome-beta --enable-features=UseOzonePlatform --ozone-platform=wayland set $browser firefox-developer-edition +set $browser google-chrome-beta --enable-features=UseOzonePlatform --ozone-platform=wayland set $password_mngr rofi-rbw --selector wofi --typer wtype --clipboarder wl-copy set $bluetooth_mngr blueman-manager set $calculator flatpak run io.github.Qalculate @@ -46,6 +46,7 @@ set $config_editor ~/.config/sway/config_editor.sh set $debug_window ~/.config/sway/debug_window.sh set $settings gnome-control-center set $toggle_layout ~/.config/sway/toggle_layout.sh +set $create_floating ~/.config/sway/create_floating.sh set $toggle_gaps ~/.config/sway/toggle_gaps.sh set $toggle_bar ~/.config/sway/toggle_bar.sh set $web_search $wofi_scripts/web-search.sh @@ -114,6 +115,7 @@ input "1739:24385:Synaptics_TM2438-005" { bindsym $mod+q kill bindsym $mod+Shift+q exec $wofi_scripts/wofi-power-menu.sh bindsym $mod+Return exec $term + bindsym $mod+Shift+Return exec $create_floating $term bindsym $mod+e exec $explorer bindsym $mod+Comma exec $settings bindsym $mod+b exec $browser @@ -138,8 +140,8 @@ input "1739:24385:Synaptics_TM2438-005" { bindsym --locked XF86AudioRaiseVolume exec "pactl -- set-sink-volume @DEFAULT_SINK@ +10%" #Increase brightness - bindsym XF86MonBrightnessUp exec brightnessctl -d intel_backlight set +10 - bindsym XF86MonBrightnessDown exec brightnessctl -d intel_backlight set 10- + bindsym XF86MonBrightnessUp exec brightnessctl -d intel_backlight set +20 + bindsym XF86MonBrightnessDown exec brightnessctl -d intel_backlight set 20- # Exit sway (logs you out of your Wayland session) bindsym $mod+Shift+e exec swaynag -t warning -m 'Do you really want to exit your Wayland session?' -B 'Yes, exit sway' 'swaymsg exit' @@ -177,11 +179,14 @@ input "1739:24385:Synaptics_TM2438-005" { for_window [app_id="qalculate-gtk"] floating enable for_window [title="Zoom Meeting.*"] floating disable for_window [title="Zoom Meeting.*"] inhibit_idle visible + for_window [app_id="firefox" title="^Picture-in-Picture$"] floating enable, move position 1300 600, sticky enable, resize set 600 450 + set $ws1 "1:  Code" assign [app_id="Alacritty"] $ws1 + assign [app_id="Kitty"] $ws1 set $ws2 "2:  Browser" - assign [class="Firefox"] $ws2 + assign [class="^Firefox"] $ws2 assign [class="Chromium"] $ws2 assign [class="Google-chrome-beta"] $ws2 assign [app_id="google-chrome-beta"] $ws2 @@ -312,6 +317,7 @@ exec_always mako # exec_always pulseaudio --start # Handle Authentiction requests exec_always lxpolkit +exec_always clipman # Dimms the screen exec_always wlsunset -l 39.47 -L -0.3821346 exec wl-paste -t text --watch clipman store --no-persist @@ -322,7 +328,10 @@ exec wl-paste -t text --watch clipman store --no-persist # Read `man 5 sway-bar` for more information about this section. bar { swaybar_command waybar + mode dock + position top } + include @sysconfdir@/sway/config.d/* exec "systemctl --user import-environment SWAYSOCK XDG_CURRENT_DESKTOP WAYLAND_DISPLAY"; diff --git a/configs/sway/create_floating.sh b/configs/sway/create_floating.sh new file mode 100644 index 0000000..f105e0c --- /dev/null +++ b/configs/sway/create_floating.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +$@ & +pid=$! + +swaymsg -t subscribe -m '[ "window" ]' \ + | jq --unbuffered --argjson pid "$pid" '.container | select(.pid == $pid) | .id' \ + | xargs -I '@' -- swaymsg '[ con_id=@ ] floating enable' & + +subscription=$! + +echo Going into wait state + +# Wait for our process to close +tail --pid=$pid -f /dev/null + +echo Killing subscription +kill $subscription diff --git a/configs/sway/debug_window.sh b/configs/sway/debug_window.sh index c75d2a7..b6282ce 100755 --- a/configs/sway/debug_window.sh +++ b/configs/sway/debug_window.sh @@ -5,12 +5,11 @@ WINDOW_NAME='(.app_id // .window_properties.class)' ID_PREFIX='"\(.pid):"' WINDOW_PROTOCOL='(if .shell == "xwayland" then "X11" else "wayland" end)' WINDOW_GEOMETRY='(.rect | "\(.x),\(.y) \(.width)x\(.height) ")' -WINDOW_PID='(.pid | tostring)' -CLEAR_OBJ="del(.rect, .name, .focus, .border, .current_border_width, .window_rect, .orientation, .layout, .percent, .deco_rect, .geometry, .window, .urgent, .marks, .sticky, .type, .fullscreen_mode, .nodes, .floating_nodes, .shell, .max_render_time, .visible, .idle_inhibitors, .inhibit_idle)" +WINDOW_PID='(.id | tostring)' +CLEAR_OBJ="del(.focus, .border, .current_border_width, .window_rect, .orientation, .layout, .percent, .deco_rect, .geometry, .window, .urgent, .marks, .sticky, .fullscreen_mode, .nodes, .floating_nodes, .shell, .max_render_time, .visible, .idle_inhibitors, .inhibit_idle)" # Output format, e.g. "1234 - 12:firefox (wayland)" or "5678 - 17:discord (X11)" -FORMAT="$WINDOW_PID" -FILT="$ALL_NODES | $WINDOW_GEOMETRY + $FORMAT" +FILT="$ALL_NODES | $WINDOW_GEOMETRY + $WINDOW_PID" function getprop() { typeset -A views @@ -24,9 +23,11 @@ function getprop() { selected="$(printf "%s\n" "${!views[@]}" | slurp)" if [[ -n "$selected" ]]; then window_id=${views[${selected}]}; - SELECT_ID=$(echo ".. | (.nodes? // empty)[] | select(.pid == $window_id) | $CLEAR_OBJ ") - echo $SELECT_ID - notify "Debug:" "$(swaymsg -t get_tree | jq -r "$SELECT_ID")"; + echo "SelectedId $window_id" + SELECT_ID=$(echo ".. | (.nodes? // empty)[] | select(.id == $window_id) | $CLEAR_OBJ ") + selected="$(swaymsg -t get_tree | jq -r "$ALL_NODES" | jq -c ". | select(.id==$window_id)" | jq)" + echo "Selected: $selected" + notify-send "Debug:" "$(echo $selected | jq -c "$CLEAR_OBJ" | jq)"; fi } diff --git a/configs/sway/toggle_bar.sh b/configs/sway/toggle_bar.sh index 34dadf0..2536181 100755 --- a/configs/sway/toggle_bar.sh +++ b/configs/sway/toggle_bar.sh @@ -5,12 +5,14 @@ GAPS=3 # How to get the current inner border from swaymsg #$ echo $(swaymsg -t get_config | jq ".config") | sed -n '/gaps\ inner/p' | sed 's/gaps\ inner//g' | xargs -if [ "$(pgrep waybar)" != "" ]; then - killall waybar; +bar_mode="$(swaymsg -t get_bar_config bar-0 | jq '.mode')" + +if [ "$bar_mode" != "dock" ]; then + swaymsg bar mode hide bar-0 swaymsg gaps outer all set 0; swaymsg gaps inner all set 0; else + swaymsg bar mode dock bar-0 swaymsg gaps outer all set $GAPS; swaymsg gaps inner all set $GAPS; - nohup waybar & 2&> /dev/null; fi diff --git a/configs/sway/toggle_layout.sh b/configs/sway/toggle_layout.sh index 54923dc..57a26d2 100755 --- a/configs/sway/toggle_layout.sh +++ b/configs/sway/toggle_layout.sh @@ -2,8 +2,10 @@ WORKSPACE=$(swaymsg -t get_workspaces --raw | jq '.[] | select(.focused == true)') + WORKSPACE_ID=$(echo $WORKSPACE | jq ".name" | tr -d '"') -WORKSPACE_MODE=$(echo $WORKSPACE | jq ".layout"); +WORKSPACE_MODE=$(swaymsg -t get_tree | jq 'recurse(.nodes[]) | select(.nodes[].focused == true).layout'); +echo "WORKSPACE: $WORKSPACE_MODE" MODE_SPLITH='"splith"' MODE_SPLITV='"splitv"' @@ -18,8 +20,12 @@ if [ $WORKSPACE_MODE = $MODE_SPLITH ]; then set_layout splitv elif [ $WORKSPACE_MODE = $MODE_SPLITV ]; then set_layout tabbed +# elif [ $WORKSPACE_MODE = $MODE_TABBED ]; then +# set_layout stacking elif [ $WORKSPACE_MODE = $MODE_TABBED ]; then - set_layout stacking -elif [ $WORKSPACE_MODE = $MODE_STACKED ]; then set_layout splith fi + +if [ "$1" != "" ]; then + set_layout $1 +fi diff --git a/configs/waybar/config b/configs/waybar/config index 37081b8..a3992b1 100644 --- a/configs/waybar/config +++ b/configs/waybar/config @@ -1,6 +1,10 @@ { "height": 20, "spacing": 4, + "bar_id":"bar-0", + "ipc": true, + "mode": "hide", + "hidden_state": "show", "modules-left": ["custom/clock", "custom/waybar-mpris"], "modules-center": ["sway/workspaces", "sway/mode"], "modules-right": ["pulseaudio", "network", "custom/cpu_speed", "memory", "battery"], diff --git a/configs/waybar/cpu_speed.sh b/configs/waybar/cpu_speed.sh index 9dec0b8..f22dda0 100755 --- a/configs/waybar/cpu_speed.sh +++ b/configs/waybar/cpu_speed.sh @@ -3,6 +3,8 @@ class=cpu_speed speed_mhz=$(lscpu | grep "CPU MHz" | sed --expression "s/CPU MHz:[[:space:]]*//g" | xargs printf "%.*f\n" 0) + + # speed_ghz=`echo $(($speed_mhz / 1000))` speed_ghz=`bc -l <<< "$speed_mhz / 1000"` diff --git a/configs/waybar/style.css b/configs/waybar/style.css index faa2c44..0f64a24 100644 --- a/configs/waybar/style.css +++ b/configs/waybar/style.css @@ -1,6 +1,7 @@ * { border: none; - font-family: Font Awesome, Hack Nerd Font; + font-family: Font Awesome, Hack Nerd Font Mono; + font-weight: 600; font-size: 13px; /* opacity: 0.95; */ } diff --git a/configs/wofi/config b/configs/wofi/config index c8f55da..23c0d90 100644 --- a/configs/wofi/config +++ b/configs/wofi/config @@ -2,5 +2,5 @@ allow_images=true allow_markup=true width=500 dynamic_lines=true -term=allacritty +term=kitty insensitive=true