Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.advocacy > #402772

Re: window grouping updates

From Snit <usenet@gallopinginsanity.com>
Newsgroups comp.os.linux.advocacy
Subject Re: window grouping updates
Date 2017-03-23 00:32 -0700
Message-ID <D4F8C803.96E2B%usenet@gallopinginsanity.com> (permalink)
References <hjxib03.abue@rooftop.invalid> <D4F8A61D.96E06%usenet@gallopinginsanity.com> <ac93.g9pl2@rooftop.invalid>

Show all headers | View raw


On 3/23/17, 12:21 AM, in article ac93.g9pl2@rooftop.invalid, "owl"
<owl@rooftop.invalid> wrote:

> Snit <usenet@gallopinginsanity.com> wrote:
>> On 3/22/17, 9:54 PM, in article hjxib03.abue@rooftop.invalid, "owl"
>> <owl@rooftop.invalid> wrote:
>> 
>>> Made some improvements to the window grouping utility:
>>> 
>>> - add/remove windows
>>> - reposition windows
>>> - gui control 
>>> 
>>> https://vid.me/4sEt
>>> 
>> 
>> That is freaking cool... and the buttons do exactly what I would expect (I
>> was wondering if you were going to demo the "pause" -- did just what one
>> would expect it to do).
>> 
>> I see you can minimize them all... can you bring them all to the front, too?
>> I assume even if not you could add a button or whatever to address them all
>> and have then do so.
>> 
>> Overall just awesome... and far more "complete" than I expected to see.
>> Thanks! 
>> 
>> Do you mind sharing the code behind it?
>> 
> 
> I added a button to raise the windows.

Even knowing nothing of how this is done I guessed that would not be too
hard.

