Desktop stacks for Budgie/Nemo?

I found this awesome looking python code on github, I’m not the owner. I can’t tell but it looks … incomplete? https://github.com/SynneK1337/stacks-for-windows-linux
I am not afraid of the tilix terminal - how to make this work?

AND: is this something that might considered as a future desktop applet?

1 Like

Looks very interesting, I don’t know anything at this moment about the Linux ecosystem to program, but if this could be an applet I’m interested.

THIS is might the solution for keeping my family’s desktops cleaner?:

Again, not my code. just looking. I might press my kid/coworker into service here :slight_smile:

I think any of those solutions if they work well would be a candidate for our distro.

I would envisage a right click option on the desktop via a nemo action that will run the app.

If anyone is interested in developing a solution in this area like this then let me know.

oh my goodness: it worked! I copied/saved the script to a text editor and saved it. Reopened it with Python Launcher (icon looks like a blue/yellow rocket ship) and it just flipped the entire contents of the desktop into appropriately named folders. Nothing lost, all organized. (this is me running around the basement like I just won the Olympics) Thank you, internet!

I certainly didn’t write it but I’m just excited it works! NOW, how to make this be a budgie applet? hmmm… more thinking required. I’ll come back to this soon :slight_smile: thanks David

1 Like

more thinking required
The second solution sorts files and stores them into folders, according to their types.
Those folders and types are « hardcoded » in the script. This might be a problem as what you might consider as a document depends of the app’s you use ?
And it might also be a problem for localization/translation.

I mean
⋅ (mime)types should automagicaly be taken from what’s defined system or user side, if possible ?
⋅ names for the folders should be localized according to those family types and date-stamped following localized conventions each time they’re modified, to avoid confusion with classic folders of same name ( Documents, Videos, Pictures ) something like « My videos ( 2020-11-18 ) » or in french « Mes vidéos ( 18-11-2020 ) ».

First solution. Is quite the same actually.
It seems to only apply to Desktop but with ability to stack and unstack.

I put stacks.py folder on my Desktop, marked it executable.

Then

django@ASGARD:/media/DATA/coeurnoir/Bureau$ python stacks.py --stack
  File "stacks.py", line 99
    print(f"{folder_name} not found.")
                                    ^
SyntaxError: invalid syntax

I replace in the script the only one "~/Desktop" occurrence by "~/Bureau" ( french for desktop ). Still same error.

I have zero knowledge in python but

    print(f"{folder_name} not found.")
                                    ^
SyntaxError: invalid syntax

looks like ^ shows where the problem is ? Should it be

print(f"{folder_name}" not found.)

Lol, no :

    print(f"{folder_name}" not found.)
                         ^
SyntaxError: invalid syntax

but the ^ folows the " so I was not totally wrong.

Same ideas as before regarding types, naming and localization
while not constrain it to Desktop by picking the folder path from where user is currently running the « stack ».

( mmm… never use « stack » in your Music folder then - maybe it’s careful to constrain to desktop only )

Hmm… odd. From first glance that syntax is ok assuming you are running on 20.04 or later.

Your assumption is right, running UBudgie 20.04 here.

Here is the full paragraph around line 99

def unstack():
    for folder_name in file_type_by_extension:
        try:
            os.chdir(folder_name)
        except FileNotFoundError:
            print(f"{folder_name} not found.")
        else:
            for file in os.listdir():
                os.rename(file, os.path.join('..', file))
            os.chdir('..')
            os.removedirs(folder_name)
print(f'{folder_name} not found.')

Just wondering if it should be apostrophe rather than quotes

Unfortunately, no.

django@ASGARD:/media/DATA/coeurnoir/Bureau$ python stacks.py --stack
  File "stacks.py", line 99
    print(f'{folder_name} not found.')
                                    ^
SyntaxError: invalid syntax

Ok so I changed
print(f'{folder_name} not found.')
to
print("{folder_name} not found.")
now I’ve got this error

django@ASGARD:/media/DATA/coeurnoir/Bureau$ python stacks.py --stack
Traceback (most recent call last):
  File "stacks.py", line 3, in <module>
    import pathlib
ImportError: No module named pathlib

I take that as a progress :wink:

And changing that line 3 to
from pathlib import Path
like in the other script https://www.geeksforgeeks.org/junk-file-organizer-python/
still gives me

