commit 59770b1cb2bfcc3016a500c0fe8cb01b83950d35
parent 13d9e0af8886d03317db67af02418e34d4d39bf2
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 21 Dec 2018 11:31:27 +0100
Add floating calculator and tmux session
Diffstat:
3 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/links/.config/i3/config b/links/.config/i3/config
@@ -15,12 +15,17 @@ font xft:PragmataPro 9
gaps inner $gaps_inner
gaps outer $gaps_outer
-# floating tmux session, later bound to mod+u.
-# for_window [instance="tmuxdd"] floating enable
-# for_window [instance="tmuxdd"] resize set 625 450
-# for_window [instance="tmuxdd"] move scratchpad
-# for_window [instance="tmuxdd"] border pixel 3
-# for_window [instance="tmuxdd"] sticky enable
+# floating windows
+for_window [instance="tmuxdd"] floating enable
+for_window [instance="tmuxdd"] resize set 625 450
+for_window [instance="tmuxdd"] move scratchpad
+for_window [instance="tmuxdd"] border pixel 3
+for_window [instance="tmuxdd"] sticky enable
+for_window [instance="dropdowncalc"] floating enable
+for_window [instance="dropdowncalc"] resize set 625 450
+for_window [instance="dropdowncalc"] move scratchpad
+for_window [instance="dropdowncalc"] border pixel 2
+for_window [instance="dropdowncalc"] sticky enable
# Set Xresources colors:
set_from_resource $darkblack color0 #000000
@@ -68,7 +73,6 @@ bindsym $mod+b exec $term -e ~/bin/board
bindsym $mod+comma exec signal-desktop
bindsym $mod+w exec firefox
bindsym $mod+Shift+w exec tor-browser
-bindsym $mod+p exec zathura
bindsym Mod1+Mod4+l exec --no-startup-id ~/bin/keyboard-layout-switch.sh && pkill -RTMIN+3 i3blocks
bindsym $mod+n exec $term -e ranger
@@ -84,6 +88,9 @@ bindsym $mod+u exec --no-startup-id dmenuunicode
bindsym $mod+F9 exec --no-startup-id dmenumount
bindsym $mod+F10 exec --no-startup-id dmenuumount
+bindsym $mod+grave exec --no-startup-id ~/bin/ddspawn ~/bin/tmuxdd
+bindsym $mod+p exec --no-startup-id ~/bin/ddspawn ~/bin/dropdowncalc
+
# keyboard backlight
bindsym XF86KbdBrightnessDown exec --no-startup-id /home/ad/bin/kbd_backlight.sh down
bindsym XF86KbdBrightnessUp exec --no-startup-id /home/ad/bin/kbd_backlight.sh up
@@ -189,7 +196,6 @@ bindsym $mod+z gaps outer current plus 5
bindsym $mod+Shift+z gaps outer current minus 5
bindsym $mod+Shift+t gaps inner current set $gaps_inner; gaps outer current set $gaps_outer
-#bindsym $mod+u exec --no-startup-id ddspawn tmuxdd
bindsym $mod+o sticky toggle
# resize window (you can also use the mouse for that)
diff --git a/links/bin/ddspawn b/links/bin/ddspawn
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# This script simplifies dropdown windows in i3.
+# Shows/hides a scratchpad of a given name, if it doesn't exist, creates it.
+# Usage:
+# argument 1: script to run in dropdown window
+# all other args are interpreted as options for your terminal
+# My usage:
+# ddpawn
+# bindsym $mod+u exec --no-startup-id ddspawn tmuxdd
+# Will hide/show window running the `tmuxdd` script when I press mod+u in i3
+# bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24
+# Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font)
+
+[ -z "$1" ] && exit
+
+if xwininfo -tree -root | grep "(\"$1\" ";
+then
+ echo "Window detected."
+else
+ echo "Window not detected... spawning."
+ i3 "exec --no-startup-id st -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center"
+ sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn).
+fi
+i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center"
diff --git a/links/bin/dropdowncalc b/links/bin/dropdowncalc
@@ -0,0 +1,2 @@
+#!/bin/sh
+([ -x /usr/bin/julia ] && julia) || ([ -x /usr/bin/ipython ] && ipython) || python -q