<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Knowledge Base (Posts about appswitcher)</title><link>https://bgstack15.ddns.net/blog/</link><description></description><atom:link href="https://bgstack15.ddns.net/blog/categories/appswitcher.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2022 &lt;a href="mailto:bgstack15@gmail.com"&gt;bgstack15&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
style="border-width:0; margin-bottom:12px;"
src="https://bgstack15.ddns.net/.images/l_by-sa_4.0_88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Sun, 27 Feb 2022 04:05:31 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Cinnamon adds "Show all workspaces" setting to Alt-tab appSwitcher</title><link>https://bgstack15.ddns.net/blog/posts/2017/10/19/cinnamon-adds-show-all-workspaces-setting-to-alt-tab-appswitcher/</link><dc:creator>bgstack15</dc:creator><description>&lt;h2&gt;The story&lt;/h2&gt;
&lt;p&gt;I recently made a &lt;a href="https://github.com/linuxmint/Cinnamon/pull/6922"&gt;pull
request&lt;/a&gt; to Cinnamon to add
the "Show all workspaces" setting to the window list of the panel. To
complement this feature, I decided to add the feature to the alt-tab utility.
My journey began with trying to find the alt-tab code in the
&lt;a href="https://github.com/linuxmint/Cinnamon"&gt;Cinnamon&lt;/a&gt; project. It took me quite a
while, but eventually I found it in
&lt;a href="https://github.com/linuxmint/Cinnamon/blob/master/js/ui/appSwitcher/appSwitcher.js"&gt;appSwitcher.js&lt;/a&gt;.
At first I started tinkering with lines 36-39&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;function&lt;/span&gt; &lt;span class="nv"&gt;matchWorkspace&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;win&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; {
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;win&lt;/span&gt;.&lt;span class="nv"&gt;get_workspace&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;win&lt;/span&gt;.&lt;span class="nv"&gt;is_skip_taskbar&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But this proved to not be the right spot. Later on I realized this was not the
correct spot logically, but putting code here would work. It just wouldn't
make sense underneath the title "matchWorkspace." You shouldn't even get to
the matchWorkspace function if you're just showing all workspaces anyway. So
then I found this section of code&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;            &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Switch&lt;/span&gt; &lt;span class="nt"&gt;between&lt;/span&gt; &lt;span class="nt"&gt;windows&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;same&lt;/span&gt; &lt;span class="nt"&gt;application&lt;/span&gt; &lt;span class="nt"&gt;from&lt;/span&gt; &lt;span class="nt"&gt;all&lt;/span&gt; &lt;span class="nt"&gt;workspaces&lt;/span&gt;
            &lt;span class="nt"&gt;let&lt;/span&gt; &lt;span class="nt"&gt;focused&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;display&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;focus_window&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nt"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;display&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;focus_window&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;windows&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
            &lt;span class="nt"&gt;windows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;windows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;filter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nt"&gt;matchWmClass&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;focused&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;get_wm_class&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="nt"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="nt"&gt;default&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
            &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Switch&lt;/span&gt; &lt;span class="nt"&gt;between&lt;/span&gt; &lt;span class="nt"&gt;windows&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;current&lt;/span&gt; &lt;span class="nt"&gt;workspace&lt;/span&gt;
            &lt;span class="nt"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;_showAllWorkspaces&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;get_boolean&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"alttab-switcher-show-all-workspaces"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="nt"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!&lt;/span&gt;&lt;span class="nt"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;_showAllWorkspaces&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="err"&gt;windows&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="err"&gt;windows.filter(&lt;/span&gt; &lt;span class="err"&gt;matchWorkspace,&lt;/span&gt; &lt;span class="err"&gt;global.screen.get_active_workspace()&lt;/span&gt; &lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And that was what I wanted. The snippet above already includes my adjustment.
Line 73 is the logic that reads the gsettings schema. And it took me a while
to get this part to work. At first I had the read-schema code up beside the
other global.settings.get_boolean at line 112 in the
AppSwitcher.prototype._init: function(binding). But it took me a while to
figure out the scoping of the variable was not correct for my needs. Reading
the gsetting schema in the prototype did not set the variable for the function
at line 73, function getWindowsForBinding(binding). I also had to learn about
the gsettings schema. I've dabbled with &lt;a href="https://bgstack15.ddns.net/blog/posts/2017/10/04/dconf-save-and-load-from-file/"&gt;dconf
before&lt;/a&gt;. But apparently adding a new key is a little more complicated that just&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;dconf&lt;/span&gt; &lt;span class="nb"&gt;load&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;cinnamon&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;EOF&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;alttab&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;switcher&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;workspaces&lt;/span&gt; &lt;span class="bp"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I learned that for gsettings you have to modify the xml-defined schema. I
found it at
&lt;a href="https://github.com/linuxmint/Cinnamon/blob/master/data/org.cinnamon.gschema.xml.in"&gt;/usr/share/glib-2.0/schemas/org.cinnamon.gschema.xml&lt;/a&gt;.
My addition is pretty basic, at lines 541-545.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;key&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"alttab-switcher-show-all-workspaces"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;default&amp;gt;&lt;/span&gt;false&lt;span class="nt"&gt;&amp;lt;/default&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;_summary&amp;gt;&lt;/span&gt;Show all windows from all workspaces&lt;span class="c"&gt;&amp;lt;!--_summary--&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I also found file &lt;a href="https://github.com/linuxmint/Cinnamon/blob/master/files/usr/share/cinnamon/cinnamon-settings/modules/cs_windows.py"&gt;/usr/share/cinnamon/cinnamon-
settings/modules/cs_windows.py&lt;/a&gt; and added the widget for this setting.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;            &lt;span class="nv"&gt;widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;GSettingsSwitch&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;_&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Show windows from all workspaces&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;org.cinnamon&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;, &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;alttab-switcher-show-all-workspaces&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
            &lt;span class="nv"&gt;settings&lt;/span&gt;.&lt;span class="nv"&gt;add_row&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;widget&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So I made my changes and then restarted Cinnamon. Still no go. After a lot of
searching, I finally found the important part: I needed to run glib-compile-
schemas!&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pushd /usr/share/glib-2.0/schemas; glib-compile-schemas .; popd;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I finally had success! I submitted pull request
&lt;a href="https://github.com/linuxmint/Cinnamon/pull/6938"&gt;#6938&lt;/a&gt; and within a day my
changes were approved and merged.&lt;/p&gt;
&lt;h2&gt;The commit as a patch&lt;/h2&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gh"&gt;diff --git a/data/org.cinnamon.gschema.xml.in b/data/org.cinnamon.gschema.xml.in&lt;/span&gt;
&lt;span class="gh"&gt;index 71e09aca..17fe5dc4 100644&lt;/span&gt;
&lt;span class="gd"&gt;--- a/data/org.cinnamon.gschema.xml.in&lt;/span&gt;
&lt;span class="gi"&gt;+++ b/data/org.cinnamon.gschema.xml.in&lt;/span&gt;
&lt;span class="gu"&gt;@@ -538,6 +538,11 @@&lt;/span&gt;
       &amp;lt;_description&amp;gt;Duration of the effect (in milliseconds)&amp;lt;!--_description--&amp;gt;
     &amp;lt;/key&amp;gt;

&lt;span class="gi"&gt;+    &amp;lt;key type="b" name="alttab-switcher-show-all-workspaces"&amp;gt;&lt;/span&gt;
&lt;span class="gi"&gt;+      &amp;lt;default&amp;gt;false&amp;lt;/default&amp;gt;&lt;/span&gt;
&lt;span class="gi"&gt;+      &amp;lt;_summary&amp;gt;Show all windows from all workspaces&amp;lt;!--_summary--&amp;gt;&lt;/span&gt;
&lt;span class="gi"&gt;+    &amp;lt;/key&amp;gt;&lt;/span&gt;
&lt;span class="gi"&gt;+&lt;/span&gt;
     &amp;lt;key name="bring-windows-to-current-workspace" type="b"&amp;gt;
       &amp;lt;default&amp;gt;false&amp;lt;/default&amp;gt;
       &amp;lt;summary&amp;gt;Brings windows requiring attention to the current workspace&amp;lt;/summary&amp;gt;
&lt;span class="gh"&gt;diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_windows.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_windows.py&lt;/span&gt;
&lt;span class="gh"&gt;index 4875346e..080026ab 100755&lt;/span&gt;
&lt;span class="gd"&gt;--- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_windows.py&lt;/span&gt;
&lt;span class="gi"&gt;+++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_windows.py&lt;/span&gt;
&lt;span class="gu"&gt;@@ -129,6 +129,9 @@ class Module:&lt;/span&gt;
             widget = GSettingsSpinButton(_("Delay before displaying the alt-tab switcher"), "org.cinnamon", "alttab-switcher-delay", units=_("milliseconds"), mini=0, maxi=1000, step=50, page=150)
             settings.add_row(widget)

&lt;span class="gi"&gt;+            widget = GSettingsSwitch(_("Show windows from all workspaces"), "org.cinnamon", "alttab-switcher-show-all-workspaces")&lt;/span&gt;
&lt;span class="gi"&gt;+            settings.add_row(widget)&lt;/span&gt;
&lt;span class="gi"&gt;+&lt;/span&gt;
 class TitleBarButtonsOrderSelector(SettingsBox):
     def __init__(self):
         self.schema = "org.cinnamon.muffin"
&lt;span class="gh"&gt;diff --git a/js/ui/appSwitcher/appSwitcher.js b/js/ui/appSwitcher/appSwitcher.js&lt;/span&gt;
&lt;span class="gh"&gt;index f161350c..d36d3bf2 100644&lt;/span&gt;
&lt;span class="gd"&gt;--- a/js/ui/appSwitcher/appSwitcher.js&lt;/span&gt;
&lt;span class="gi"&gt;+++ b/js/ui/appSwitcher/appSwitcher.js&lt;/span&gt;
&lt;span class="gu"&gt;@@ -70,7 +70,10 @@ function getWindowsForBinding(binding) {&lt;/span&gt;
             break;
         default:
             // Switch between windows of current workspace
&lt;span class="gd"&gt;-            windows = windows.filter( matchWorkspace, global.screen.get_active_workspace() );&lt;/span&gt;
&lt;span class="gi"&gt;+            this._showAllWorkspaces = global.settings.get_boolean("alttab-switcher-show-all-workspaces");&lt;/span&gt;
&lt;span class="gi"&gt;+            if (!this._showAllWorkspaces) {&lt;/span&gt;
&lt;span class="gi"&gt;+                windows = windows.filter( matchWorkspace, global.screen.get_active_workspace() );&lt;/span&gt;
&lt;span class="gi"&gt;+            }&lt;/span&gt;
             break;
     }
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;References&lt;/h2&gt;
&lt;h3&gt;Weblinks&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Need to use glib-compile-schemas &lt;a href="https://developer.gnome.org/gio/stable/GSettings.html"&gt;https://developer.gnome.org/gio/stable/GSettings.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.gnome.org/GSettings/"&gt;https://developer.gnome.org/GSettings/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;</description><category>appswitcher</category><category>cinnamon</category><category>de</category><category>opensource</category><category>workspaces</category><guid>https://bgstack15.ddns.net/blog/posts/2017/10/19/cinnamon-adds-show-all-workspaces-setting-to-alt-tab-appswitcher/</guid><pubDate>Thu, 19 Oct 2017 12:33:56 GMT</pubDate></item></channel></rss>