django@ASGARD:/media/DATA/coeurnoir/Bureau$ python stacks.py --stack
Traceback (most recent call last):
  File "stacks.py", line 3, in <module>
    from pathlib import Path
ImportError: No module named pathlib

Does it suggest my system is missing some package regarding python ?

django@ASGARD:~$ dpkg -l | grep python
ii  libpython2-stdlib:amd64               2.7.17-2ubuntu4                         amd64        interactive high-level object-oriented language (Python2)
ii  libpython2.7:amd64                    2.7.18-1~20.04                          amd64        Shared Python runtime library (version 2.7)
ii  libpython2.7-minimal:amd64            2.7.18-1~20.04                          amd64        Minimal subset of the Python language (version 2.7)
ii  libpython2.7-stdlib:amd64             2.7.18-1~20.04                          amd64        Interactive high-level object-oriented language (standard library, version 2.7)
ii  libpython3-stdlib:amd64               3.8.2-0ubuntu2                          amd64        interactive high-level object-oriented language (default python3 version)
ii  libpython3.8:amd64                    3.8.5-1~20.04                           amd64        Shared Python runtime library (version 3.8)
ii  libpython3.8-minimal:amd64            3.8.5-1~20.04                           amd64        Minimal subset of the Python language (version 3.8)
ii  libpython3.8-stdlib:amd64             3.8.5-1~20.04                           amd64        Interactive high-level object-oriented language (standard library, version 3.8)
ii  libreoffice-script-provider-python    1:6.4.7-0ubuntu0.20.04.1~lo1            all          Python script support provider for LibreOffice scripting framework
ii  nemo-python                           4.4.0-3                                 amd64        Python bindings for nemo components
ii  python-apt-common                     2.0.0ubuntu0.20.04.1                    all          Python interface to libapt-pkg (locales)
ii  python-dbus                           1.2.16-1build1                          amd64        simple interprocess messaging system (Python interface)
ii  python-gi                             3.36.0-1                                amd64        Python 2.x bindings for gobject-introspection libraries
ii  python-is-python2                     2.7.17-4                                all          symlinks /usr/bin/python to the DEPRECATED python2
ii  python-tk                             2.7.18-1                                amd64        Tkinter - Writing Tk applications with Python2
ii  python2                               2.7.17-2ubuntu4                         amd64        interactive high-level object-oriented language (Python2 version)
ii  python2-minimal                       2.7.17-2ubuntu4                         amd64        minimal subset of the Python2 language
ii  python2.7                             2.7.18-1~20.04                          amd64        Interactive high-level object-oriented language (version 2.7)
ii  python2.7-minimal                     2.7.18-1~20.04                          amd64        Minimal subset of the Python language (version 2.7)
ii  python3                               3.8.2-0ubuntu2                          amd64        interactive high-level object-oriented language (default python3 version)
ii  python3-apport                        2.20.11-0ubuntu27.12                    all          Python 3 library for Apport crash report handling
ii  python3-apt                           2.0.0ubuntu0.20.04.1                    amd64        Python 3 interface to libapt-pkg
ii  python3-aptdaemon                     1.1.1+bzr982-0ubuntu32.2                all          Python 3 module for the server and client of aptdaemon
ii  python3-aptdaemon.gtk3widgets         1.1.1+bzr982-0ubuntu32.2                all          Python 3 GTK+ 3 widgets to run an aptdaemon client
ii  python3-blinker                       1.4+dfsg1-0.3ubuntu1                    all          fast, simple object-to-object and broadcast signaling library
ii  python3-brlapi:amd64                  6.0+dfsg-4ubuntu6                       amd64        Braille display access via BRLTTY - Python3 bindings
ii  python3-bs4                           4.8.2-1                                 all          error-tolerant HTML parser for Python 3
ii  python3-cairo:amd64                   1.16.2-2ubuntu2                         amd64        Python3 bindings for the Cairo vector graphics library
ii  python3-certifi                       2019.11.28-1                            all          root certificates for validating SSL certs and verifying TLS hosts (python3)
ii  python3-cffi-backend                  1.14.0-1build1                          amd64        Foreign Function Interface for Python 3 calling C code - runtime
ii  python3-chardet                       3.0.4-4build1                           all          universal character encoding detector for Python3
ii  python3-click                         7.0-3                                   all          Wrapper around optparse for command line utilities - Python 3.x
ii  python3-colorama                      0.4.3-1build1                           all          Cross-platform colored terminal text in Python - Python 3.x
ii  python3-commandnotfound               20.04.4                                 all          Python 3 bindings for command-not-found.
ii  python3-cryptography                  2.8-3ubuntu0.1                          amd64        Python library exposing cryptographic recipes and primitives (Python 3)
ii  python3-cups                          1.9.73-3build1                          amd64        Python3 bindings for CUPS
ii  python3-cupshelpers                   1.5.12-0ubuntu1                         all          Python utility modules around the CUPS printing system
ii  python3-dateutil                      2.7.3-3ubuntu1                          all          powerful extensions to the standard Python 3 datetime module
ii  python3-dbus                          1.2.16-1build1                          amd64        simple interprocess messaging system (Python 3 interface)
ii  python3-debconf                       1.5.73                                  all          interact with debconf from Python 3
ii  python3-debian                        0.1.36ubuntu1                           all          Python 3 modules to work with Debian-related data formats
ii  python3-defer                         1.0.6-2.1                               all          Small framework for asynchronous programming (Python 3)
ii  python3-distro                        1.4.0-1                                 all          Linux OS platform information API
ii  python3-distro-info                   0.23ubuntu1                             all          information about distributions' releases (Python 3 module)
ii  python3-distupgrade                   1:20.04.28                              all          manage release upgrades
ii  python3-entrypoints                   0.3-2ubuntu1                            all          Discover and load entry points from installed packages (Python 3)
ii  python3-gdbm:amd64                    3.8.5-1~20.04.1                         amd64        GNU dbm database support for Python 3.x
ii  python3-gi                            3.36.0-1                                amd64        Python 3 bindings for gobject-introspection libraries
ii  python3-gi-cairo                      3.36.0-1                                amd64        Python 3 Cairo bindings for the GObject library
ii  python3-gst-1.0                       1.16.2-2                                amd64        GStreamer GObject Introspection overrides for Python (Python 3)
ii  python3-html5lib                      1.0.1-2                                 all          HTML parser/tokenizer based on the WHATWG HTML5 specification
ii  python3-httplib2                      0.14.0-1ubuntu1                         all          comprehensive HTTP client library written for Python3
ii  python3-ibus-1.0                      1.5.22-2ubuntu2.1                       all          Intelligent Input Bus - introspection overrides for Python (Python 3)
ii  python3-idna                          2.8-1                                   all          Python IDNA2008 (RFC 5891) handling (Python 3)
ii  python3-jwt                           1.7.1-2ubuntu2                          all          Python 3 implementation of JSON Web Token
ii  python3-keyring                       18.0.1-2ubuntu1                         all          store and access your passwords safely - Python 3 version of the package
ii  python3-launchpadlib                  1.10.13-1                               all          Launchpad web services client library (Python 3)
ii  python3-lazr.restfulclient            0.14.2-2build1                          all          client for lazr.restful-based web services (Python 3)
ii  python3-lazr.uri                      1.0.3-4build1                           all          library for parsing, manipulating, and generating URIs
ii  python3-libdiscid                     1.0-5ubuntu2                            amd64        libdiscid binding for Python 3
ii  python3-louis                         3.12.0-3                                all          Python bindings for liblouis
ii  python3-lxml:amd64                    4.5.0-1                                 amd64        pythonic binding for the libxml2 and libxslt libraries
ii  python3-macaroonbakery                1.3.1-1                                 all          Higher-level macaroon operations for Python 3
ii  python3-mako                          1.1.0+ds1-1ubuntu2                      all          fast and lightweight templating for the Python 3 platform
ii  python3-markupsafe                    1.1.0-1build2                           amd64        HTML/XHTML/XML string library for Python 3
ii  python3-minimal                       3.8.2-0ubuntu2                          amd64        minimal subset of the Python language (default python3 version)
ii  python3-mutagen                       1.44.0-1                                all          audio metadata editing library (Python 3)
ii  python3-nacl                          1.3.0-5                                 amd64        Python bindings to libsodium (Python 3)
ii  python3-netifaces                     0.10.4-1ubuntu4                         amd64        portable network interface information - Python 3.x
ii  python3-notify2                       0.3-4                                   all          desktop notifications API for Python 3
ii  python3-oauthlib                      3.1.0-1ubuntu2                          all          generic, spec-compliant implementation of OAuth for Python3
ii  python3-olefile                       0.46-2                                  all          Python module to read/write MS OLE2 files
ii  python3-pexpect                       4.6.0-1build1                           all          Python 3 module for automating interactive applications
ii  python3-pil:amd64                     7.0.0-4ubuntu0.1                        amd64        Python Imaging Library (Python3)
ii  python3-pkg-resources                 45.2.0-1                                all          Package Discovery and Resource Access using pkg_resources
ii  python3-problem-report                2.20.11-0ubuntu27.12                    all          Python 3 library to handle problem reports
ii  python3-protobuf                      3.6.1.3-2ubuntu5                        amd64        Python 3 bindings for protocol buffers
ii  python3-psutil                        5.5.1-1ubuntu4                          amd64        module providing convenience functions for managing processes (Python3)
ii  python3-ptyprocess                    0.6.0-1ubuntu1                          all          Run a subprocess in a pseudo terminal from Python 3
ii  python3-pyatspi                       2.36.0-1                                all          Assistive Technology Service Provider Interface - Python3 bindings
ii  python3-pymacaroons                   0.13.0-3                                all          Macaroon library for Python 3
ii  python3-pyqt5                         5.14.1+dfsg-3build1                     amd64        Python 3 bindings for Qt5
ii  python3-pyqt5.qtmultimedia            5.14.1+dfsg-3build1                     amd64        Python 3 bindings for Qt5's Multimedia module
ii  python3-pyudev                        0.21.0-3ubuntu1                         all          Python3 bindings for libudev
ii  python3-pyxattr                       0.6.1-2                                 amd64        module for manipulating filesystem extended attributes (Python3)
ii  python3-renderpm:amd64                3.5.34-1ubuntu1                         amd64        python low level render interface
ii  python3-reportlab                     3.5.34-1ubuntu1                         all          ReportLab library to create PDF documents using Python3
ii  python3-reportlab-accel:amd64         3.5.34-1ubuntu1                         amd64        C coded extension accelerator for the ReportLab Toolkit
ii  python3-requests                      2.22.0-2ubuntu1                         all          elegant and simple HTTP library for Python3, built for human beings
ii  python3-requests-unixsocket           0.2.0-2                                 all          Use requests to talk HTTP via a UNIX domain socket - Python 3.x
ii  python3-rfc3339                       1.1-2                                   all          parser and generator of RFC 3339-compliant timestamps (Python 3)
ii  python3-secretstorage                 2.3.1-2ubuntu1                          all          Python module for storing secrets - Python 3.x version
ii  python3-setproctitle:amd64            1.1.10-1ubuntu1                         amd64        Setproctitle implementation for Python 3
ii  python3-simplejson                    3.16.0-2ubuntu2                         amd64        simple, fast, extensible JSON encoder/decoder for Python 3.x
ii  python3-sip                           4.19.21+dfsg-1build1                    amd64        Python 3/C++ bindings generator runtime library
ii  python3-six                           1.14.0-2                                all          Python 2 and 3 compatibility library (Python 3 interface)
ii  python3-software-properties           0.98.9.2                                all          manage the repositories that you install software from
ii  python3-soupsieve                     1.9.5+dfsg-1                            all          modern CSS selector implementation for BeautifulSoup (Python 3)
ii  python3-speechd                       0.9.1-4                                 all          Python interface to Speech Dispatcher
ii  python3-systemd                       234-3build2                             amd64        Python 3 bindings for systemd
ii  python3-talloc:amd64                  2.3.0-3ubuntu1                          amd64        hierarchical pool based memory allocator - Python3 bindings
ii  python3-tz                            2019.3-1                                all          Python3 version of the Olson timezone database
ii  python3-uno                           1:6.4.7-0ubuntu0.20.04.1~lo1            amd64        Python-UNO bridge
ii  python3-update-manager                1:20.04.10.1                            all          python 3.x module for update-manager
ii  python3-urllib3                       1.25.8-2ubuntu0.1                       all          HTTP library with thread-safe connection pooling for Python3
ii  python3-wadllib                       1.3.3-3build1                           all          Python 3 library for navigating WADL files
ii  python3-webencodings                  0.5.1-1ubuntu1                          all          Python implementation of the WHATWG Encoding standard
ii  python3-xapian                        1.4.14-1ubuntu2                         amd64        Xapian search engine interface for Python3
ii  python3-xapp                          1.8.1-2                                 all          Python 3 XApp library
ii  python3-xdg                           0.26-1ubuntu1                           all          Python 3 library to access freedesktop.org standards
ii  python3-xkit                          0.5.0ubuntu4                            all          library for the manipulation of xorg.conf files (Python 3)
ii  python3-yaml                          5.3.1-1                                 amd64        YAML parser and emitter for Python3
ii  python3.8                             3.8.5-1~20.04                           amd64        Interactive high-level object-oriented language (version 3.8)
ii  python3.8-minimal                     3.8.5-1~20.04                           amd64        Minimal subset of the Python language (version 3.8)
django@ASGARD:~$ 

