From 1c225e141d55eb2cae32acd4f73445e5fad47b4e Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 8 Apr 2022 17:37:26 +0200 Subject: [PATCH] feat: some stuff --- configs/sway/config | 3 +++ configs/sway/create_floating.sh | 12 +++++++++++- configs/sway/debug_window.sh | 2 +- configs/waybar/config | 1 + configs/zsh/functions.zsh | 1 + configs/zsh/functions/mv-safe.zsh | 11 +++++++++++ 6 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 configs/zsh/functions/mv-safe.zsh diff --git a/configs/sway/config b/configs/sway/config index 94a18e7..43dbcc8 100644 --- a/configs/sway/config +++ b/configs/sway/config @@ -40,6 +40,7 @@ set $password_mngr rofi-rbw --selector wofi --typer wtype --clipboarder wl-copy set $bluetooth_mngr blueman-manager set $calculator flatpak run io.github.Qalculate set $photo_editor gtk-launch ~/.local/share/applications/photopea.desktop +set $translator com.github.gi_lom.dialect # Scripts set $config_editor ~/.config/sway/config_editor.sh @@ -112,6 +113,7 @@ input "1739:24385:Synaptics_TM2438-005" { # Basics: # bindsym $mod+d exec $quickmenu + bindsym $mod+t exec $translator bindsym $mod+q kill bindsym $mod+Shift+q exec $wofi_scripts/wofi-power-menu.sh bindsym $mod+Return exec $term @@ -175,6 +177,7 @@ input "1739:24385:Synaptics_TM2438-005" { # Workspaces: # for_window [class="zoom"] floating enable + for_window [app_id="com.github.gi_lom.dialect"] floating enable, resize set 800 400, sticky enable for_window [app_id="gnome-calculator"] floating enable for_window [app_id="qalculate-gtk"] floating enable for_window [title="Zoom Meeting.*"] floating disable diff --git a/configs/sway/create_floating.sh b/configs/sway/create_floating.sh index 605e79b..02c0cd6 100755 --- a/configs/sway/create_floating.sh +++ b/configs/sway/create_floating.sh @@ -3,9 +3,19 @@ $@ & pid=$! + +# ALL_NODES='recurse(.nodes[]?, .floating_nodes[]?) | select(.pid and .visible)' + +# echo "pid: $pid" +# all_nodes="$(swaymsg -t get_tree | jq -r "$ALL_NODES")" +# window_id="$(swaymsg -t get_tree | jq -r "$ALL_NODES" | jq -c ". | select(.pid==$pid) | .id")" + +# echo "al: $all_nodes" +# echo "window_id: $window_id" + swaymsg -t subscribe -m '[ "window" ]' \ | jq --unbuffered --argjson pid "$pid" '.container | select(.pid == $pid) | .id' \ - | xargs -I '@' -- swaymsg '[ con_id=@ ] floating enable, resize set 600 450' & + | xargs -I '@' -- swaymsg '[ con_id=@ ] floating enable' & subscription=$! diff --git a/configs/sway/debug_window.sh b/configs/sway/debug_window.sh index b6282ce..3f1c06f 100755 --- a/configs/sway/debug_window.sh +++ b/configs/sway/debug_window.sh @@ -6,7 +6,7 @@ ID_PREFIX='"\(.pid):"' WINDOW_PROTOCOL='(if .shell == "xwayland" then "X11" else "wayland" end)' WINDOW_GEOMETRY='(.rect | "\(.x),\(.y) \(.width)x\(.height) ")' 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)" +CLEAR_OBJ="del(.focus, .pid, .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)" FILT="$ALL_NODES | $WINDOW_GEOMETRY + $WINDOW_PID" diff --git a/configs/waybar/config b/configs/waybar/config index a3992b1..0178a72 100644 --- a/configs/waybar/config +++ b/configs/waybar/config @@ -158,6 +158,7 @@ "on-click": "kitty -e htop" }, "custom/waybar-mpris": { + "max-length": 30, "return-type": "json", "exec": "waybar-mpris --position --autofocus", "on-click": "waybar-mpris --send toggle", diff --git a/configs/zsh/functions.zsh b/configs/zsh/functions.zsh index 3598261..f2d0262 100644 --- a/configs/zsh/functions.zsh +++ b/configs/zsh/functions.zsh @@ -11,3 +11,4 @@ source $(dirname "$0")/functions/cht.zsh; source $(dirname "$0")/functions/run.zsh; source $(dirname "$0")/functions/conf.zsh; source $(dirname "$0")/functions/note.zsh; +source $(dirname "$0")/functions/mv-safe.zsh; diff --git a/configs/zsh/functions/mv-safe.zsh b/configs/zsh/functions/mv-safe.zsh new file mode 100644 index 0000000..b332cd1 --- /dev/null +++ b/configs/zsh/functions/mv-safe.zsh @@ -0,0 +1,11 @@ +function mv-safe(){ + for OLD_NAME in "$@" + do + NEW_NAME="$(echo $OLD_NAME | sed -e 'y/āáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛ/aaaaeeeeiiiioooouuuuüüüüAAAAEEEEIIIIOOOOUUUUÜÜÜÜ/' | sed -e 's/[^A-Za-z0-9._-]/_/g')" + if [ $OLD_NAME != $NEW_NAME ]; then + mv $OLD_NAME $NEW_NAME; + else + echo "No need to rename $OLD_NAME"; + fi + done +}