Lightweight tips and tricks

Post Reply
User avatar
mctom
Posts: 440
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 48 times
Been thanked: 41 times
Contact:

Lightweight tips and tricks

Post by mctom »

I imagine not all of us use Odroids as their main desktops, but surely I do. :D
And in modern times, it is more necessary than ever to conserve RAM and CPU time to maintain fluent experience.
I know, most people prefer just buying a rig that can lift everything, but I, mainly as an engineer and technopunk, refuse to believe that it takes 1,5GB of RAM to play a goddamn youtube video.
Maybe because I used to use Excel 5.0 that was shipped on a few 1.44MB floppys and believe me, it was just as accurate as today.

So, what are your tips and tricks to make your environment leaner and snappier?
Here are my few habits:

- mpv
It's a bare bone media player. Although the authors have a deep disregard to basically anything ARM-based, it does its job really well on my N2+. That's frankly the only way to watch a movie in 2K fluently. It plays music, plays videos, is very configurable, and supports youtube content (and other web-based video content, har har).
The mpv config is very flexible, but what interests me the most are the buffer sizes - after all, mpv might as well take half of your RAM to load 1 hour worth of content ahead. We don't want that. That's why in ~/.config/mpv/mpv.conf we add this:

Code: Select all

mctom@Tomusiomat-ARM:~/.config/mpv$ cat mpv.conf
demuxer-max-bytes=20480KiB
demuxer-max-back-bytes=20480KiB
20MB buffer in each direction, forward or backwards, is more than enough to watch online content (especially when you need to jump back a few seconds sometimes), and indeed your mpv memory footprint should stay below 100MB in total.

- pipe-viewer
Pointed out by jart25, it's indeed a gold nugget. Perl based, so pretty awkward to build unless you know anything about that Perl thing. But then, just wow. You open it up in a console, type what you'd like to search, blitz-fast response, and then you type type in the number of search result to play a movie. It opens up mpv to show the content. It doesn't get any lighter.
And here's a tip: If you use '-n' argument, mpv will play just an audio portion of youtube content. I use it every day for playing music at work.
Oh yes, it also comes with GUI, but who cares about that ;)

- open-with
A Firefox plugin. It lets you run a command with current page address (or page address under a link you point at) as its parameter.
I used to use it for playing youtube videos in mpv rather than browser itself, until I found pipe-viewer. Still pretty handy when you browse video content sites and want to pick a video based on the thumbnail, I guess.. :lol:

Anyway, here's a string I configured open-with to show a youtube movie in its full glory:

Code: Select all

mpv --fs --ytdl-format="bestvideo[height<=?1500]+bestaudio/best" %s
You may want to adjust height parameter to your own display.
And another option for audio-only playback:

Code: Select all

foot mpv --ytdl-format="bestaudio/best" %s
This time I open mpv in a foot terminal (may be other terminal of your choice). The reason is that mpv does not have any GUI when it plays audio, so I want to have it in a terminal window and be able to control it, rather than in a void somewhere.

(More later :D)
These users thanked the author mctom for the post (total 3):
tobetter (Sat Aug 07, 2021 5:24 am) • mad_ady (Mon Aug 09, 2021 6:32 pm) • clach04 (Sun Sep 12, 2021 3:58 pm)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
rooted
Posts: 8727
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 743 times
Been thanked: 376 times
Contact:

Re: Lightweight tips and tricks

Post by rooted »

Never seen pipe-viewer but I'm going to check it out for sure as a quick way to search videos on my laptop, I've used mpv for years and the predecessor mplayer for years before that.

*edit*
pipe-viewer is indeed an amazing piece of kit
Last edited by rooted on Sat Aug 07, 2021 5:26 am, edited 1 time in total.

L67GS
Posts: 578
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Location: Great Lakes Region, U.S.A
Has thanked: 159 times
Been thanked: 83 times
Contact:

Re: Lightweight tips and tricks

Post by L67GS »

..Subscribed..
Great topic idea Tom

sgear
Posts: 5
Joined: Sun Jun 30, 2019 9:31 pm
languages_spoken: english
ODROIDs: N2
Has thanked: 0
Been thanked: 6 times
Contact:

Re: Lightweight tips and tricks

Post by sgear »

ncspot is a great lightweight CLI alternative to the web player for those with Spotify premium.

spotify-tui looks promising as well but I've yet to try it.

WebCord is a slightly more lightweight and native feeling way to run discord compared to Firefox or Chrome
These users thanked the author sgear for the post:
mctom (Sun Aug 08, 2021 12:55 am)

User avatar
mad_ady
Posts: 9689
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 609 times
Been thanked: 721 times
Contact:

Re: Lightweight tips and tricks

Post by mad_ady »

Great tips! I didn't realize mpv was the offspring of mplayer...

Any ideas what I can do to fix my firefox tab addiction? I can't bring myself to close any...

User avatar
rooted
Posts: 8727
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 743 times
Been thanked: 376 times
Contact:

Re: Lightweight tips and tricks

Post by rooted »

mad_ady wrote:Great tips! I didn't realize mpd was the offspring of mplayer...

Any ideas what I can do to fix my firefox tab addiction? I can't bring myself to close any...
This to save tabs and come back to them whenever you like

https://addons.mozilla.org/en-US/firefo ... n-manager/
These users thanked the author rooted for the post:
mad_ady (Mon Aug 09, 2021 6:32 pm)