Searching… as suggested here https://stackoverflow.com/q/60788709

django@ASGARD:~$ python --version
Python 2.7.18
django@ASGARD:~$ 

My actual 20.04 is an upgrade from 19.10 is all I can add.

Now am trying

django@ASGARD:/media/DATA/coeurnoir/Bureau$ python3 stacks.py --stack
Traceback (most recent call last):
  File "stacks.py", line 110, in <module>
    stack()
  File "stacks.py", line 86, in stack
    if get_file_type(file, file_type_by_extension):
  File "stacks.py", line 73, in get_file_type
    if pathlib.Path(file).suffix.lower() in extension:
NameError: name 'pathlib' is not defined
django@ASGARD:/media/DATA/coeurnoir/Bureau$ 

All folders have been created on my desktop but no files were moved into them.
NameError: name 'pathlib' is not defined
so something’s missing about pathlib in my UBudgie ?

I think we are going down the Rabbit Hole on this:


I will look tonight after dinner but maybe it’s invoking the incorrect lib? AND:
Windows uses \ while Mac and Linux use / as a separator.

Reading/skimming right now: https://realpython.com/python-pathlib/

Right there, the two Python codes are different. The second code from Geeks starts:

  • import os
  • from pathlib import Path

Why don’t you use:

print(str(folder_name)+ " not found.")
#OR
print("{} not found.".format(folder_name))

