Gnome Wayland Screenshot tools (2018)

Most screenshot tools broke in Wayland. But luckily the developer community caught up quickly and we have a few functional alternatives.

Besides the native gnome-screenshot tool (which is a bit slow for heavy screenshotters) there are two other functional tools:

(Btw, I’m on Fedora 28, if you’re not, your milage may vary).

Fastest Tool:

If you’re looking for a 1-click thing without annotation, then Gnome-extension Screenshot Tool by oal is your friend.

Useful features include:

  • Configurable to be ‘one click on toolbar’ to make screenshot (Primary button option).
  • Auto copy to clipboard & autosave
  • Area/window/screen
  • Imgur & auto-upload support.
  • Keybindings

screenshot_1112_Jil5Fvi.png

Installation:
1) (If not done so already) Install Gnome extension support for your browser.

2) (If not done so already) Also install the native connector (in addition to browser plugin).

On Fedora: dnf install chrome-gnome-shell

3) Install the extension:

https://extensions.gnome.org/extension/1112/screenshot-tool/

As a note, at time of writing, the area-selection seemed to include a blue overlay. Haven’t found a way around it so I use Flameshot for area screenshots.

Most Feature Rich : Flameshot

ScreenShot_2018-05-09_14:06:26.png

ScreenShot_2018-05-09_14:10:48.png

Features include:

  • Rich annotation tools. (Pencil, arrows, shapes, blurring)
  • Rich set of export tools (copy to clipboard, open in app, save, upload).
  • But missing ‘add text to screenshot’ at the moment (May 2018), which shutter had.

Installation:

Double click on the status-bar icon & (wait for 2-3 seconds) to select area to screenshot.

 

Happy screenshotting!

 

Advertisements

LinkedList descendingIterator run time.

I couldn’t find the run time performance of LinkedList’s descendingIterator(), so I decided to roll up my sleves and investigate.

Theory 1: Linked list has to traverse to the end of the list to get the last node, so run time would be O(n).
Theory 2: Linked list keeps track of the last node and uses it. This would be O(1).

TL;DR; Getting Iterator has O(1) performance.

Reason:

Background: Descending iterator is useful if you want to iterate over a list backwards:


LinkedList myList = new LinkedList(); 
LinkedList myList = new LinkedList(); 
myList.add(1); 
myList.add(2); 
myList.add(3); 
Iterator myDescIter = myList.descendingIterator(); 
while (myDescIter.hasNext()) { 
   System.out.println(myDescIter.next()); 
}

 

I hunted around Java’s source code to investigate.
LinkedList has 2 internal references:

transient Node first;
transient Node last;

But it’s not actually referencing those until you call ‘iter.next()’.
When next() is called, it is redirected to previous();

private class DescendingIterator implements Iterator<E> {
 private final ListItr itr = new ListItr(size());
 public boolean hasNext() {
      return itr.hasPrevious();
 }

Which in turn returns the last node:

</pre>
public E previous() {
....
lastReturned = next = (next == null) ? last : next.prev;   // next == null -&gt; we get 'last'
<pre>

So in Theory 2 is correct, we start form the last node and thus get O(1).

As a side node, if you add a node after getting the iterator, and then use the iterator, you get an  excepiton. So make sure to only get the iterator when you need it!

Eclipse + Flatpak Quick-start guide

Today I’m experimenting with the Eclipse to Flatpak port that our team has been working on.

To do so, I had to learn Flatpak.  It only took 10 minutes to learn the basics needed to survive. I.e adding/listing Flapack repos, installing & removing packages.

Flatpack basics:

  • Flatpak is basically a package management system like yum/dnf/apk-get + version defined container for running gui apps.
  • Flatpak word does not contain a ‘c’. (I was wondering why flatpack could not be found on my system).
  • (Most?) of flatpak can be used via Software Center GUI, but I prefer the command line version as I need to manage repos.
  • The command line has very good tab-completion I’ve litereley figured things out by pressing tab when ever I wonder what argument to type next.
  • Flatpak is already installed on recent Fedora builds, but by default it has no repositories to feed from. You can add the flathub by opening it from here:
    https://flatpak.org/setup/Fedora/
    To verify that you’ve added the repo, you can list repos via:

    flatpak remote-list
    
  • To list available packages:
    flatpak remote-ls
    
  • To install these: (e.g I tested with Zotero)
    flatpak install org.zotero.Zotero
    flatpak install flathub org.zotero.Zotero  #if you want to specify which repo to install from
    
  • To remove a package:
    flatpak uninstall org.zotero.Zotero
    

 

Eclipse in flatpak

Now I went a head and fidlded around with using Eclipse from Flatpak.
Eclipse comes in it’s own repository, as document by Mat Booth.
To set things up:

# Add the 'eclipse' repo. 
flatpak remote-add --if-not-exists eclipse https://fedorapeople.org/~mbooth/flatpak/eclipse.flatpakrepo

# Btw, if you want to delete a repo in the future, it's easy:
flatpak remote-delete eclipse     #again, tab completion is your friend.

# To see what's in Mat's eclipse repo, you can list it's content:
flatpak remote-ls eclipse
  org.eclipse.Committers   # I'm a committer, so I'm gonna go with this version.
  org.eclipse.Cpp 
  org.eclipse.Java 

flatpak install eclipse org.eclipse.Committers  #this asks if you want to install gnome 3.24 run time. Say yes.

Now you can run eclipse either via overviews or via command:

flatpak run org.eclipse.Committers

# or with environment variable:
YOUR_ENV_VAR=VALUE flatpak run org.eclipse.Committers

And voila, Eclipse is up and running:
Eclipse in a flatpak

Also useful:

# look for stuff in your flatpak
flatpak search vlc

# Update packages in the future:
flatpack update

# list what's installed
flatpak list
flatpak list --app #only list apps.

 

References:

Running nightly Eclipse for the impatient

 

Eclipse-Icon.png

If you’re an Eclipse developer, you might consider running a nightly version of Eclipse so that you can easily test out the latest patches. Bleeding edge is the cool stuff right? It’s actually surprisingly quite stable.

The advantage of this setup is that you won’t have to re-download a new version and re-download all the plugins over and over. You just configure the thing once and just click on ‘check for updates’ once in a while.

The setup is a little bit counter intuitive. This article is not just ‘follow these steps’, but more about understanding the mechanism and workflow.

Continue reading