> The code is below.
> There are two scripts, leader and linkem.  leader calls linkem.
> In leader, set the LINKEM variable to whatever.
> 
> Need the following dependencies:
> X11, bash, tcl/tk, wish, xdotool, xwininfo.  (I think that's about it).
> 
> It uses a tempfile in /tmp and cleans up after itself.  Hitting the "Stop"
> button exits cleanly, but if you just close the window instead, there will
> probably be a "linkem" process hanging around that you'll need to kill,
> as well as a /tmp/windowlist0xNNNNNNN text file.  This linkem process
> will also keep the windows stuck together as a group until it is killed.

You mean the tool you made based on a whim of mine is not perfect. You suck!

No, seriously, this is amazingly cool... curious if it also works with
windows from other programs? From what (very) little I know of X I would
assume so... but if not it is still really cool. Thanks for putting it
together and sharing.

> 
> ++++++++++++++++ begin leader ++++++++++++++++
> #!/usr/bin/wish
> 
> set LINKEM /home/anon/code/groups/linkem
> 
> proc addwindow {} {
>  set wid [winfo id .]
>  global LINKEM
>  exec $LINKEM -a $wid &
> }
> 
> proc removewindow {} {
>  set wid [winfo id .]
>  global LINKEM
>  exec $LINKEM -r $wid &
> }
> 
> proc run {} {
>  set wid [winfo id .]
>  global LINKEM
>  set channel [ open "|$LINKEM -l $wid" ]
>  global PID
>  set PID [pid $channel]
> }
> 
> proc pause {} {
>  global PID
>  exec kill -9 $PID
> }
> 
> proc stop {} {
>  set wid [winfo id .]
>   global PID
>   exec rm /tmp/windowlist$wid
>   exec kill -9 $PID
>   exit
> }
> 
> proc raisewindows {} {
>  set wid [winfo id .]
>  global LINKEM
>  exec $LINKEM -u $wid &
> }
> 
> proc screen {} {
>  frame .top -borderwidth 10
>  pack .top -fill x
>  button .top.addwindow -text "Add Window" -command {
>   addwindow
>   .top.run config -state normal
>   .top.removewindow config -state normal
>  }
>  pack .top.addwindow -side left
>  button .top.run -text "Run" -state disabled -command {
>    run 
>    .top.run config -state disabled
>    .top.addwindow config -state disabled
>    .top.removewindow config -state disabled
>    .top.stop config -state normal
>    .top.pause config -state normal
>    .top.raisewindows config -state normal
>    }
>  pack .top.run -side left
>  button .top.pause -text "Pause" -state disabled -command {
>   pause
>   .top.run config -state normal
>   .top.addwindow config -state normal
>   .top.removewindow config -state normal
>   .top.stop config -state normal
>   .top.raisewindows config -state normal
>   }
>  pack .top.pause -side left
>  button .top.stop -text "Stop" -state disabled -command stop
>  pack .top.stop -side left
>  button .top.removewindow -text "Remove Window" -state disabled -command {
>  removewindow 
>  .top.run config -state normal
>  }
>  pack .top.removewindow -side left
>  button .top.raisewindows -text "raisewindows" -state disabled -command {
>  raisewindows
>  }
>  pack .top.raisewindows -side left
>  
> }
> 
> screen 
> 
> ++++++++++++++++ end leader ++++++++++++++++
> 
> ++++++++++++++++ begin linkem ++++++++++++++++
> #!/bin/bash
> declare -a followerids
> declare -a followersx
> declare -a followersy
> declare -a followersxsoffset
> declare -a followersysoffset
> # states: IsViewable, IsUnMapped
> 
> addwindow () {
> touch /tmp/windowlist${1}
> windowid=$(xwininfo |grep 'Window id:' |cut -f3 -d: |awk '{print $1}')
> echo ${windowid} >> /tmp/windowlist${1}
> }
> 
> removewindow () {
> echo "in removewindow"
> touch /tmp/windowlist${1}
> windowid=$(xwininfo |grep 'Window id:' |cut -f3 -d: |awk '{print $1}')
> sed -i "s/${windowid}//g" /tmp/windowlist${1}
> }
> 
> linkem () {
> leaderid=${1}
> 
> laulx=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left X" \
> |awk '{print $4}')
> lauly=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left Y" \
> |awk '{print $4}')
> 
> followerids+=($(cat /tmp/windowlist${1} |sort |uniq))
> 
> xdotool windowraise ${leaderid}
> 
> for (( i=0;i<${#followerids[@]};i++ ));do
>   followersx[${i}]=$(xwininfo -id "${followerids[${i}]}" \
> |grep "Absolute upper-left X" |awk '{print $4}')
>   followersy[${i}]=$(xwininfo -id "${followerids[${i}]}" \
> |grep "Absolute upper-left Y" |awk '{print $4}')
> done
> 
> for (( i=0;i<${#followerids[@]};i++ ));do
>   followersxoffset[${i}]=$(( ${laulx}-${followersx[${i}]} ))
>   followersyoffset[${i}]=$(( ${lauly}-${followersy[${i}]} ))
> done
> 
> while [ 1 ]; do
> 
> laulx=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left X" \
> |awk '{print $4}')
> 
> lauly=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left Y" \
> |awk '{print $4}')
> 
> xdotool windowraise ${leaderid}
> 
> for (( i=0;i<${#followerids[@]};i++ ));do
> xdotool windowmove ${followerids[${i}]} \
> $((${laulx}-${followersxoffset[${i}]})) \
> $((${lauly}-${followersyoffset[${i}]}))
> done
> 
>    leaderstate=$(xwininfo -id ${leaderid} |grep "Map State:" \
> |awk '{print $3}')
>    
>    if [ "${leaderstate}" = "IsViewable" ];then
>       for (( i=0;i<${#followerids[@]};i++ ));do
>          xdotool windowmap ${followerids[${i}]}
>       done
>    elif [ "${leaderstate}" = "IsUnMapped" ];then
>       for (( i=0;i<${#followerids[@]};i++ ));do
>          xdotool windowminimize ${followerids[${i}]}
>       done
>    fi
> 
> done
> }
> 
> raisem () {
> leaderid=${1}
> 
> laulx=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left X" \
> |awk '{print $4}')
> lauly=$(xwininfo -id "${leaderid}" |grep "Absolute upper-left Y" \
> |awk '{print $4}')
> 
> followerids+=($(cat /tmp/windowlist${1} |sort |uniq))
> 
> xdotool windowraise ${leaderid}
> for (( i=0;i<${#followerids[@]};i++ ));do
>   xdotool click --window ${followerids[${i}]} 1
> done
> 
> }
> 
> touch /tmp/windowlist${2}
> case ${1} in 
>    -a)
>       addwindow ${2}
>       exit
>     ;;
>    -r)
>       removewindow ${2}
>       exit
>     ;;
>    -l)
>       linkem ${2}
>       exit
>     ;;
>    -u)
>       raisem ${2}
>       exit
>     ;;
>     *)
>       exit
>     ;; 
> esac
> 
> ++++++++++++++++ end linkem ++++++++++++++++


-- 
Personal attacks from those who troll show their own insecurity. They cannot
use reason to show the message to be wrong so they try to feel somehow
superior by attacking the messenger.

They cling to their attacks and ignore the message time and time again.

Back to comp.os.linux.advocacy | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

window grouping updates owl <owl@rooftop.invalid> - 2017-03-23 04:54 +0000
  Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-22 22:07 -0700
    Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-23 07:21 +0000
      Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-23 00:32 -0700
        Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-23 07:41 +0000
        Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-24 14:58 +0000
          Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-24 10:48 -0500
            Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-24 18:40 +0000
              Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-24 11:55 -0700
              Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-24 14:07 -0500
          Re: window grouping updates Snit <usenet@gallopinginsanity.com> - 2017-03-24 10:38 -0700
  Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-23 02:11 -0500
    Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-23 07:26 +0000
  Re: window grouping updates DFS <nospam@dfs.com> - 2017-03-23 09:04 -0400
    Re: window grouping updates Steve Carroll <fretwizzer@gmail.com> - 2017-03-23 08:50 -0700
      Re: window grouping updates Marek Novotny <marek.novotny@marspolar.com> - 2017-03-23 11:05 -0500
        Re: window grouping updates Steve Carroll <fretwizzer@gmail.com> - 2017-03-23 09:22 -0700
    Re: window grouping updates owl <owl@rooftop.invalid> - 2017-03-23 16:06 +0000

csiph-web