Instead of f-string?
And I guess you need to download “pathlib” too.

It’s not my code, I don’t code at all.

I was just trying to try those « stack » things.

If pathlib is needed, shouldn’t it be already there on default 20.04 installation ?

no - zero reasons to include a component that the out-of-the-box install doesnt use.

Ok I hear that.

So it means both those « stack » script things can’t work out of the box on Ubuntu and need be adapted.

Agreed. Without spending more time that I don’t have on this I can’t really help other than to encourage everyone to have a poke and a prod to see if they can make things work.

Mmm how do you make it work.

Whatever script I try I always end up with :

django@ASGARD:/media/DATA/coeurnoir/Bureau$ python stacks.py --stack
Traceback (most recent call last):
  File "stacks.py", line 3, in <module>
    from pathlib import Path
ImportError: No module named pathlib
django@ASGARD:/media/DATA/coeurnoir/Bureau$ python org_junk.py 
Traceback (most recent call last):
  File "org_junk.py", line 2, in <module>
    from pathlib import Path 
ImportError: No module named pathlib
django@ASGARD:/media/DATA/coeurnoir/Bureau$ 

Still unhappy about pathlib

I’ve before those errors installed things like

python-pathlib2 (2.3.5-1ubuntu1)
python-scandir (1.10.0-2ubuntu3)
python-six (1.14.0-2)
python3-more-itertools (4.2.0-1build1)
python3-zipp (1.0.0-1)
pypy (7.3.1+dfsg-2)
pypy-lib (7.3.1+dfsg-2)
pypy-pathlib2 (2.3.5-1ubuntu1)
pypy-scandir (1.10.0-2ubuntu3)
pypy-six (1.14.0-2)

What do I miss ? Would you mind sharing your

dpkg -l | grep python

for comparison ?

Should really use python3 now just in-case you have installed python-2 stuff…

python3 stacks.py --stack