ref: de26064caa7471927f6cfc66ba68eb4069850b33
parent: ae0e2de6efe0764b3c24e69c183dd2380c4fd1fa
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Mar 30 13:04:54 EDT 2020
toggle sticky mode with G-s
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@
* toggle fullscreen on the current window
* start a new window
* "sticky" programs, by default `stats`, `kbmap` etc are shown on every desktop
+ * toggle "sticky" mode for current window
All that with simple shortcuts.
@@ -39,6 +40,7 @@
```
G-f toggle fullscreen for the current window
+G-s toggle "sticky" mode for the current window
G-enter start a new window
G-[0..9] switch to a specific virtual desktop
G-shift-[0..9] move the current window to a specific virtual desktop
--- a/riow
+++ b/riow
@@ -23,21 +23,28 @@
cat $1/label
}
-fn fullscreen {- scrsize
+fn curwindow { for(f in /dev/wsys/*){ a=`{winread $f}- if(~ $a(5) current){- winid=`{basename $f}- if(~ $a(1) 0 && ~ $a(2) 0 && ~ $a(3) $screenw && ~ $a(4) $screenh){- if(test -f /env/winsize_^$winid)
- echo resize -r `{cat /env/winsize_^$winid} >$f/wctl- }
- if not {- echo -n $a(1 2 3 4) >/env/winsize_^$winid
- echo resize -r 0 0 9999 9999 >$f/wctl
- }
+ if(~ $a(5) current)
+ basename $f
+ }
+}
+
+fn togglefullscreen {+ winid=`{curwindow}+ if(! ~ $#winid 0){+ f=/dev/wsys/^$winid
+ a=`{winread $f}+ scrsize
+ if(~ $a(1) 0 && ~ $a(2) 0 && ~ $a(3) $screenw && ~ $a(4) $screenh){+ if(test -f /env/winsize_^$winid)
+ echo resize -r `{cat /env/winsize_^$winid} >$f/wctl}
+ if not {+ echo -n $a(1 2 3 4) >/env/winsize_^$winid
+ echo resize -r 0 0 9999 9999 >$f/wctl
+ }
}
}
@@ -44,18 +51,17 @@
fn desktop {# find and remember the current window
if(~ $shift 0){- for(f in /dev/wsys/*){- a=`{winread $f}- winid=`{basename $f}- if(~ $a(5) current)
- echo -n $winid >/env/windeskcur_^$curdesktop
- }
+ winid=`{curwindow}+ if(! ~ $#winid 0)
+ echo -n $winid >/env/windeskcur_^$curdesktop
+ if not
+ rm -f /env/windeskcur_^$curdesktop
}
for(f in /dev/wsys/*){- if(! ~ `{winlabel $f} $sticky){+ winid=`{basename $f}+ if(! ~ `{winlabel $f} $sticky && ! test -f /env/winsticky_^$winid){ a=`{winread $f}- winid=`{basename $f} if(~ $shift 1){ # moving the current window elsewhere if(~ $a(5) current){@@ -97,12 +103,17 @@
}
}
-fn handle {- # remember old states
- oalt=$alt
- octl=$ctl
- oshift=$shift
+fn togglesticky {+ winid=`{curwindow}+ if(! ~ $#winid 0){+ if(test -f /env/winsticky_^$winid)
+ rm -f /env/winsticky_^$winid
+ if not
+ touch /env/winsticky_^$winid
+ }
+}
+fn handle {m=$1
state=0
if(~ $1 k)
@@ -109,8 +120,13 @@
state=1
shift
- key=''
- ukey=''
+ key='' # depending on the shift state (1 → !)
+ ukey='' # stays the same regardless of the shift state
+
+ # K is key down
+ # k is key up
+ # c is key (and repeat) with the shift applied
+
if(~ $state K && ~ $#* 0){alt=0
ctl=0
@@ -133,7 +149,9 @@
if(~ $key enter)
window
if(~ $key f)
- fullscreen
+ togglefullscreen
+ if(~ $key s)
+ togglesticky
}
if(~ $ukey [0-9] && ! ~ $ukey $curdesktop)
desktop $ukey
--
⑨