From 30ed143583d5dda79e0793a426f09bc90c0524a8 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 28 Apr 2019 04:00:24 +0200 Subject: [PATCH] Add window hover script, sticky floating window i3 keybind --- .config/i3/config | 3 +++ .scripts/wm/hover.sh | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 .scripts/wm/hover.sh diff --git a/.config/i3/config b/.config/i3/config index 6dc6cfa..0161e89 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -112,6 +112,9 @@ bindsym $mod+Shift+e exec --no-startup-id prompt.sh "Logout and exit i3?" "i3-ms bindsym $mod+Shift+s exec --no-startup-id prompt.sh "Shutdown computer?" "poweroff" bindsym $mod+Shift+w exec --no-startup-id prompt.sh "Reboot computer?" "reboot" +# Sticky floating window +bindsym $mod+Shift+f fullscreen disable, floating enable, sticky enable; exec --no-startup-id $HOME/.scripts/wm/hover.sh + #--- Workspace bindings ---# set $ws1 "1 " diff --git a/.scripts/wm/hover.sh b/.scripts/wm/hover.sh new file mode 100755 index 0000000..0503b76 --- /dev/null +++ b/.scripts/wm/hover.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Enable mathematics in POSIX shell +calc() { awk "BEGIN{print $*}"; } + +# Calculate size +MON_WIDTH=$(xdotool getdisplaygeometry | awk '{print $1}') +MON_HEIGHT=$(xdotool getdisplaygeometry | awk '{print $2}') +NEW_WIDTH=$(calc "$MON_WIDTH * 0.25") +NEW_HEIGHT=$(calc "$NEW_WIDTH / 16 * 9") + +# Calculate position +BORDER=23 +X=$(calc "$MON_WIDTH - $NEW_WIDTH - $BORDER") +Y=$(calc "$MON_HEIGHT - $NEW_HEIGHT - $BORDER") + +# Set window +CURRENT=$(xdotool getwindowfocus) +xdotool windowsize "$CURRENT" "$NEW_WIDTH" "$NEW_HEIGHT" +xdotool windowmove "$CURRENT" "$X" "$Y"