Tuesday, April 30, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 4982  / 3 Years ago, tue, july 20, 2021, 2:26:34

I've created some shortcuts mimicking the Unity's Mod4 + num behavior.



wmctrl -xa Sublime || subl


What I don't like, is that once sublime is running, it always focuses the first opened window. I'd like to focus the last "focused" window. Same as in Unity. Is there a flag for that?


More From » window-management

 Answers
3

I've made a very robust app switcher using wmctrl. Check my Ubuntu Forums post and my askubuntu answer.



This is the script to launch:



#!/bin/bash
app_name=$1
workspace_number=`wmctrl -d | grep '*' | cut -d' ' -f 1`
win_list=`wmctrl -lx | grep $app_name | grep " $workspace_number " | awk '{print $1}'`


active_win_id=`xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}' | awk -F', ' '{print $1}'`
if [ "$active_win_id" == "0" ]; then
active_win_id=""
fi


# get next window to focus on, removing id active
switch_to=`echo $win_list | sed s/.*$active_win_id// | awk '{print $1}'`
# if the current window is the last in the list ... take the first one
if [ "$switch_to" == "" ];then
switch_to=`echo $win_list | awk '{print $1}'`
fi


if [[ -n "${switch_to}" ]]
then
(wmctrl -ia "$switch_to") &
else
if [[ -n "$2" ]]
then
($2) &
fi
fi


exit 0

[#32145] Wednesday, July 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
berlorful

Total Points: 346
Total Questions: 90
Total Answers: 99

Location: Monaco
Member since Tue, Nov 30, 2021
2 Years ago
berlorful questions
Thu, Sep 2, 21, 10:12, 3 Years ago
Sun, May 9, 21, 20:55, 3 Years ago
Mon, Jan 16, 23, 23:19, 1 Year ago
Mon, Aug 29, 22, 05:43, 2 Years ago
;