User avatar
mctom
Posts: 440
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 48 times
Been thanked: 41 times
Contact:

Re: Lightweight tips and tricks

Post by mctom »

Firefox really flexes my patience. I'm looking at falkon as a permanent substitution, but I need to transfer bookmarks somehow.
This won't help with your multiple tab addiction, I'm afraid. Nevertheless saving memory elsewhere might help you out a bit. :)
These users thanked the author mctom for the post:
mad_ady (Mon Aug 09, 2021 6:32 pm)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
mad_ady
Posts: 9689
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 609 times
Been thanked: 721 times
Contact:

Re: Lightweight tips and tricks

Post by mad_ady »

I've just tried pipe-viewer -- it's excellent! Thanks for the tip! Now, I shouldn't get distracted by youtube's algorithm while trying to get some music going in the background!
@rooted: thanks for the tab-session-manager addon! Now I can close some tabs and know they're not forever gone somewhere in history...

User avatar
rooted
Posts: 8727
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 743 times
Been thanked: 376 times
Contact:

Re: Lightweight tips and tricks

Post by rooted »

This is exactly like pipe-viewer but allows you to login to your account, same developer.

https://github.com/trizen/youtube-viewer

I've been trying to figure out the difference but the only difference I can find is the login ability works. Maybe the difference is the way it parses.

User avatar
mctom
Posts: 440
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 48 times
Been thanked: 41 times
Contact:

Re: Lightweight tips and tricks

Post by mctom »

Anyone remembers Pidgin, that obsolete chat program?
Well it turns out there are a few modern plugins for this thing.
I just built purple-facebook and after a password guessing game voila, it actually works!
Well, as long as you need to stay notified about chats and be able to exchange text. Nothing else seems to work, but 73MB of shared memory is far better than one tab in Firefox may clutter. :D
(I recommend generating a password just for this program in Facebook settings).

Supported protocols are definitely not an exhaustive list of my wishes, but there are a few peculiarities worth noting. Sure, it does support Matrix, Signal, Telegram and WhatsApp, but how about writing to stdin of your Docker containers, or actual SMS plugin? :D
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
rooted
Posts: 8727
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 743 times
Been thanked: 376 times
Contact:

Re: Lightweight tips and tricks

Post by rooted »

Yeah I used Pidgin for a long time many many years ago, back in the MSN Messenger and AIM days.

User avatar
mctom
Posts: 440
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 48 times
Been thanked: 41 times
Contact:

Re: Lightweight tips and tricks

Post by mctom »

It's a shame when you fire up a simple calculator and your music get choppy because you have just sacrificed another 47MB of RAM and system starts swapping like crazy. Why not sacrifice just 20MB, or go extreme and use just 520kB for the same thing!
The first option is a very competent terminal based calculator, qalc.

Code: Select all

mctom@Tomusiomat-ARM:~$ qalc
> 10 / 3

  10 / 3 = approx. 3,3333333

> 34,25 + 23.45

  34,25 + 23,45 = 57,7

> 12V / 25mA

  (12 * volt) / (25 * milliampere) = 480 ohms

> 59 USD to PLN

  59 * dollar = approx. 230,57194 PLN

> 345 to hex

  345 = 0x159

> 0xdeadbeef + 0x1

  3735928559 + 1 = 3735928560

> ans to hex

  ans = 0xDEADBEF0
That's cool and all, but let's go lighter!

Code: Select all

mctom@Tomusiomat-ARM:~$ dc
10 3 / n
3
34.25 23.45 + n
57.70
12 0.025 / n
480
2 2 2 2 2 2 * * * * * n
64
That's right, you're looking at the reverse Łukasiewicz notation. Super simple and not much of a burden when 40-some MB are at stake, right? :D
That is, unless your terminal emulator is lighter than a calculator to begin with :D And for that I highly recommend foot.
These users thanked the author mctom for the post:
clach04 (Sun Sep 12, 2021 3:58 pm)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
mctom
Posts: 440
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 48 times
Been thanked: 41 times
Contact:

Re: Lightweight tips and tricks

Post by mctom »

Tired of DESKTOP ENVIRONMENT? What a burden! Save precious memory on your leanest setup at home!

I ruined a Ubuntu Server installation on my old netbook, so decided to give Manjaro a go - the bare bones variant with nothing on board.

Eventually I realized that I do most of my stuff in terminal - but what about the rest?
I thought it would be so cool to just launch a GUI program with some sort of thin Wayland wrapper, just to display it in full screen (10" screen, so tiling is quite useless anyway).
And indeed there is. cage is a "Wayland kiosk" that does exactly that: lets you run one full screen program. If more are started, the latest is always on top.
So you just run cage wesnoth and play Wesnoth on otherwise unspoiled system.

Cage takes its kiosk mission seriously and is hardened against geeky misuse. Running cage with -s option lets you switch VTs.

Unfortunately, cage is a tad bit buggy and I had some issues with freezing display when working on foot terminal. So eventually I ended up with Weston, that offers similar modes: kiosk mode and fullscreen mode (can't tell the difference though). Sadly, a dirty hack is necessary to conveniently run something in Weston on demand.
alias weston="weston & sleep 1 &&"
And then:
weston wesnoth
These users thanked the author mctom for the post:
tobetter (Mon Sep 13, 2021 7:51 am)
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

Post Reply

Return to “Ubuntu (All Linux'es)”

Who is online

Users browsing this forum: No registered users and 1 guest