tag:blogger.com,1999:blog-7136026038949208742024-03-12T22:32:10.316-07:00Tech Stuff and Noteson software development, computing science, software technologies, learning, etc.bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.comBlogger234125tag:blogger.com,1999:blog-713602603894920874.post-85988816751633029362022-05-09T08:00:00.001-07:002022-05-09T08:00:00.159-07:00Trampolines - fun way to make recursion not stack overflow<p>(We'll use JavaScript for today, running in the Firefox developer console.) <br /></p><p>No doubt when you learned recursion, you learned that each recursive function call uses stack space to do its work. There's only so much stack space. So unless your programming language has a special feature (called tail call elimination), a recursive function can eventually exhaust all stack space, leading to the famous stack overflow error (not the web site). </p><p>For example, let's write a loop to sum up numbers from 0 up to some <i>N</i> like this:</p><p></p><pre><code>let sum = 0;
for (let i = 0; i < 10000; ++i) sum += i;
console.log(sum); // prints: 49995000</code></pre><p>Now a recursive version might look like this:</p><pre><code>const loop = function(i, sum){
if (i < 10000){
sum += i;
return loop(i + 1, sum);
} else {
return sum;
}
};
console.log(loop(0, 0)); // prints: 49995000</code></pre><p>As you can see, a loop is just a recursive function call.</p><p>The above is a nice, simple demo of converting a loop to recursion. But if instead of summing up to 10,000, we sum up to 100,000, then the loop prints 4999950000. But the recursive function prints:</p><p></p><blockquote><code>Uncaught InternalError: too much recursion</code><br /></blockquote><p></p><p>With a link to: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion</a> </p><p><b>Trampolines</b></p><p>No surprise, like the title says, trampolines can fix this!</p><p>The key is to not allow the <i>loop</i> function to run <i>loop(i + 1, sum)</i>, because that'd consume stack space! Instead, the <i>loop</i> function will <i>return</i> a function called a <i>thunk</i>. That thunk function, when run, will run and return <i>loop(i + 1, sum)</i>. This also means a thunk can return a thunk!<br /></p><p>The function that runs <i>loop</i>, and any thunk functions, is called a <i>trampoline</i>. That's because the thunk function the trampoline runs may return a thunk, and if so, that thunk will get run too. The thunks keep bouncing off of the trampoline function. Until one day a thunk returns a value instead of a thunk! Then the trampoline's job is done, and that value is returned.<br /></p><p>Because the thunk itself only ever uses a single "frame" of space on the stack, rather than recursively using more and more stack space with recursive function calls, and so the stack overflow error is avoided.<br /></p><p></p><p>Here's how the code will look:<br /></p><pre><code>const loop = function(i, sum){
if (i < 100000){
sum += i;
let thunk = ()=>{return loop(i + 1, sum)};
return thunk; // rather than returning loop(i + 1, sum)
} else {
return sum;
}
};
const trampoline = function(){
let tv = loop(0, 0);
while (typeof tv === 'function'){
tv = tv(); // returns either a thunk function or a value
}
return tv;
};
console.log(trampoline()); // prints: 4999950000
</code></pre><p>Trampolines running thunk-returning thunk functions is a generic technique that's applicable in other languages and situations too!<br /></p><p><br /></p><p><b>Tail Call Elimination: no need for trampolines<br /></b></p><p>If your programming language has full support for an optimization called Tail Call Elimination, the above trampoline technique is completely unnecessary.</p><p>It turns out JavaScript at one point had this optimization planned. It was to be an "invisible" opportunistic tail call optimization (TCO). Meaning that if you correctly wrote a proper recursive function call in tail position, then TCO would kick in, and it wouldn't consume stack space (thus no stack overflow).</p><p>TCO is currently only available on Apple's Safari browser and on iOS [1].<br /></p><p>Google's V8 team apparently came to the conclusion that TCO makes the wrong tradeoff. Because it's an opportunistic optimization, it's very easy for a programmer to write code they think would get TCO, but actually won't, and it can be very difficult to discover the error during testing. They advocated for an explicit syntactic way to designate a recursive function call as requiring tail call elimination. But... well, it all fell by the wayside and was never picked back up [2].</p><p>Interestingly, the Clojure programming language's creator, Rich Hickey, basically made the same argument. In Clojure, recursive function calls requiring TCO must be written explicitly with a <i>recur</i> syntax. In that case, no trampoline is needed, and the recursive function call won't overflow the stack.<br /></p><p> </p><p>[1] <a href="https://kangax.github.io/compat-table/es6/">https://kangax.github.io/compat-table/es6/</a><br /></p><p>[2] <a href="https://stackoverflow.com/a/42788286">https://stackoverflow.com/a/42788286</a> <br /></p><p></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-46271642622539068692022-05-02T08:00:00.007-07:002022-05-02T08:00:00.177-07:00Firefox Focus - weird but good, standalone mobile browser and ad blocker<p>The best ad blocker around (uBlock Origin [0]) is not available on iPhone iOS. That's essentially because Firefox and other browsers on iOS do not have the ability to load plugins as sophisticated as uBlock Origin.</p><p>A good substitute is Firefox Focus [1]. It's a content blocker on iOS, and can be set up that way so that Focus will block ads from showing when you use Safari!</p><p>A weird thing though is that Focus will not block ads on the main Firefox browser. Again, something to do with iOS restrictions on iPhones.</p><p>That's ok, because <a href="https://blog.carsoncheng.ca/2022/04/ad-blocking-in-firefox-on-iphone-ios.html">Firefox has ad blocking built in</a> (though as an obscure feature).</p><p>Another weird thing is that Firefox Focus also functions as a weird mobile web browser. Weird because although Focus is "Firefox" branded, it doesn't have any of the account and password syncing features of the actual Firefox browser.</p><p>Oh, and Focus doesn't have tabs. You literally have to focus on one web page at a time.<br /></p><p> </p><p>[0] <a href="https://github.com/gorhill/uBlock" rel="nofollow" target="_blank">https://github.com/gorhill/uBlock</a> <br /></p><p>[1] <a href="https://en.wikipedia.org/wiki/Firefox_Focus">https://en.wikipedia.org/wiki/Firefox_Focus</a></p><p><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-60456988900029620812022-04-25T08:30:00.001-07:002022-04-25T08:30:00.152-07:00Ad blocking in Firefox on iPhone iOS<p>uBlock Origin [0] is a plugin for the best ad blocking available, and
it's available for Firefox on Android, Windows, Mac, and Linux.<br /><br />However, Firefox on iPhone iOS (FF-iOS) does not have any plug-in support, so uBlock Origin is not available for it.<br /><br />FF-iOS
doesn't support plug-ins apparently because it's actually using
Safari's rendering engine underneath (a choice forced by Apple,
apparently).<br /><br /><b>What to do about ad blocking in FF-iOS then?</b><br /><br />Turns
out <b>FF-iOS has ad blocking built-in</b>! You just need to go into
"Settings" > "Tracking Protection". Then enable "Enhanced Tracking
Protection", and set "Protection Level" to "Strict".<br /><br />This feature is frustratingly [1][2] not well publicized [3]!<br /><br />Another
very popular plug-in is "dark mode", and that too is built into FF-iOS!
It's very prominently publicized in the app's "more" menu though.<br /><br />[0] <a href="https://github.com/gorhill/uBlock" rel="nofollow" target="_blank">https://github.com/gorhill/uBlock</a><br />[1] <a href="https://www.reddit.com/r/firefox/comments/jwi1r9/firefox_ios_should_integrate_with_ublock_to_make/" rel="nofollow" target="_blank">https://www.reddit.com/r/firefox/comments/jwi1r9/firefox_ios_should_integrate_with_ublock_to_make/</a><br />[2] <a href="https://www.reddit.com/r/firefox/comments/n9jfui/firefox_ios_and_lack_of_content_blockers/" rel="nofollow" target="_blank">https://www.reddit.com/r/firefox/comments/n9jfui/firefox_ios_and_lack_of_content_blockers/</a><br />[3] <a href="https://github.com/mozilla-mobile/firefox-ios/issues/5198#issuecomment-575617840" rel="nofollow" target="_blank">https://github.com/mozilla-mobile/firefox-ios/issues/5198#issuecomment-575617840</a></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-84618868942254269332021-04-28T17:44:00.001-07:002021-04-28T17:44:00.245-07:00Programming Language Notes 2021 - multiplatform, GUIs<p><i>These are <b>incomplete</b> notes and thoughts on programming languages through lens of multiplatform support and coding GUI apps for platforms like Android, iOS, Mac, Windows, Linux, and web (front and back ends).<br /></i></p><p><b>JavaScript<br /></b></p><p>Lack type safety.</p><p><b>Java, Go, </b><b><b>Python, Ruby, C++, C, </b></b><b><b>Elixir</b></b></p><p>Not great for frontend web dev.</p><p><b>D</b></p><p>Not great for Android or iOS. Can build web apps via compiling to WASM (pretty sure it's experimental), but lack mature frameworks for frontend web dev. Not very popularly used, unfortunately.<br /></p><p><b>TypeScript</b></p><p>It's JavaScript but with a brilliant aftermarket type system retrofit. If you must code JS, then TS is a fantastic upgrade.</p><p></p><p>For backend, there's faster languages (Java, Go). For device native apps, other languages are maybe better suited (Swift, Kotlin, etc). Great choice for web frontend.</p><p>For frontend web dev, used with React is popular. There's React Native to build device native apps for Macs, Windows, Linux, Android, and iOS that uses platform native UI widgets (some haven't reached 1.0 yet though, if you're looking for maturity). You'd still have to build 5 specialized UIs though (6 including web), and there are faster device native languages.<br /></p><p><b>Kotlin</b></p><p>Compiles to JVM, JS, and native. <a href="https://kotlinlang.org/docs/multiplatform.html" target="_blank">Kotlin Multiplatform</a> Mobile (alpha) is great for write-once application logic for iOS / Android native apps, but the UI code must be specialized for each platform (could still be written in Kotlin though).</p><p>e.g. Use with Google Android's Jetpack Compose (beta) and Apple's Swift UI for native Android and iOS UI.</p><p>e.g. Use with Jetbrains' <a href="https://www.jetbrains.com/lp/compose/" target="_blank">Compose for Desktop</a> to build apps for Windows, Macs, and Linux --- but this runs on JVM and renders using Skia, so it doesn't use platform native UI widgets (it draws it's own like a game does). And it's in alpha.</p><p>Some say Jetpack Compose is Google Android team's answer to Google Ads team's Dart/Flutter. <br /></p><p>Kotlin/JS means you can use with React for frontend web dev too. Not sure of its maturity. Kotlin is great for backend using Spring or Ktor.<br /></p><p><b>PHP</b></p><p>Not great for device native apps</p><p><b>C#</b></p><p>Windows centric. Blazor lets you do frontend web dev by compiling to WASM but it adds C#'s runtime to your web app to run in WASM as well (read: bigger, slower app).<br /></p><p><b>Rust</b></p><p>Lower level, like C or C++. Can build web apps via compiling to WASM, but without bringing a runtime along for the ride (check out Yew or Seed). Can build backend stuff (check out Actix-web or Rocket), but frameworks aren't mature the way Django or RoR are.</p><p>Coding device native GUI apps is... <a href="https://www.areweguiyet.com/" target="_blank">not there yet</a>.<br /></p><p>Rust is getting a lot of traction for systems programming though (unlike D, unfortunately).<br /></p><p><b>Dart</b></p><p>Basically exists for Flutter. Flutter lets you build apps for Windows, Macs, Linux, iOS, Android, and the web. On the web, it draws into a canvas. On devices, it renders using Skia. So it doesn't use platform native UI widgets anywhere, and draws it's own like a game does. On the web, it's UI performance is a little janky.<br /></p><p>Dart compiles to JS or runs on Dart VM. Unlike the Kotlin stuff above, Flutter is production ready and being used by Google, notably by their Ads team (apparently some of the Kotlin stuff above are the Android team's answer to Flutter).<br /></p><p>It's from Google, so who knows if they'll cancel it in 5 years time.<br /></p><p><b><u>Other thoughts</u></b><br /></p><p>Rendering to Skia like Compose for Desktop and Flutter is not great for accessibility, and their accessibility features are currently WIP.<br /></p><p>React Native has edge cases for each platform so you'd still need to know each platform carefully. Plus TypeScript / JavaScript bridging into native can have performance issues.</p><p> Nothing's perfect.<br /></p><p><i>That's all I've got time for today!</i></p><p><i>Missing: Scala, Clojure, Haskell, F#, Crystal, PureScript, Elm.</i><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-45658092056787894372021-03-25T20:54:00.286-07:002021-03-25T20:54:00.722-07:00Use ISO 8601 dates in PCManFM on Debian LXQt<p>I like <a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a> or RFC 3339 style dates. That is, rather than "January 15, 2021", I like "2021-01-15".</p><p>This is especially useful in a file manager, having all the year-month-day lined up vertically in a column.</p><p>I also prefer 24-hr time format for the same reason. But how to set this up?<br /></p><p> </p><p><u><b>macOS Finder</b></u><br /></p><p>For Mac's file manager, it's really easy to set the date/time format:<br /></p><p>Just open <i><b>System Preferences</b></i> > <i><b>Language
& Region</b></i> > <i><b>Advanced</b></i> > <i><b>Dates</b></i>, then modify the date formats to
whatever you want. At the same time, you could go to the <i><b>Times</b></i> tab and
set it to use 24-hr format. </p><p>Done! I offer this as just a point of comparison for what's below... </p><p><br /></p><p><u><b>Debian LXQt PCManFM</b></u></p><p>On LXQt's PCManFM file manager, running on Debian, the setup was... annoyingly difficult.</p><p>PCManFM does not allow custom date/time formatting. It only respects the system set <i>locale</i>. So you have to choose the right locale.</p><p><b>Step 1.1: Select Locale</b><br /></p><p>On LXQt, you can easily set the locale (they call it "Region") by running <b><i>lxqt-config-locale</i></b> in the terminal, or else click the system <i><b>Preferences</b></i> > <i><b>LXQt settings</b></i> > <i><b>Locale</b></i>.</p><p><b>Step 1.2: Which locale to choose???</b></p><p>You have a number of options.</p><p>Do you want:</p><ul style="text-align: left;"><li>English language</li><li>dollar denominated</li><li>metric</li><li>ISO-8601</li><li>but 12-hr time?</li></ul><p>Use <b>Canadian English</b> (en_CA) locale.<br /></p><p>If that's not close enough, and you <i>really</i> want 24-hr time as well, you can enable <b><i>Detailed Settings</i></b> and change the <b><i>Time</i></b> locale to <b>Sweden - English</b> (en_SE).</p><p>Be sure to see <b>Step 2: Installing Locales in Debian</b>, because chances are doing the above will cause system errors later!</p><p>Note that en_CA uses Canadian dollars, not USD! You can change the <b><i>Currency</i></b> locale to <b>American English</b> (en_US) if you want <i>real</i> USD dollars. Although it probably doesn't matter for formatting purposes.<br /></p><p>Why Sweden? It turns out lots of Europeans want something similar, as in a locale that is English language, metric, using ISO-8601 or similar style dates!</p><p>Sweden - English is an unofficial locale made up to give us that [1], but it does use Swedish
kronor SEK for currency [2]. That's why you <i>only</i> want to set the <b><i>Time</i></b> locale to use en_SE, keeping the rest as en_CA (or en_US).</p><p> </p><p><b>Step 2: Installing Locales in Debian</b><br /></p><p>Selecting the "Region" in LXQt's <i>locale </i>preference app is just half the story.</p><p>PCManFM will probably work fine as is. Qt apps are fine because it uses it's own Qt locale definition lookup system, and includes en_CA and en_SE by default.<br /></p><p>Debian does <b><i>not</i></b> include en_CA by default, so you'll have to install it. And it does <b><i>not</i></b> have en_SE... not at all... you'll have to add the en_SE definition file manually then install it.<br /></p><p>You can download a copy of the <a href="http://www.stacken.kth.se/~auno/en_SE" target="_blank">en_SE locale definition</a> written by Mikael Auno [7]. Then create this directory if it doesn't exist:</p><p><code></code></p><pre><code>/usr/local/share/i18n/locales</code></pre><p></p><p>Place the <code>en_SE</code> file into the above <code>locales</code> directory. Create a text file in the above <code>i18n</code> directory containing this text:<br /><br /> <code>en_SE.UTF-8 UTF-8</code></p><p>Then run in terminal:<br /></p><pre><code>$ sudo dpkg-reconfigure locales</code></pre><p>You should see a list of locales you can install. Look for and install the ones you selected in LXQt's <i>locale </i>preference app. For my example above, that means en_CA, en_US, and en_SE.</p><p>Lastly, logout and re-login for the changes to take effect.</p><p> </p><p><u><b>Fully Custom Locales in Debian: don't bother<br /></b></u></p><p>From above, you see Debian allows you to create totally custom locales, so you can customize all the formats the way Macs can! After all, that <code>en_SE</code> locale file you downloaded was just <i>made up</i> so to speak, and you can customize it however you want.</p><p>...but Qt won't use it. Qt's locale system runs parallel to Debian Linux's.</p><p>So why go through the trouble of installing the en_SE locale if Qt won't use it? Because if you don't, you'll run into problems with non-Qt apps, problems like:</p><p>Run <code>locale</code> in the terminal, and it'll complain:</p><p style="margin-left: 40px; text-align: left;"><code></code></p><pre><code>locale: Cannot set LC_MESSAGES to default locale: No such file or directory<br />locale: Cannot set LC_ALL to default locale: No such file or directory</code></pre><p></p><p>Unzip certain archives using <code>file-roller</code> results in a dialog box complaining:</p><p style="margin-left: 40px; text-align: left;"><code></code></p><pre><code>An error occurred while extracting files.<br />Pathname can't be converted from UTF-8 to current locale.<br /></code></pre><p></p><p>That occurs because a locale you chose in LXQt was not installed in Debian [8]. Qt is perfectly happy though, as it runs a separate locale system...</p><p> </p><p><u><b>Firefox locale incompatibility</b></u></p><p>If you set your locale to Canadian or US English (en_CA or en_US), and enabled <b><i>Detailed Settings</i></b> to change the <b><i>Time</i></b> locale to <b>Sweden - English</b> (en_SE), Firefox will show numbers in Swedish / European style, like "3,14" instead of "3.14".</p><p>This problem happens at least in the downloads window.</p><p><b>Method 1: Fix by setting LC_ALL environment variable </b><br /></p><p>The most reliable way to fix it in Debian is to set the <code>LC_ALL</code> environment variable, but <i>only</i> for Firefox [13]. Don't set <code>LC_ALL</code> globally or it'll undo the locale changes above, plus you just shouldn't as it overrides everything [12]. </p><p><i><b>For the terminal :</b></i><br /></p><p>With that said, all it involves is opening Firefox in the terminal like this:</p><p><code>LC_ALL=en_CA.utf8 firefox</code><br /></p><p>You can save that in a script that's in your <code>PATH</code> so running Firefox always uses the <code>LC_ALL</code> locale.</p><p><i><b>For the Firefox icon:</b></i> <br /></p><p>The Firefox icon in Debian requires a different fix though. That icon in the applications menu is controlled by a <code>firefox.desktop</code> file located at:</p><p><code></code><code>/usr/share/applications/firefox.desktop</code> <br /></p><p>You can modify it directly or, safer, copy it to your user's applications folder:</p><p><code>~/.local/share/applications</code><br /></p><p>Once copied, open it in a plaintext editor and change the <code>Exec</code> line to this:<br /></p><p><code>Exec=sh -c "LC_ALL=en_CA.utf8 /usr/bin/firefox"</code></p><p> </p><p><b>Method 2: </b><b><b>Fix by setting</b> Firefox locale internally</b></p><p>The "official" way to set the Firefox user interface locale is via Firefox's preferences [14]: open preferences, then go to the <i>Language</i> section of the <i>General</i> panel.</p><p>I've tried it on Debian and it doesn't work.</p><p>You could also try finding in <code>about:config</code> the <code></code><code>intl.locale.requested</code> key and set it to the desired locale [15]. I didn't test this method though because setting the <code>LC_ALL</code> environment variable worked perfectly for me.<br /></p><p><br /></p><p><u><b>Other locale options</b></u><br /></p><p><b>Sweden - English</b> (en_SE) is an unofficial locale made up to give us English language, metric, ISO-8601 date format [1]. But it uses Swedish kronor SEK for currency [2]. </p><p><b>Denmark - English</b> (en_DK) is another unofficial locale made up with similar English and metric formats [3]. But the date is backwards (in dd/MM/y format), and uses Danish kroner DKK currency [4].</p><p><b>Ireland - English</b> (en_IE) is an <i>official</i> locale that, like Denmark - English, gives us English and metric units [5], and like en_DK, the date is backwards (in dd/MM/y format). It uses Euro for currency [6] though.</p><p>So by mixing and matching Ireland, Denmark, and Sweden, you should be able to get a reasonable ISO 8601/English/Euro(pean) locale.</p><p>And mixing Canada, US, and Sweden will get you a reasonable ISO 8601/English/Dollar locale.<br /></p><p><br /></p><p><u><b>References</b></u><br /></p><p>[1]: https://unix.stackexchange.com/a/62318</p><p>[2]: https://icu4c-demos.unicode.org/icu-bin/locexp?d_=en&_=en_SE</p><p>[3]: https://unix.stackexchange.com/a/272665 and https://superuser.com/a/1269909<br /></p><p>[4]: https://icu4c-demos.unicode.org/icu-bin/locexp?d_=en&_=en_DK</p><p>[5]: https://unix.stackexchange.com/a/62317</p><p>[6]: https://icu4c-demos.unicode.org/icu-bin/locexp?d_=en&_=en_IE</p><p>[7]: https://bugs.launchpad.net/ubuntu/+source/langpack-locales/+bug/208548/comments/11</p><p>[8]: https://unix.stackexchange.com/a/269293</p><p>[12]: https://wiki.debian.org/Locale#Configuration </p><p>[13]: https://unix.stackexchange.com/questions/34965/how-to-change-firefox-language#comment47453_34967</p><p>[14]: https://support.mozilla.org/en-US/kb/use-firefox-another-language?redirectslug=use-firefox-interface-other-languages-language-pack&redirectlocale=en-US#w_how-to-change-the-language-of-the-user-interface</p><p>[15]: https://support.mozilla.org/en-US/questions/1223719#answer-1127761</p><p><br /></p><p><u><b>Bibliography</b></u></p><p>[9]: https://github.com/lxqt/pcmanfm-qt/issues/656</p><p>[10]: https://github.com/lxqt/lxqt-config/issues/507</p><p>[11]: https://wiki.debian.org/Locale</p><p><br /></p><p></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-15078820544723253342021-03-18T11:52:00.001-07:002021-11-06T11:10:44.763-07:00Enable 3 Finger Drag on Linux<p></p><h1 style="text-align: left;"><b><b>3 Finger Drag (3FD)</b> is not available on Windows, and not built-in on Linux<br /></b></h1><p>On Windows, we can achieve something similar. Let's call it: <b>3 Finger Tap to Drag Lock</b>. See <a href="https://blog.carsoncheng.ca/2021/02/enable-3-finger-drag-on-windows.html" target="_blank">Enable 3 Finger Drag on Windows</a> for how.</p><p>On Linux, it <i>is</i> apparently possible to have pretty good 3 Finger Drag! See below. </p>Pretty
good but not as good as Mac's 3FD, but without Apple's tightly
integrated hardware, software, OS, driver, etc., it's impossible to get
Apple Mac's high quality 3FD.<h1 style="text-align: left;"><b>What's 3FD anyway?</b> <br /></h1><p>3 Finger Drag refers to a Mac
accessibility feature. When enabled, if you place three fingers on the
Mac's trackpad or touchpad, then move those fingers in unison on the
trackpad, the mouse pointer behave as if you
left-clicked-and-are-dragging.</p><p>It's a better more ergonomic alternative to the tap-twice-and-drag method that's common on Macs, Windows, and Linux.</p><p>It's
better because there's less finger tapping movement which can develop
into "trigger finger" type repetitive strain injury. If you drag things
around a lot, tap-twice-and-drag plus another tap to deactivate
dragging starts to add up to being a nuisance!<br /></p><p>And at least
for me, when dragging using the tap-twice-and-drag gesture, I often
have trouble continuing to drag mid-drag if I lift my hand away from the
trackpad to reposition. And ironically, I also have trouble
disengaging the drag once I've reached the target of the drag motion
too!</p><h1 style="text-align: left;"><b>How to add 3FD to Linux</b></h1><p>As of 2021 January, the happy path to getting 3FD on Linux is: </p><ol style="text-align: left;"><li>Use a desktop Linux system that uses libinput for handling the trackpad</li><li>build your own custom 3FD enabled libinput</li><li>install your custom libinput.</li></ol><p><b>(1) Use a desktop Linux system that uses libinput for handling the trackpad</b></p><p>Fortunately, Ubuntu and Debian uses libinput. And libinput works with both Wayland and X11. And Gnome/Xfce/KDE/LXDE all work with libinput. So practically everyone's standardized onto libinput for trackpad and gesture support in 2021!</p><p><b>(2) Build custom 3FD enabled libinput </b><br /></p><p>Unfortunately, 3FD isn't standard in libinput. And likely won't be for a very long time if ever.</p><p>But there's a patched version of libinput with 3FD added! Here's the most recent patch: <a href="https://github.com/aakside/libinput/tree/1.16-branch-complyue" target="_blank">aakside's libinput</a>.</p><p><b>(3) install your custom libinput</b> </p><p>See <a href="https://medium.com/@dakshin.k1/enable-3-finger-gesture-for-click-and-drag-on-windows-and-linux-cd7165b66851" target="_blank">Dakshin Karthikeyan's article</a> for the Linux specific instructions on how to install.</p><p>Caution: Dakshin's article references a different 3FD patched libinput that's by jafd, which is slightly older and apparently with less 3FD enabling features.</p><p>To be clear, aakside's 3FD enabled libinput is a rebasing of complyue's 3FD libinput patch onto a more updated libinput.<br /></p><p>I wrote a <a href="https://blog.carsoncheng.ca/2021/03/state-of-built-in-3-finger-drag-on-linux.html" target="_blank">State of Built-in 3 Finger Drag on Linux</a> post earlier if you want to understand more the relationship between the various libinput patches / forks.</p><p><i><u><b>Alternatively...</b></u></i></p><p>It's work checking out another route to 3FD based on top of libinput like libinput-gestures called <a href="https://github.com/marsqing/libinput-three-finger-drag" target="_blank">libinput-three-finger-drag (marsqing)</a>. It can work alongside libinput-gestures. However, it's <a href="https://github.com/marsqing/libinput-three-finger-drag/issues/4" target="_blank">stopped working as of 2021 Oct 28</a>. But if it works, it seems less invasive than using a patched libinput?<br /><b></b></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-40287406649873104672021-03-10T15:57:00.001-08:002021-11-06T11:08:18.839-07:00State of Built-in 3 Finger Drag on Linux<p> Will we ever get built-in 3 Finger Drag (3FD) on Linux? At this point, likely not.<br /></p><p><b>Non-libinput desktop Linux</b> <br /></p><p>For older desktop Linux not using libinput for trackpad support, you can look into <a href="https://github.com/BlueDragonX/xf86-input-mtrack" target="_blank">mtrack</a> (no 3FD but...) and the <a href="https://github.com/p2rkw/xf86-input-mtrack" target="_blank">p2rkw's mtrack fork</a> which provides 3FD. <a href="https://martys.typepad.com/blog/2015/08/3-finger-drag-on-linux.html" target="_blank">Marty's article</a> [1] is older but explains it well for non-libinput desktop Linux.</p><p>But non-libinput is on the way out. <br /></p><p><b>Libinput is basically standard in 2021</b> <br /></p><p>Everyone's using libinput now, pretty much. If you're on a desktop Linux machine using Wayland, you're using libinput.</p><p>If you're using X11 still, you still could be using libinput. Or
synaptics or xf86-input-* or... but at least on Debian buster LXDE as I
am, turns out it's using libinput.</p><p><a href="https://gitlab.freedesktop.org/libinput/libinput" target="_blank">Libinput</a> sits between your
input drivers in the linux kernel and the display server. Libinput is
the present and future of gesture, event, and pointer support for trackpads on Linux.</p><p>So if you want 3FD into the future, we have to look at libinput. <br /></p><p><b>Configuring libinput</b></p><p>If you're using Wayland on Linux, there's no way to configure libinput. This is <a href="https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-wayland" target="_blank">by design</a>.
You should use your desktop environment's configuration to configure
the trackpad. Your desktop environment will configure libinput as
needed.<br /></p><p>Using X11 on Linux, you can still configure libinput.
Like most things X11 related, you have to change configuration files
here and there. See <a href="https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-x" target="_blank">libinput's FAQ on this point</a> to start. But <a href="https://wiki.archlinux.org/index.php/Libinput" target="_blank">ArchWiki's libinput page</a> is great with plenty of details.</p><p>There is, however, no configuration for 3FD for libinput anyway.</p><p><b>State of 3FD support in libinput via patches</b><br /></p><p>There's two patched versions of libinput with 3FD added you could try!</p><ol style="text-align: left;"><li><a href="https://github.com/jafd/libinput" target="_blank"> jafd's libinput </a></li><li><a href="https://github.com/aakside/libinput/tree/1.16-branch-complyue" target="_blank">aakside's libinput</a> --- this is an updated version of <a href="https://github.com/complyue/libinput" target="_blank">complyue's libinput</a> which had 3FD enabled but was based on an older libinput version</li></ol><p></p><p>See <a href="https://medium.com/@dakshin.k1/enable-3-finger-gesture-for-click-and-drag-on-windows-and-linux-cd7165b66851" target="_blank">Dakshin Karthikeyan's article</a> for the Linux specific instructions on how to install. But Dakshin references jafd's libinput instead of complyue / aakside's patch.<br /></p><p> If you go through the whole <a href="https://gitlab.freedesktop.org/libinput/libinput/-/issues/298" target="_blank">Request for three fingers click+movement </a>in libinput's repository, you'll see that jafd's 3FD is possibly less featureful than complyue's. But complyue's version was based on an older libinput.</p><p>That Request discussion thread also seems to point at the difficulty and possibly impossibility of libinput ever having 3FD enabled by default.<br /></p><p>Fortunately, aakside updated complyue's patch to the latest libinput! <br /></p><p><b>3FD via libinput-gestures</b></p><p>There is another route to 3FD via <a href="https://github.com/bulletmark/libinput-gestures" target="_blank">libinput-gestures</a> via this patched <a href="https://github.com/daveriedstra/libinput-gestures/tree/three-finger-drag" target="_blank">fork of libinput-gestures with basic 3FD support</a>.</p><p><b>3FD via libinput-3FD</b></p><p>There is another route to 3FD based on top of libinput like libinput-gestures called <a href="https://github.com/marsqing/libinput-three-finger-drag" target="_blank">libinput-three-finger-drag (marsqing)</a>. It can work alongside libinput-gestures. However, it's <a href="https://github.com/marsqing/libinput-three-finger-drag/issues/4" target="_blank">stopped working as of 2021 Oct 28</a>.</p><p><br /></p><p><b>References</b></p>[1] <a href="https://martys.typepad.com/blog/2015/08/3-finger-drag-on-linux.html" target="_blank">3-finger-drag on Linux</a> bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com1tag:blogger.com,1999:blog-713602603894920874.post-64375110049283044572021-03-04T22:33:00.006-08:002021-03-04T22:33:00.771-08:00.bashrc, .profile, .bash_profile in Lubuntu vs Debian LXDE<p>Here we go again... profile vs bash_profile vs bashrc dot files.</p><h1 style="text-align: left;"><b>In Lubuntu<br /></b></h1><p>I had figured <a href="https://blog.carsoncheng.ca/2020/04/profile-bashprofile-bashrc-on-ubuntu.html" target="_blank">previously [1]</a> that:</p><ul style="text-align: left;"><li>Desktop environment's graphical login sources .profile</li><li>bash started in login mode sources .bash_profile, but if that doesn't exist, then falls back to sourcing .profile</li><li>bash started interactively (hence in non-login, or interactive, mode) sources in .bashrc only<br /></li><li>Both .bash_profile and .profile should contain code to source in .bashrc</li></ul><p>So when does code in each file run? <br /></p><p><b>.profile</b> has code you want to run only once, and only upon your DE graphical login.</p><p><b>.bash_profile</b> has code you want to run once only upon your bash shell executing in login mode</p><p><b>.bashrc</b> has code you want to run every single time bash starts, or when you login (if .profile sources in .bashrc as it should), or when bash starts in login mode (if .bash_profile sources in .bashrc as it should).</p><h1 style="text-align: left;">In Debian LXDE<br /></h1><p>It seems that:</p><ul style="text-align: left;"><li>Desktop environment's graphical login <b>AND</b> bash started in login mode both source .bash_profile, but if that doesn't exist, then falls back to sourcing .profile</li><li>bash started interactively (hence in non-login, or interactive, mode) sources in .bashrc only<br /></li><li>.bash_profile or .profile should contain code to source in .bashrc</li><li>You should <i>not</i> have both .bash_profile and .profile since then the latter will be ignored anyway<br /></li></ul><p>This meant there's no place to put code that you want to run only once, and only upon your DE graphical login.</p><p>The workaround is to put the code in .profile (and you shouldn't have .bash_profile around as it'll override .profile).</p><p>Then make that code run only if the GUI is running, which you can detect. And also make the code only once only, by checking if it's run before.<br /></p><p>e.g. in .profile<br /></p><p>
<code></code></p><pre><code>
if [ -n "$DISPLAY" ]; then
if [ ! -n "$RUNONCE" ]; then
export RUNONCE="done" # like a C include guard
cat "GUI running" > GUI_is_running.txt
fi
fi </code></pre><p>In a console without a GUI, $DISPLAY is not defined.</p><p></p><h1 style="text-align: left;">To learn more <br /></h1><p> Some resources from other sites:<br /></p><ul style="text-align: left;"><li><a href="https://superuser.com/a/183980" target="_blank">Difference between .bashrc and .bash_profile</a></li><li><a href="https://superuser.com/a/789465" target="_blank">Choosing between .bashrc, .profile, .bash_profile, etc</a></li><li><a href="https://serverfault.com/a/261807" target="_blank">What are the functional differences between .profile .bash_profile and .bashrc</a></li><li><a href="https://leimao.github.io/blog/bashrc-VS-profile-VS-bash_profile/" target="_blank">~/.bashrc VS ~/.profile VS ~/.bash_profile</a></li><li><a href="https://news.ycombinator.com/item?id=24881711" target="_blank">HN: barrkel | on: /.bashrc VS –/.profile VS –/.bash_profile </a></li></ul><p>[1] <a href="https://blog.carsoncheng.ca/2020/04/profile-bashprofile-bashrc-on-ubuntu.html" target="_blank">profile bash_profile bashrc on Ubuntu Linux, Macs, and Windows</a><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-4638503748675042892021-02-25T11:25:00.000-08:002021-02-25T11:25:00.899-08:00Mac Finder still shows incorrect folder sizesIt's been two years, and the Mac Finder <i>still</i> shows incorrect folder sizes --- on macOS 10.15 Catalina.<br /><p>A single screenshot shows how hilarious / sad this is:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5XYB4jdNY_K3fBQjn_lp_AlFc9gaMqoLdpo5kov6B42l1xemqEaNrgS1cqHs56xKLxUY32AeSSJfT_J8FlQoBRuUGEN-mrf2MJXsgKr1-OAlonkZ4U_OpgugP1GC5PEjaKy4RHmg-V4I/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="413" data-original-width="1025" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5XYB4jdNY_K3fBQjn_lp_AlFc9gaMqoLdpo5kov6B42l1xemqEaNrgS1cqHs56xKLxUY32AeSSJfT_J8FlQoBRuUGEN-mrf2MJXsgKr1-OAlonkZ4U_OpgugP1GC5PEjaKy4RHmg-V4I/w640-h258/Screen+Shot+2021-02-20+at+23.14.17.jpg" width="640" /></a></div> <p></p><p>The screenshot here shows the Finder thinking my "lol" folder is 17.92 GB.</p><p>But inside "lol" are two sub-directories: "magic", and "movs". Finder thinks those two folders are zero KB.</p><p>Inside "movs" are a bunch of MP4 files that together are several <i>hundred</i> MBs.<br /></p><p>Bring up the terminal to check, and <i>du</i> shows "lol" is actually 211 GB !!!</p><p>For the record, <i>du</i> is correct. "magic" contains a lot more files.<br /></p><p>Oh Apple... I can't recall classic Mac OS Finder, since the System 7 days, ever having this level of... mistake? incompetency? error? If every time the Finder's Get Info window is open, it would just spin out a <i>du</i> sub-process to get the folder size, then it wouldn't get it this wrong. But nope.<br /></p><p>And for the record, I had to restart the Mac to get the folder size to show correctly. Something with the Finder got really screwed up I guess.<br /></p><p>This problem has been known for two years, since macOS 10.14. See:<br /></p><p>- 2019 February: <a href="https://mjtsai.com/blog/2019/02/22/finder-shows-incorrect-folder-sizes/" target="_blank">Finder Shows Incorrect Folder Sizes</a> --- on macOS 10.14<br /></p><p>- 2020 February: <a href="https://daringfireball.net/2020/02/what_you_see_in_the_finder_should_be_correct" target="_blank">What You See in the Finder Should Always Be Correct</a></p>- 2021 February: here we are... bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-91031469862567025412021-02-19T14:03:00.130-08:002021-02-19T14:03:00.341-08:00Remap Capslock to Control in VirtualBox Linux guest on Windows host<p>Let's say you have Debian Linux guest OS in VirtualBox, running on a Windows 10 host.</p><p></p><p><b>Here's how to map capslock to control</b></p><p>If it was a Mac host, it'd be super easy: install and use <a href="https://karabiner-elements.pqrs.org/" target="_blank">Karabiner-Elements</a> to remap capslock to control in the Mac host [3]. Now both host and guest Linux will have the remapping. Done.</p><p>On Windows, it's not so easy.</p><p>You basically have to do the remapping in both Windows and Linux. Follow the ideas here:</p><p></p><ol style="text-align: left;"><li><a href="https://blog.carsoncheng.ca/2021/01/remap-one-key-to-another-in-windows.html" target="_blank">Remap one key to another in Windows, like Capslock to Control</a> </li><li><a href="https://blog.carsoncheng.ca/2021/02/remap-one-key-to-another-in-linux-like.html" target="_blank">Remap one key to another in Linux, like Capslock to Control</a></li></ol><p><b>Set shift key to break capslock for greater reliability<br /></b></p><p>For greater reliability, you should also set shift key to break capslock. So adding that to the Linux command for making capslock a control key, you'd get this command to run instead: </p><p style="margin-left: 40px; text-align: left;"><code>setxkbmap -option -option caps:ctrl_modifier -option shift:breaks_caps <br /></code></p><p>The first blank "-option" clears any previously set. Then the second option sets the capslock to control. The third option makes shift key break capslock.</p><p>This is needed because sometimes switching between Windows host and Linux guest, the capslock gets locked down. Now a quick tap on the shift key should break that lock.<br /></p><p style="text-align: left;"><b>What's wrong with remapping in Windows host only?<br /></b></p><p style="text-align: left;">If you remap capslock to control in Windows host only, it'll actually sort of work in the Linux guest --- except in Linux, the capslock will now function as <i>both</i> capslock <i>and</i> control!</p><p style="text-align: left;">I did that for a while and didn't notice as I tested it inside Linux guest. Capslock-T in Firefox still created new tabs! Works! But if you start typing, you'll notice things are in all caps until you tap capslock again, and vice versa.</p><p style="text-align: left;"><b>What's wrong with remapping in Linux guest only?</b></p><p style="text-align: left;">If you remap capslock to control in Linux guest only, it'll actually work! Except the capslock LED light will turn on/off with each click. And if you switch back to Windows, capslock might have been engaged as you used capslock-as-control in Linux guest.<br /></p><p>That's why you must do the remapping in both Windows host and Linux guest. That way they stay in sync with each other, and the LED light won't turn on.</p><p><b>Capslock LED light in Linux</b></p><p>As I was troubleshooting the Linux guest only remapping, and noticed the capslock LED light would turn on/off, at first I thought the problem was in Linux.</p><p>And in case it is for your situation, here's how to fix or check.</p><p><code>xmodmap -e 'clear Lock'</code> is suppose to clear the capslock LED from being turned on [1]. Try that, despite <i>xmodmap</i> being a deprecated system.</p><p>You can check if the LED is being turned on by Linux by running this command:</p>
<code><pre>cat '/sys/class/leds/input5::capslock/brightness'
</pre></code>
<p>Turns out the LED property is represented as "just a file" on Linux you can open and read [2].<br /></p><p>In my case, that command showed the LED was always off from Linux guest's point of view. Turned out Windows host was controlling it.<br /></p><p><br /></p><p><b>Reference</b></p><p>[1] <a href="https://unix.stackexchange.com/a/75578" target="_blank">How to prevent the caps-lock toggle effect, without remapping or disabling it?</a> <br /></p><p>[2] <a href="https://askubuntu.com/a/734861" target="_blank">Turn the Caps Lock LED on, while keep Caps Lock status is off</a></p><p>[3] Actually, I think Mac's System Preferences even have a built in setting
for doing this remapping, so Karabiner might not even be needed for this
single simple remapping.</p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-31723758385504757762021-02-10T00:36:00.118-08:002021-03-26T20:50:34.334-07:00Remap one key to another in Linux, like Capslock to Control<p>Linux is known for choice and customizability.</p><p>So it's ironic but when it comes to keyboard and mouse key remapping and scripting, Linux is the more challenging than Windows (using AutoHotKey) or Macs (using Karabiner-Elements).</p><p>I'll link to some guides and answers below, but some big picture ideas to be aware of in 2020 for Linux key remapping:</p><h1 style="text-align: left;"><b>xmodmap is deprecated</b></h1><p>Prefer using <b>setxkbmap</b> if it'll do what you want.<br /></p><p>Some xmodmap functionality remains, but it's clearly a deprecated system and it sometimes doesn't work.</p><p>I tried to do some simple key remapping with it on Debian LXDE and it didn't work for me.</p><h1 style="text-align: left;"><b>setxkbmap is preferred but complicated</b></h1><p>It has many common remappings like turning capslock to control [1]:</p><p style="margin-left: 40px; text-align: left;"><code>setxkbmap -option -option caps:ctrl_modifier</code></p><p>The first blank "-option" clears any previously set. Then the second option sets the capslock to control.<br /></p><p>Swapping the left control and alt keys can be easy to do as there's a direct option for it too.</p><p>Running setxkbmap only affects the current session, so logging out will wipe the settings. To make it auto set on login, put it in a script run from .bashrc or similar.<br /></p><p><b>Limitations</b> <br /></p><p>But what if you want to swap the <i>right</i> control and alt keys instead? Or some weird 4 way switch of keys? <br /></p><p>There many be some set of xkeyboard-config options that'll work, but it's not straightforward the way it is on a Mac with Karabiner-Elements. <br /></p><p>You also may have to find and use keycodes or events generated by your keyboard or mouse interactively. Do this using the <b>xev</b> command line app [3].</p><p> If you want to go down this route, be sure to check out: <a href="https://medium.com/@damko/a-simple-humble-but-comprehensive-guide-to-xkb-for-linux-6f1ad5e13450" target="_blank">A simple, humble but comprehensive guide to XKB for linux</a>. But if you want an easier way, check out the last section below because, of course, there's an app for that!<br /></p><h1 style="text-align: left;">Show setxkbmap options</h1><p>To find what options are supported by setxkbmap, you can run [2]:<br /></p><p style="margin-left: 40px; text-align: left;"><code>man xkeyboard-config</code></p><p><b>man xkeyboard-config is not complete: e.g. right alt to right control<br /></b></p><p>More annoyingly, turns out running <i>man xkeyboard-config</i> does not list a complete list of what setxkbmap can do!</p><p>For example, let's say you want to make the right alt another right control key.</p><p>It's not listed in <i>man xkeyboard-config</i> but it <i>is</i> easily possible! Just run:</p><p><code>setxkbmap -option ctrl:ralt_rctrl</code></p><p>It is listed in a lower level description file at however [4] :</p><p><code>/usr/share/X11/xkb/rules/evdev</code> <br /></p><p>And if you're up to it, you can change the low level description files that setxkbmap uses to give you great control over the keyboard remappings. But it's not easy the way it is on Macs and Windows!<br /><br /></p><h1 style="text-align: left;"><b>Remapping single keys using hwdb files</b><br /></h1><p>This is lower level than setxkbmap, but it's not deprecated like xmodmap, and for single key to single key remapping, it seems to work well.</p><p>Detailed instructions found at: <a href="https://www.reddit.com/r/linux_gaming/comments/k3h9qv/remapping_keys_using_hwdb_files/" target="_blank">Remapping keys using hwdb files</a><br /></p><h1 style="text-align: left;"><b>Use an app to intercept and inject keys</b><br /></h1><p>This method allows more complex hotkeys and combos to be remapped to almost arbitrary input.</p><p>This is really new. Try out <a href="https://github.com/sezanzeb/key-mapper" target="_blank">sezanzeb's key-mapper</a>. It works with X11 and Wayland, and has an easy GUI interface to it.</p><p>Here's a nice guide for it: <a href="https://www.linuxuprising.com/2020/12/remap-keyboard-and-mouse-buttons-on.html" target="_blank">Remap Keyboard And Mouse Buttons On Linux With The New Key Mapper GUI (Supports X11 And Wayland)</a>.<br /></p><p>Since key-mapper is a Python program, you'll need Python to run it
anyway. So on Debian, you might as well just install Python and pip,
then use pip to install it.</p><p>Key-mapper is <b>not</b> available in Debian's package system, so you'll have to download and install it from the <a href="https://github.com/sezanzeb/key-mapper" target="_blank">key-mapper Github repository</a>.</p><p>In fact, Debian has a package called "keymapper" that is <b>not</b> the key-mapper you're looking for. Using apt to install key-mapper, even key-mapper's own pre-packaged .deb file, kept suggesting the wrong "keymapper" package instead.</p>Probably easiest to just install it with pip!<br /><p>(<b>NEW!</b>) Check out <a href="https://github.com/rbreaves/kinto" target="_blank">kinto</a> if you're interested in mac-style hotkeys on Linux and Windows!<br /></p><p><br /></p><p><b>References</b></p><p>[1] <a href="https://opensource.com/article/18/11/how-swap-ctrl-and-caps-lock-your-keyboard" target="_blank"> How to swap Ctrl and Caps Lock keys in Linux</a></p><p>[2] <a href="https://unix.stackexchange.com/q/43976" target="_blank">List all valid kbd layou ts, variants and toggle options (to use with setxkbmap)</a></p><p>[3] <a href="https://unix.stackexchange.com/a/75492" target="_blank">How to prevent the caps-lock toggle effect, without remapping or disabling it?</a></p><p>[4] <a href="https://unix.stackexchange.com/a/353699" target="_blank">Map right alt to left control</a> <br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-73994755589503991922021-02-02T21:33:00.190-08:002021-02-02T21:33:00.794-08:00Enable 3 Finger Drag on Windows<p><b>3 Finger Drag (3FD) is not available on Windows</b><b>, and not built-in on Linux</b> <br /></p><p>For Linux support, I'll write another post in the future. <br /></p><p>On Windows, we can achieve something similar. Let's call this: <b>3 Finger Tap to Drag Lock</b>.</p><p>It's Dakshin's idea [1], refined further [2] and tweaked below.<b> <br /></b></p><p><b>What's 3FD anyway?</b> <br /></p><p>3 Finger Drag refers to a Mac accessibility feature. When enabled, if you place three fingers on the Mac's trackpad or touchpad, then move those fingers in unison on the trackpad, the mouse pointer behave as if you left-clicked-and-are-dragging.</p><p>It's a better more ergonomic alternative to the tap-twice-and-drag method that's common on Macs, Windows, and Linux.</p><p>It's better because there's less finger tapping movement which can develop into "trigger finger" type repetitive strain injury. If you drag things around a lot, tap-twice-and-drag plus another tap to deactivate dragging starts to add up to being a nuisance!<br /></p><p>And at least for me, when dragging using the tap-twice-and-drag gesture, I often have trouble continuing to drag mid-drag if I lift my hand away from the trackpad to reposition. And ironically, I also have trouble disengaging the drag once I've reached the target of the drag motion too!</p><p><b>3 Finger Tap to Drag Lock (3FTD) on Windows<br /></b></p><p>The gesture allows you to tap on the trackpad with 3 fingers, which will "lock" the left click down. Then you can use 1 finger to move the cursor around, thus dragging what's clicked on! A single tap again will disengage it.</p><p>You'll need to install <a href="https://www.autohotkey.com/" target="_blank">AutoHotKey</a> (AHK) as this is a script continuously running in the background to make it happen.</p><p><b>Installing the AHK Script</b><br /></p><p>Make a text file and copy the script below into it, then save the text file with a <b>.ahk</b> file extension. Double click the .ahk script file and AutoHotKey will run it to give you this 3FTD behaviour.</p><p>If you want the script to run every time you log in to Windows, you'll need to move the script or add a shortcut to it into the Windows startup folder. See <a href="https://www.maketecheasier.com/schedule-autohotkey-startup-windows/" target="_blank">detailed instructions</a> [3] for that.</p><p><b>ThreeFingerTapDragLock.ahk</b></p>
<code><pre>#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
drag_enabled := false
; Key combo for 4 finger tap: #^+F24
#^+F22:: ; 3 finger tap
if (drag_enabled)
Click, Up
else
Click, Down
drag_enabled := !drag_enabled
return
#If drag_enabled
LButton::
Click, Up
drag_enabled := false
return
#If
</pre></code>
<p><b>Limitations of this script: games and VirtualBox</b></p><p>Chances are, this script won't work inside games. Many games access the mouse and keyboard at a lower level than what AHK can effectively manipulate, or has anti-scripting functionality built-in.</p><p>AHK also doesn't play nice with VirtualBox since it's virtualizing the keyboard and mouse for the guest OS!</p><p>To avoid problems with VirtualBox, I tweaked the above script so it only works outside of it:</p><p><b>ThreeFingerTapDragLock_OutsideVBox.ahk</b></p>
<code><pre>#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
drag_enabled := false
#If !WinActive("ahk_exe VirtualBoxVM.exe")
; Key combo for 4 finger tap: #^+F24
#^+F22:: ; 3 finger tap
if (drag_enabled)
Click, Up
else
Click, Down
drag_enabled := !drag_enabled
return
#If drag_enabled && !WinActive("ahk_exe VirtualBoxVM.exe")
LButton::
Click, Up
drag_enabled := false
return
#If
</pre></code>
<p><b>Note about the Key combo</b></p><p>My trackpad's 3 finger tap sends the key combo Win+Ctrl+Shift+F22.</p><p>And it's F24 instead of F22 if I 4 finger tap.</p><p>So the Key combo in the scripts above can be easily changed if you prefer a 4 finger instead of 3 finger gestures.</p><p>But also, if your laptop or vendor trackpad is different, you'll have to use AHK to find out the appropriate key combo to put in the script instead.<br /></p><p><br /></p><p><b>References</b><br /></p><p>[1] <a href="https://medium.com/@dakshin.k1/enable-3-finger-gesture-for-click-and-drag-on-windows-and-linux-cd7165b66851" target="_blank">Enable 3 Finger Gesture for click and drag on Windows and Linux</a></p><p>[2] <a href="https://stackoverflow.com/a/65307232" target="_blank">AutoHotKey - Three finger dragging script causing minor issue, how to fix?</a></p><p>[3] <a href="https://www.maketecheasier.com/schedule-autohotkey-startup-windows/" target="_blank"> How to Schedule AutoHotKey to Start Up with Windows</a><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com4tag:blogger.com,1999:blog-713602603894920874.post-50248732386421001862021-01-27T19:09:00.124-08:002021-01-27T19:09:08.019-08:00How to disable Lenovo Fn-Tab Magnifier Hotkey<p>Lenovo makes some great laptops, like their ThinkPad T series.</p><p>But who's brilliant idea was it to "hard" wire the Fn-Tab key combo at a low level to activate the Windows Magnifier?</p><p>This annoying behaviour can't be remapped away with AutoHotKeys.</p><p>Lenovo's Vantage program calls them Hidden Keyboard Functions. They're aware some people have a tendency to mistype Fn for Ctrl, so they offer a "Fn and Ctrl key swap" option instead.</p><p><b>Two ways to disable Fn-Tab Magnifier behaviour</b><br /></p><p><b>(1) Disable permanently by changing the Magnify app's name</b><br /></p><p>You can take file ownership of the Magnifier app, then change it's name from Magnify.exe to something else (e.g. Magnify.exe.bu as a backup).</p><p>That way, Fn-Tab can't find the Magnify app!</p><p>But Windows's own key combo won't find it either! Congrats, you've disabled the Magnify hotkey permanently.</p><p>Detailed instructions can be found elsewhere [2] labelled as "method 2" (different than my # 2 below).</p><p>I don't like this method because I still want the Windows hotkey to bring up the Magnifier.<br /></p><p><b>(2) Disable only the Fn-Tab hotkey</b></p><p>Inspired by a similar question from way way back [3], I found out the Fn-Tab hotkey will open any app who's path is entered into a specific Windows Registry entry!</p><p>Specifically, this Registry entry:<br /></p><p style="margin-left: 40px; text-align: left;">HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\ShortcutKey\AppLaunch\Ex_13\UIAccess<br /></p><p>The key name "File" by default has the data value:</p><p style="margin-left: 40px; text-align: left;">%SystemRoot%\system32\magnify.exe<br /></p><p>Well if you change that to:</p><p style="margin-left: 40px; text-align: left;">%SystemRoot%\system32\magnify.exe.bak</p><p>Then Fn-Tab won't find the magnify app and won't do anything! In fact, you should be able to make Fn-Tab launch any app you want using this technique!</p><p>If you're trusting and lazy, and want an easy way to enable or disable the Lenovo Fn-Tab behaviour, save the following into text files and change the file extension to <b>.reg</b> so that you can double click the file to make the above registry edit for you:</p><p><b>EnableLenovoFnTabMagnify.reg</b></p>
<code><pre>Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\ShortcutKey\AppLaunch\Ex_13\UIAccess]
"File"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
61,00,67,00,6e,00,69,00,66,00,79,00,2e,00,65,00,78,00,65,00,00,00
"Parameters"=""
</pre></code>
<p><b>DisableLenovoFnTabMagnify.reg</b><br /></p>
<code><pre>Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\ShortcutKey\AppLaunch\Ex_13\UIAccess]
"File"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,\
61,00,67,00,6e,00,69,00,66,00,79,00,2e,00,65,00,78,00,65,00,2e,00,62,00,61,\
00,6b,00,00,00
"Parameters"=""
</pre></code>
<p><br /></p><p><br /></p><p><b>References</b><br /></p><p>[1] <a href="https://forums.lenovo.com/t5/ThinkPad-X-Series-Laptops/Fn-TAB-brings-up-Magnifier/m-p/4405553?page=1#4564296" target="_blank">Fn-TAB brings up Magnifier</a></p><p>[2] <a href="https://www.top-password.com/blog/turn-off-disable-magnifier-in-windows-10/" target="_blank">3 Ways to Turn Off / Disable Magnifier in Windows 10</a></p><p>[3] <a href="https://www.eehelp.com/question/full-of-thinkpad-fn-spacebar-screen-magnifier/" target="_blank">Full of ThinkPad (Fn + SPACEBAR) screen magnifier</a><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com2tag:blogger.com,1999:blog-713602603894920874.post-90133961425192265272021-01-20T15:40:00.043-08:002021-03-26T20:51:59.940-07:00Remap one key to another in Windows, like Capslock to Control<p>There's three options to consider for remapping keys on Windows.</p><p><b>(1) Manually edit the Windows Registry</b> <br /></p><p>You can directly edit the Windows registry to remap keys, for example to <a href="https://superuser.com/a/949533" target="_blank">Map capslock to control</a>. You'll need to know the keyboard hex scan codes involved though.<br /></p><p><b>(2) Edit the Windows Registry with SharpKeys</b><br /></p><p>If you have many keys to remap, or don't want to manually mess with the registry, there's an App for that! <a href="https://github.com/randyrants/sharpkeys" target="_blank">SharpKeys</a> looks pretty good. You can use it to remap the Right Alt to the Left Windows key for example.</p><p><b>(3) Don't edit the Registry but run a background app like PT or AHK</b><br /></p><p>Some common remappings like Capslock to control can be easily done without editing the registry at all! You can run an app that stays in the background, listening for the keys you want changed, then they'll inject the key you want for it to change to.<br /></p><p>Microsoft's <a href="https://github.com/microsoft/PowerToys" target="_blank">PowerToys</a> has a module for that sort of usage, and it comes with other toys like advanced file name changer, etc. The kind of key remapping allowed is extremely limited though.<br /></p><p> Another option is <a href="https://www.autohotkey.com/" target="_blank">AutoHotKey</a> (AHK). It'll give you extreme customization beyond remapping a single key to a single key. It'll let you script keys and combos to do pretty much arbitrary things to the keyboard and mouse.</p><p>Don't run both PowerToys keyboard remapping module <i>and</i> AHK key remappings together as they may interfere with each other!</p><p>(<i><b>NEW!</b></i>) Check out <a href="https://github.com/rbreaves/kinto" target="_blank">kinto</a> if you're interested in mac-style hotkeys on Linux and Windows!</p><p> <br /></p><p><b>Remap Capslock to Control with AutoHotKey</b></p><p>Make a text file and copy the script below into it, then save the text file with a <b>.ahk</b> file extension. Double click the .ahk script file and AutoHotKey will run it to give you this 3FTD behaviour.<br /><br />If you want the script to run every time you log in to Windows, you'll need to move the script or add a shortcut to it into the Windows startup folder. See <a href="https://www.maketecheasier.com/schedule-autohotkey-startup-windows/" target="_blank">detailed instructions</a> for that. <br /></p><p><b>CapslockAsControl.ahk</b></p>
<code><pre>#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
Capslock::Ctrl
</pre></code>
<p><br /></p><p><br /></p><h1 style="text-align: left;"><b>Limitations to all methods<br /></b></h1><p><b>Some Windows hotkeys cannot be remapped!</b></p><p>Key combos like Windows key + L are dealt with by the Windows OS at a much lower level and treated specially. Those cannot be remapped by PowerToys or AHK, at least not normally or usefully.</p><p>You could disable Win+L completely by disabling the Windows lock screen function [1]. But then your computer will never lock... ever. Not when waking from sleep, not from the Control + Alt + Delete menu. It's all or nothing.</p><p><b>Some apps don't allow / respect the remapping</b>s<br /></p><p>Also apps that access the keyboard at a lower level, like some games and VirtualBox, don't play nice with AHK remappings.</p><p>Games access keyboards in a way that reduces latency to increase gaming responsiveness. And some games have anti-scripting functionality to discourage cheating.</p><p>VirtualBox is virtualizing your PC for another OS so a Windows background app messing with the keyboard of course won't play nice with VirtualBox. And yes, Win+L will lock Windows even if you're inside a Linux guest in VirtualBox!</p><p><b>Vendor hotkeys can't be remapped</b><br /></p><p>There are vendor specific keys and combos that your PC maker may have added via their keyboard drivers. Like Lenovo's Fn+Tab starts the Windows magnifier key combo. Press that while in a VirtualBox guest OS and it'll still run the magnifier!</p><p>Neither AHK nor PowerToys can remap the Fn+Tab combo either. In fact, remapping the Fn key is usually tough if not impossible. It's something handled specially by vendor's drivers on laptops to provide special functionality.<br /></p><p><b> </b></p><p><b> </b></p><h1 style="text-align: left;"><b>Compared to Macs</b> <br /></h1><p><b>Scripting with AppleScript</b> <br /></p><p>Coming from the Mac world where <a href="https://en.wikipedia.org/wiki/AppleScript" target="_blank">AppleScript</a> lets you implement customized and scripted automation of tasks, AutoHotKey (AHK) is similar in many ways. Since AppleScript can be substituted with JavaScript, then the scripting language itself is better than AHK.<br /></p><p>However, AppleScript doesn't provide hooks to customize or remap keys and key combos, so AHK does have this feature AppleScript doesn't.</p><p>On the flip side, Mac apps that make extensive use of Apple's <a href="https://en.wikipedia.org/wiki/AppleScript#Open_Scripting_Architecture" target="_blank">Open Scripting Architecture</a> allow AppleScripts to directly access certain data inside those apps for better integration. Not every or many apps support advanced OSA usage, but it gives AppleScript an edge.<br /></p><p><b>Remapping with Karabiner</b> <br /></p><p>As for providing key and combo remapping, I'm finding <a href="https://karabiner-elements.pqrs.org/" target="_blank">Karabiner-Elements</a> on Macs to be better for that job than AHK.</p><p>Karabiner is more intuitive, purpose built for remapping keys, with many of the same AHK features for multi-key remapping. It can also run scripts on key triggers like AHK, so Karabiner + AppleScript is roughly equivalent to AHK's functionality.</p><p><b>Less limitations</b> <br /></p><p>Macs have less limitations than Windows on the key remapping front too. You'll have no problems using Karabiner-Elements to remap the "Apple key" (command key) vs the difficulties of remapping the Windows key (especially special combos like Win+L).</p><p>Key remappings with Karabiner on Macs are also respected by VirtualBox unlike remappings done via AHK on Windows. To be fair, some AHK key remappings do work with VirtualBox, but I had trouble with modifier keys and special Windows hotkeys.</p><p><br /></p><p><b>References</b></p><p>[1] <a href="https://www.faqforge.com/windows/windows-10/how-to-disable-windows-10-workstation-lock-window-l-functionality/" target="_blank">How to disable Windows 10 Workstation Lock (Window + L) Functionality</a></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-17222814050223959772021-01-12T19:24:00.004-08:002021-01-12T19:24:01.273-08:00My app uses only java.base, but actually jdeps missed the jdk.crypto.cryptoki module!<p>I was building a small app and I purposely used only the <b>java.base</b> module. That way when I build a custom Java Runtime for it, I can build the smallest possible runtime with <i>jlink</i>.<br /></p><p>Java's <i>jdeps</i> lets you know which module your app depends on, and it said my app only uses the <i>java.base</i> module. </p><p>Build the runtime with <i>jlink</i> and run my app with it and <i>oops</i>, an error having to do with <i>cryptoki</i>.</p><p>Turns out <i>jdeps</i> made a mistake and did not identify the <b>jdk.crypto.cryptoki</b> module!</p><p>I suspect my use of the <b>java.net.URI</b> class was to blame, as it was used to access an <i>https</i> URL.<br /></p><p>Anyway, if you purposely depend only on the <b>java.base</b> module, but also use the <b>URI</b> class, note that it may actually also depend on the <a href="https://docs.oracle.com/javase/9/docs/api/jdk.crypto.cryptoki-summary.html"><b>jdk.crypto.cryptoki</b></a> module!</p><p><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-18232706336796923362021-01-06T19:02:00.002-08:002021-01-06T19:02:04.385-08:00Build your own custom Java Runtime with jlink and jdeps<p>Since Java 9, the way Java programs are supposed to be distributed changed.</p><p>It used to be that users would install a Java Runtime Environment (JRE) on their system. The user then gets the Java app from the app developer. The Java app then runs on the JRE that's installed.</p><p>Some OS like Macs used to even have a "system" JRE installed as part of the OS.</p><p>The world's moved on from that style of app distribution. Nowadays, many users want statically compiled programs, or a single executable file with no dependencies. For better or worse.</p><p>That means when you develop a Java app and want to distribute it, it's on you as the developer to create your own custom Java Runtime and package that runtime together with the rest of your app for distribution.</p><p>The upshot is that if you don't use too much of the Java standard library and customize your Java Runtime, then you pay for only what you use in terms of the size of the Java runtime you need to package with your app.</p><p>You can find what Java modules your app depends on using <b>jdeps</b> easily: <code>jdeps my.jar</code></p><p>Then you can use <b>jlink</b> to create the Java Runtime your app needs: <code>jlink --output my-custom-runtime --add-modules java.base,and.other.modules</code></p><p>Then you can run your app with the custom Java Runtime: <code>/path/to/my-custom-runtime/bin/java -jar my.jar</code></p><p>The Java Runtime that <i>jlink</i> creates is specific to the OS platform you ran <i>jlink</i> on. So on Windows, you'll have to substitute <i>java.exe</i> for <i>java</i> in the path above.</p><p>There's a way to cross-compile a Java Runtime for a different OS platform with <i>jlink</i>, but you'll need to download the target platform's JDK. It was easier to run the target platform's OS in a virtual machine and run <i>jlink</i> on it instead.</p><p>A thorough and detailed tutorial is <a href="https://www.devdungeon.com/content/how-create-java-runtime-images-jlink" target="_blank">How to Create Java Runtime Images with jlink</a>.<br /></p><p><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-1718377672575546862020-12-30T17:00:00.000-08:002020-12-30T17:00:06.522-08:00How to reduce PDF file size on Macs and Linux?<p> Of the <a href="https://askubuntu.com/a/113547" target="_blank">suggestions</a> I saw, using the <a href="http://www.alfredklomp.com/programming/shrinkpdf/" target="_blank">"shrink PDF" script files with Ghostscript</a> was the best.</p><p>Install Ghostscript first. On Linux, <code>apt install ghostscript</code> or on Macs using homebrew, <code>brew install ghostscript</code>.</p><p>Save that shrink PDF script into a <code>shrinkpdf.sh</code> file. Make sure to <code>chmod u+x shrinkpdf.sh</code> to allow it to execute.</p><p>Then use it, <code>/path/to/shrinkpdf.sh in.pdf out.pdf</code>.</p><p>On my old Mac running Sierra macOS 10.12, Ghostscript had trouble running because the way brew built it, <a href="https://stackoverflow.com/q/56609227" target="_blank">Ghostscript was looking for the libXt.6.dylib library in the wrong place</a>.</p><p>You need <a href="https://www.xquartz.org/" target="_blank">XQuartz</a> installed first. But XQuartz installs X11 libraries into <code>/opt/X11</code>. But Ghostscript looks for X11 libraries in <code>/usr/X11</code>.</p><p>Easy fix? Symlink the X11 directory to where Ghostscript expects it.</p><p>Go to where Ghostscript looks for X11: <code>cd /usr</code></p><p>Then symlink to where the X11 libraries actually are: <code>sudo ln -s /opt/X11</code>.</p><p>Done.<br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-68423866393571922692020-12-23T14:10:00.007-08:002020-12-23T14:10:39.342-08:00Why upgrade past Java 8?<p>What reasons are there to use Java versions newer than Java 8 (JDK 1.8)? <br /></p><p>I'll give two: (1) security, and (2) great new features! Let me explain.<br /><br /><b>(1) security</b><br /><br />The last "major release" of Java was Java 9. The <a href="https://blogs.oracle.com/java-platform-group/update-and-faq-on-the-java-se-release-cadence" target="_blank">Java upgrade cadence</a> changed at that point. They're now on a steady stream of "feature releases" model. Kind of like how there's no major release of Chrome, Firefox, or Windows 10 nowadays... it's just a stream of feature releases. Java's cadence is 6 months, so about every 6 months, they ship and bump the version number. JDK 15 was released not long ago.<br /><br />So who cares? Well only the current release (JDK15 as of this writing) gets proper maintenance and security updates for free.<br /><br />Note "for free". Certainly some software development shops will stick with old JDKs, but they might have good reasons and good mitigation for using old JDKs. Good reasons like certain customers are stuck (for whatever reason) with old JDKs, or vendors of certain dependencies they need are stuck with old JDKs.<br /><br />Good mitigations include... paying for paid Long Term Support versions of Java from a JDK vendor. E.g. it looks like Azul offers a JDK 8 LTS, although the current LTS from any vendor is JDK 11. The next LTS is JDK 17 scheduled for September 2021 (because of the stream of feature releases model, JDK 12 thru 16 are relatively small feature upgrades, hence the gap between the LTS versions).<br /><br />You can even use the "free LTS" versions if you want to download those binaries from Oracle, Red hat, or Azul etc., just don't expect actual support without paying! Mostly they backport security fixes from current version to the latest LTS version, and provide real support for paying JDK LTS customers. So "free LTS" builds aren't really fully supported for free. If you must use an LTS release, at least use the latest one (that's JDK 11).<br /><br />But really, for free security and maintenance, you should just use the latest version. It's no different from Chrome or Firefox... you should always use the latest to avoid security vulnerabilities.<br /><br />As for which vendor to choose from? There's Oracle, Red hat, Azul, Amazon Corretto, AdoptOpenJDK, etc. But they're all built from the same OpenJDK from Oracle, even Oracle's JDK, and they contribute back upstream to OpenJDK. If you want a slick downloads page and easy installers, AdoptOpenJDK and Azul looks pretty ok.<br /><br /><br /><b>(2) great new features</b><br /><br />Java has a lot of great features in newer releases. These features aren't just for looks, they bring life back into Java. I know... "kids these days"... always wanting</p><ul style="text-align: left;"><li>type inference --- like in Swift, C#, etc</li><li>lambdas --- like in lisp, C++11, JavaScript, etc.</li><li>async --- like in JavaScript, rust, etc</li><li>better garbage collectors --- like Go</li></ul><p>But those language features are, rightly or wrongly, table stakes to be considered an up-to-date language nowadays. Even modern C++ has type inference and async, and smart pointers with garbage collection (reference counted).<br /><br />So...</p><ul style="text-align: left;"><li>Java 8 has lambdas</li><li>Java 10 has type inference (use <i>var</i>)</li><li>I believe Java 16 will have virtual threads (Java's better answer to async) from Project Loom</li><li>Java 15 has better garbage collectors (by some metrics), and in fact multiple GCs to choose from for different use-cases: Shenandoah, ZGC, and G1 (admittedly, only more advanced development might care about GC performance)</li><li>There's multiline text blocks since Java 15, finally</li><li>There's extended switch expressions that can yield values since Java 14</li><li>and also a safer switch statement/expression using "arrow case" labels instead of "colon case" labels since Java 14</li><li>Java 9 introduced JShell, which is fantastic to be able to use a REPL to test out Java code<br /></li></ul><p>There's so much to get excited about! There's a joke about Java being the new Cobol. But not anymore with features that bring it parity with other languages.<br /> <br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-54526044908310253042020-10-21T21:32:00.001-07:002020-10-21T21:32:05.790-07:00Quickly Open source code file location in OS's file browser from Netbeans<p>Want to open the file system browser to the location of a file or folder from Netbeans?</p><p>Easy, use the QuickOpener plugin. Such a basic functionality requires a plugin, whereas it's built in in VS Code, but there it is.</p><p><a href="http://plugins.netbeans.org/plugin/43217/quickopener" target="_blank">Not the old QuickOpener</a> that's been <a href="https://github.com/dzsessona/QuickOpener-NetBeans" target="_blank">abandoned</a>.</p><p>Use the <a href="http://plugins.netbeans.org/plugin/62668/quickopener" target="_blank">new QuickOpener</a> that's the <a href="https://github.com/Chris2011/QuickOpener-NetBeans" target="_blank">fork of the old</a> one (it's a <a href="https://github.com/dzsessona/QuickOpener-NetBeans/issues/92" target="_blank">friendly fork</a>).</p><p>It works with Apache Netbeans, and can be found in the Netbeans plugin search area at least up to version 11.</p><p>For Netbeans version 12, you'll need to download the NBM plugin file from the online page of the <a href="http://plugins.netbeans.org/plugin/62668/quickopener" target="_blank">new QuickOpener</a>, then install it in Netbeans from the downloaded NBM file. It worked for me in basic testing, so it should work fine.</p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-56558491364788616652020-10-11T20:24:00.007-07:002020-12-23T15:01:52.381-08:00LibreOffice's multiFormatSave extension is broken again<p><a href="https://github.com/ertaiNL/multiFormatSave/issues/9" target="_blank"><i><b>multiFormatSave broken as GlobalScope.DialogLibraries.isLibraryLoaded(EXTENSION_NAME) not working</b></i></a><br />
<br />I've talked about this <a href="http://blog.carsoncheng.ca/2020/02/libreoffices-multiformatsave-extension.html" target="_blank">before and the workaround</a>. It's been fixed but it broke for me again. It was easy to fix this time though:</p><p>Quit LibreOffice, then just delete <code>~/.config/libreoffice/4/user/basic/dialog.xlc</code>.</p><p></p><p>Done.</p><p><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-45782943258942595462020-09-23T21:19:00.001-07:002020-09-23T21:19:23.039-07:00synaptic doesn't run after entering password in GUI<p>Clicking on synaptic (which runs <i>synaptic-pkexec</i>), I can enter my password in the "sudo" (gksu?) window, but then synaptic GUI doesn't actually appear. I'm on Debian buster and LXDE.</p><p>Synaptic runs fine from the terminal (via <i>sudo synaptic</i>)!</p><p>Turns out I needed to install the <b><i>policykit-1-gnome</i></b> package.</p><p>It's the same issue as described in <a href="https://askubuntu.com/a/162557" target="_blank">pkexec won't launch polkit GUI in Lubuntu / LXDE</a> but on Debian. I have no idea why <i>policykit-1-gnome</i> isn't marked as a dependency for LXDE but it is.</p><p><br /></p>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-21184380399094076742020-06-30T22:57:00.003-07:002020-06-30T22:59:55.426-07:00Stop Netbeans downloading whole 1GB maven index<div>Netbeans for Java programming with Maven likes to download the Maven index that's over 1 GB in size.</div><div><br /></div><div>There's basically three ways to stop that huge download for 3 different situations:<br /></div><div><br /></div><div><b>(1) Temporarily don't want auto updates</b><br /></div><div><br /></div><div>If you already downloaded the index, the updates are smaller but still sizable. One way to to stop it re-downloading the updates is to go to:</div><div><br /></div><div style="margin-left: 40px; text-align: left;">Tools <b>></b> Options <b>></b> Java <b>></b> Maven <b>></b> Index <b>></b> Index update frequency <b>></b> <i>set to</i> never.</div><div><br /></div><div>Then click "Index Now" in that window only whenever you want an update.</div><div><br /></div><div><b>(2) Just don't want Maven at all</b><br /></div><div><br /></div><div>If you don't have the index downloaded yet (e.g. a new install) and basically never want to use Maven, then in that same window, you could instead check off:</div><div><br /></div><div style="margin-left: 40px; text-align: left;">Completely disable indexing</div><div><br /></div><div>As it warns you, lots of features will be disabled, but if you're not using Maven, who cares?</div><div><br /></div><div><b>(3) Want Maven index without the download</b></div><div><br /></div><div>This is amazing, there's this plugin you should get and it'll solve this problem: <a href="http://plugins.netbeans.org/plugin/68415/maven-remote-search" target="_blank">Maven Remote Search plugin</a>.</div><div><br /></div><div>It's old and it says it's for Netbeans 8.2 (the super old Oracle version), but I tried it out and <b>it works for the new Apache Netbeans 11 and 12</b>!</div><div><br /></div><div>It lets you search the Maven index online rather than downloading the whole index to your local disk (which is crazy).</div><div><br /></div><div>The github <a href="https://github.com/emilianbold/maven.search.remote" target="_blank">repo</a> for the plugin is active recently with a historical build, so hopefully it'll get its version bumped and put on the Apache Netbeans plugins web page (which I don't think exists yet...).</div><div><br /></div><div><br /></div><div><b>Bibliography</b>:</div><div><ol style="text-align: left;"><li><a href="https://blogs.oracle.com/geertjan/configure-maven-indexing-on-demand-in-netbeans-ide" target="_blank">Configure Maven Indexing On Demand in NetBeans IDE</a></li><li><a href="https://stackoverflow.com/questions/35405755/netbeans-keeps-transferring-maven-repository-index-even-though-i-have-disabled/42503290" target="_blank">Netbeans keeps transferring maven repository index, even though I have disabled it</a></li><li><a href="https://jaxenter.com/netbeans/keep-netbeans-nimble-with-maven-remote-search" target="_blank">Keep NetBeans Nimble with Maven Remote Search</a></li><li><a href="http://plugins.netbeans.org/plugin/68415/maven-remote-search" target="_blank">Maven Remote Search - plugin detail</a></li><li><a href="https://github.com/emilianbold/maven.search.remote" target="_blank">Github - emilianbold / maven.search.remote </a><br /></li></ol></div>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com3tag:blogger.com,1999:blog-713602603894920874.post-70465540552045856312020-06-21T02:04:00.003-07:002021-09-30T16:51:01.630-07:00 Migrating to Debian LXQt - great apps, tips and fixes<div></div><div>
I like LXQt and use Lubuntu. I'm trying out Debian LXQt because of...
snap issues. So here's the Debian LXQt edition of my previous Lubuntu
<a href="https://blog.carsoncheng.ca/2020/02/productivity-software-i-like-to-install.html" target="_blank">productivity software</a>
to install and migration
<a href="https://blog.carsoncheng.ca/2019/09/migrating-to-lubuntu-again-tips-and.html" target="_blank">notes</a>. <br /></div><div><br /></div>
<div>
<span style="font-size: x-large;"><b>TL;DR...</b></span><br />
</div>
<div><br /></div>
<div>
After installing the standard
<a href="https://www.debian.org/devel/debian-installer/" target="_blank">Debian testing distribution</a>
(currently bullseye), I like to:<br />
</div>
<div>
<br />
<code># for building some kernel modules</code>
<br />
<code>sudo apt-get install build-essential dkms linux-headers-$(uname -r)</code>
<br />
<br />
<code># enable contrib and non-free repos</code>
<br />
<code><code>sudo </code>sed -ri 's/^(deb.*main)$/\1 contrib non-free/' /etc/apt/sources.list</code>
<br />
<code><code>sudo </code>apt-get update</code>
<br />
<code><code>sudo </code>apt-get upgrade</code>
</div>
<br />
<code># productivity software I like (note nomacs is in Debian unstable repository)</code>
<br />
<code><code>sudo </code>apt-get install chrony file-roller xournal evince nomacs
graphicsmagick ghostwriter emacs gimp gimp-plugin-registry gimp-gmic
default-jdk gcc make ttf-mscorefonts-installer ruby vlc </code><code><code></code>libsecret-1-0
libsecret-1-dev keynav </code><code><code></code><code><code>gedit </code></code>restic rename git gitk git-gui<br /><br />
# enable libsecret for git
<br /></code><code><code>sudo </code>make --directory=/usr/share/doc/git/contrib/credential/libsecret<br />git
config --global credential.helper
/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret</code><br />
<div><code><br /></code></div><div><code>
# because where I am, it's hard to contact a time server except Apple's...
</code></div><div><code></code></div><code>
echo 'server time.apple.com iburst' >> /etc/chrony/chrony.conf
</code><br />
<div><br /><code></code></div><div><code>
# make an icon for GraphicsMagic<br /></code></div><div><code>cat > ~/.local/share/applications/GraphicsMagic\ display.desktop << EOM<br />
[Desktop Entry]<br />
Encoding=UTF-8<br />
Name=GraphicsMagick display<br />
Comment=GraphicsMagick display<br />
Exec=/usr/bin/gm display %F<br />
Icon=lximage-qt<br />
Categories=Graphics;Viewer;RasterGraphics;2DGraphics;Photography;<br />
Type=Application<br />
MimeType=image/jpeg<br />
Terminal=false<br />
EOM<br />
</code></div>
<div>
<code><br /></code></div><div><code># install aws-cli 2 using
<a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html" target="_blank">curl,unzip,install</a>, like this:<br /></code>
</div>
<div>
<code>
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o
"awscliv2.zip"</code>
</div>
<div><code></code></div>
<code>
unzip awscliv2.zip<br />
sudo ./aws/install</code><code></code><br /><br />
<b>Note</b>: <i>ttf-mscorefonts-installer</i> might require user interaction to
install, so don't walk away from it overnight thinking everything will be done
by morning.<br />
<br /><div>
Then install <a href="#by-hand">by hand</a> VS Code, Chrome, Netbeans, and LibreOffice
dictionaries and plugins etc.</div><div><br /></div><div>Then set up <a href="#screen-saver">screen saver and lock screens</a>.</div><div><br /></div><div>Finally, also set up <a href="#file-compress">file-roller integration</a>.<br /></div>
<div></div>
<div><br /></div><div><br /></div>
<span style="font-size: x-large;"><b>Software to Download and Install by Hand<a href="#" id="by-hand" name="by-hand"></a></b></span><br />
<br />
The default package manager using the default Debian software sources (testing channel) are pretty
good at keeping up with the versions. I like doing that most of the time
to reduce on maintenance.<br />
<br />
Some things are worth the manual install though.<br />
<br />
1.
<a href="https://www.libreoffice.org/download/download/" target="_blank">LibreOffice</a> needs some extensions, dictionaries, and settings:<br />
<ul>
<li>
an extension I rely on a lot:
<a href="https://extensions.libreoffice.org/extensions/multisave-1" target="_blank">MultiFormatSave</a>. Let's you save a document to multiple formats <i>at the same time</i>, great
for archival compatibility.<br /><br />
</li>
<li>it needs a dictionary for spell checking! For English,
these
<a href="https://extensions.libreoffice.org/extensions/english-dictionaries" target="_blank">dictionaries from LibreOffice</a> are good.<br /><br /><br />
</li>
<li>this setting is essential to
<a href="https://ask.libreoffice.org/en/question/30702/can-i-supress-the-images-on-the-start-screen/?answer=30703#post-id-30703" target="_blank">prevent previews of recent documents on the start screen</a>, which is quite a privacy blunder:
</li>
<ul>
<li>
<i>Tools</i> menu <b>></b> <i>Options</i> <b>></b> <i>LibreOffice</i> <b>></b> <i>Advanced</i> <b>></b> Open <i>Expert
Configuration</i> <b>></b> Search for <i>RecentDocsThumbnail</i> property <b>></b>
toggle to <i>false</i>.
<br /><br /></li>
</ul>
</ul>
2. <a href="https://www.google.ca/chrome/" target="_blank">Google Chrome</a> is
self-updating. I prefer Firefox, which is installed by default, but sometimes you need Chrome.<br /><br />
<br />
3.
<a href="https://netbeans.apache.org/download/index.html" target="_blank">Apache NetBeans</a>. This requires as a dependency the Java JDK at least version 8.<br />
<ul>
<li>
So use muon to install the <b>default-jdk</b> because the default is version
11, which works fine so far.<br /><br />
</li>
<li>
And get the
<a href="http://plugins.netbeans.org/plugin/68415/maven-remote-search" target="_blank">"Maven Remote Search" plugin</a>
before Netbeans starts downloading and extracting the maven index that's
apparently more than 1 GB in size (froze my computer since I have very
little disk space...).
<br /><br /></li>
</ul>
4.
<a href="https://code.visualstudio.com/" target="_blank">VS Code</a>.<br />
<ul>
<li>Get it via <code>
<a href="https://code.visualstudio.com/Download" target="_blank">deb download and install</a></code></li>
</ul>
<ul></ul>
<br />
<span style="font-size: x-large;"><b>Screen Saver Lock Screen Madness<a href="#" id="screen-saver" name="screen-saver"></a></b></span><br />
<br />It's madness, there are at least 3 places to set the screen saver / lock screen / sleep
settings:<br />
<ol>
<li>Preferences <b>></b> LXQt Settings <b>></b> Session Settings</li>
<li>Preferences <b>></b> LXQt Settings <b>></b> Power Management</li>
<li>Preferences <b>></b> Screensaver</li>
</ol>
They seem to interact with each other, and each has slightly different settings and
uses.<br />
<br />
My default Screensaver sometimes ran the CPU real hot, so maybe set that to
something less energy intensive first. I used <i>Deco</i> with settings reducing the
framerate.<br />
<br /><div>
I'd suggest using each tool for orthogonal tasks:</div><div><ol style="text-align: left;"><li>use <b>Screensaver</b> purely for setting the screensaver and when it
turns on.<br /><br /></li><li>Set when the screen locks using <b>Power Management</b> (Idle tab).<br /><br /></li><li>Use the <b>Session Settings</b> to set whether the screen locks before suspending the
OS (I think it defaults to locking after suspending).<br /></li></ol></div>
<br />
<span style="font-size: x-large;"><b>File compression tool<a href="#" id="file-compress" name="file-compress"></a></b></span><br />
<br /><div>For reasons, I like file-roller. So just install <b>file-roller</b> via apt-get.</div><div><br /></div><div>The default file explorer <i>PCManFM-Qt</i> has a preferences
option to integrate with file-roller instead as well for ease of use.</div><div><br /></div>
<br />
<hr />
<div><br /></div><div><font size="6"><b>Explanation of certain software choices</b></font><br /></div>
<div><br /></div><div><br /></div><div><span style="font-size: x-large;"><b>Basic graphics editing</b></span><br />
<br />
The default graphics viewer LXImage is actually a bit of a pain to use,
especially coming from Mac Preview, which really has a great mix of UI, UX, and
editing features for graphics <i>and</i> PDFs...<br />
<br />
There's no equivalent to Apple's Preview, but for graphic files,
<a href="https://nomacs.org/" target="_blank"><b>nomacs</b> Image Lounge</a> is
pretty good. nomacs has a UI UX reminiscent of Preview, and has some basic
graphics editing features too. </div><div><br /></div><div><br />
<span style="font-size: x-large;"><b>Little more graphics editing features</b></span><br />
<br />
The default graphics viewer LXImage has some annotation tools, I guess, but
nothing more. nomacs has some more graphics editing features, but I sure
miss the Mac Preview tool.<br />
<br />
Anyway, ImageMagick or the more updated <b>GraphicsMagick</b> fork is quite
useful (but beware it has a very... historic?... dated?... GUI). It can be
installed via apt-get, but it doesn't seem to install a
default app launcher icon --- well, it's meant to be used from the terminal, but
I like to deal with the GUI.<br />
<br />
So I added a blank file to <i>~/.local/share/applications</i> called "<i>GraphicsMagic display.desktop"</i>
with the following text saved to it:<br />
<br />
<code>
[Desktop Entry]<br />Encoding=UTF-8<br />Name=GraphicsMagick display<br />Comment=GraphicsMagick
display<br />Exec=/usr/bin/gm display %F<br />Icon=lximage-qt<br />Categories=Graphics;Viewer;RasterGraphics;2DGraphics;Photography;<br />Type=Application<br />MimeType=image/jpeg<br />Terminal=false</code>
<br /><div><br /></div><div>
Now you can use it like LXImage (in fact, it uses the LXImage icon because, why
not?).</div>
<br />
If I need more intensive graphics editing, I'll use GIMP.<br />
<div><br /></div><div><br />
<span style="font-size: x-large;"><b>Time Clock Auto Update Synchronization Problem</b></span><br />
<br />Debian looks to use <code>timedatectl</code> by default for setting time,
including synchronization via NTP Network Time Protocol. It doesn't allow me to force a sync though.<br />
<br />You could instead use <b>chrony</b>.<br />
<br />It lets you do things like <code>chronyc sources</code> to see the currently
available and selected time sources. Perhaps your network is blocking NTP
updates?<br />
<br />
Or <code>chronyc sourcestats</code> to see your clock's time offset from the
various NTP sources.<br />
<br />
You could do a single time offset check, without setting the time:
<code>sudo chronyd -Q</code><br />
<br />
Or manually force a time synchronization with: <code>sudo chronyd -q</code><br />
<br /><div>
Oh, and I like to add to <code>/etc/chrony/chrony.conf</code> :
<code>server time.apple.com iburst</code> because where I am it's hard to get to a
time server except Apple's.</div><div><br /></div><div><font size="2"><i>See also: <a href="https://vitux.com/keep-your-clock-sync-with-internet-time-servers-in-ubuntu/" target="_blank">Keep Your Clock Sync with Internet Time Servers in Ubuntu 18.04</a> and Ubuntu Docs on
<a href="https://help.ubuntu.com/lts/serverguide/NTP.html" target="_blank">Time Synchronization</a>.</i></font></div>
</div></div><div><br /></div><div><br /></div><div>
<span style="font-size: x-large;"><b>Microsoft Fonts</b></span><br />
<br />
Install <b>ttf-mscorefonts-installer</b>. Some
<a href="https://www.ostechnix.com/install-microsoft-windows-fonts-ubuntu-16-04/" target="_blank">instructions</a>
for this but it's straightforward from the package manager. Just use
<code>sudo apt install ttf-mscorefonts-installer</code>.<br />
<br />
</div><div><br /></div><div><br /></div><div><span style="font-size: x-large;"><b>Markdown editor</b></span><br />
<br />
I like
<b><a href="https://wereturtle.github.io/ghostwriter/" target="_blank">Ghostwriter</a></b>
so far.
</div>
<div><br /></div><div><br /></div>
<span style="font-size: x-large;"><b>Backup</b></span><br />
<br />
For file backup,
<a href="https://restic.net/" target="_blank"><b>restic</b></a> looks great. Some people like <a href="https://borgbackup.readthedocs.io/en/stable/" target="_blank">borg.</a><br />
<br />
<br />
<span style="font-size: x-large;"><b>Remember Git passwords securely</b></span><br />
<br />
Git is great.
<a href="https://blog.carsoncheng.ca/2020/03/remember-git-passwords-securely.html" target="_blank">Remember Git passwords securely</a>
is even better, but requires manual install though.<br />
<div><br /></div>
<div><br /></div>
<span style="font-size: x-large;"><b>Misc</b></span><br />
<br />
<a href="https://github.com/jordansissel/keynav" target="_blank">keynav</a> --- Didn't have it in Lubuntu, but it exists for Debian!!!!<br />
<br />
<div><a href="https://github.com/richardgv/skippy-xd" target="_blank">skippy-xd</a> --- It hasn't been updated and doesn't work anymore for Lubuntu (OpenBox, LXQt). Debian LXQt uses Xfwm though, so somewhat similar functionality is already built in!</div><div><br /></div>
<span></span>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-25682009421783033112020-04-29T06:00:00.000-07:002020-04-29T06:00:01.798-07:00What is the best Linux terminal emulator?<i>(Or: Why doesn't Lubuntu PCManFM-Qt's "Execute in Terminal" work?"</i><br />
<br />
Gnome-terminal is the best.<br />
<br />
Admittedly, the only other ones I've tried are Sakura, QTerminal, and XTerm.<br />
<br />
But hear me out.<br />
<br />
Gnome-terminal is the only one that handles executing command arguments <i>with spaces</i> properly, like XTerm does.<br />
<br />
I only say Gnome-terminal is better than XTerm because XTerm is a little too old school for me.<br />
<br />
<br />
<b>The problem with QTerminal</b><br />
<br />
If you run:<br />
<br />
<pre><code>qterminal -e sh "/path/to/Folder Name With Spaces/do stuff.sh"</code></pre>
<br />
QTerminal will screw up on the first space, splitting the string into multiple arguments.<br />
<br />
This is <a href="https://github.com/lxqt/qterminal/issues/335" target="_blank">a known problem from 2017</a>, so I'm <a href="https://github.com/lxqt/qterminal/issues/586#issuecomment-495923694" target="_blank">not holding my breath</a> for it to be fixed. I don't know why, but QTerminal has <a href="https://github.com/lxqt/qterminal/issues/182" target="_blank">other white</a> <a href="https://github.com/lxqt/qterminal/issues/474" target="_blank">space problems</a> too.<br />
<br />
<br />
<b>The problem with Sakura</b> <br />
<br />
Sakura has the exact same problem. If you run:<br />
<br />
<pre><code>sakura -e sh "/path/to/Folder Name With Spaces/do stuff.sh"</code></pre>
<br />
Sakura will screw up, splitting the string into multiple arguments due to the spaces.<br />
<br />
Sakura is better than QTerminal in that it will work if you escape the double-quotes:<br />
<br />
<pre><code>sakura -e sh \"/path/to/Folder Name With Spaces/do stuff.sh\"</code></pre>
<br />
Unfortunately, file managers like PCManFM-Qt does not escape the quotes when it opens a script for you in your terminal.<br />
<br />
<br />
<b>XTerm and Gnome-terminal does it right</b><br />
<br />
Well, the <code>-e</code> option still doesn't work for Gnome-terminal but <a href="https://github.com/lxqt/qterminal/issues/335" target="_blank">I guess it does for XTerm</a>. However, Gnome-terminal has the <code>--</code> option which does work properly!<br />
<br />
This works!<br />
<br />
<pre><code>gnome-terminal -- sh "/path/to/Folder Name With Spaces/do stuff.sh"</code></pre>
<br />
And file managers like PCManFM-Qt does work with it to properly open a script in gnome-terminal, even if the path to the script contains spaces.<br />
<br />
Now go check out <a href="https://blog.carsoncheng.ca/2020/04/changing-default-terminal-in-lubuntu.html" target="_blank">how to change the default terminal in Lubuntu</a>.<br />
<br />bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0tag:blogger.com,1999:blog-713602603894920874.post-14338547236461640912020-04-28T06:00:00.001-07:002020-06-22T17:40:44.183-07:00Changing the default terminal in Lubuntu 20.04<br />
This is terrifically over-complicated.<br />
<br />
I used to just remove <code>lxterminal</code> and symlink <code>gnome-terminal</code> over.<br />
<br />
I'm testing out the "proper" way nowadays. Here's 3 steps to do it:<br />
<br />
<br />
<b>1. PCManFM-Qt</b><br />
<br />
Go to preferences > Advanced > change the Terminal emulator<br />
<br />
<br />
<b>2. Change the global shortcut Ctrl-Alt-T </b><br />
<br />
The GUI way to do it (using LXQt Settings > Shortcut Keys) does NOT work.<br />
<br />
You have to change the <code>~/.config/openbox/lxqt-rc.xml</code> config file (or <code>lxde-rc.xml</code> for older Lubuntu), <a href="https://superuser.com/a/902584" target="_blank">replacing the default qterminal with gnome-terminal</a>.<br />
<br />
<br />
<b>3. Update-alternatives</b><br />
<br />
Also in terminal, select gnome-terminal as prompted after running:<br />
<code></code><br />
<pre><code>sudo update-alternatives --config x-terminal-emulator</code></pre>
<div><code>
</code>
or <br /></div><div style="text-align: left;"><pre>sudo update-alternatives --set x-terminal-emulator /usr/bin/gnome-terminal.wrapper</pre></div>
<br /><div>
<br />
<span style="font-size: x-small;"><b>Bibliography</b> </span><br />
<span style="font-size: x-small;">Doing the above three things is the correct way* to do what's <a href="https://askubuntu.com/a/1124539" target="_blank">suggested here</a> but which has documented the GUI global shortcut change method which doesn't work in Lubuntu 20.04 (and maybe even earlier versions).</span></div>bloggerhttp://www.blogger.com/profile/09586588053165570068noreply@blogger.com0