Showing posts with label mpv. Show all posts
Showing posts with label mpv. Show all posts

Monday, May 1, 2023

Qutebrowser. My most configurable browser, to date.

Throughout my usage of GNU/Linux, there was one browser which always stood in my way, which was recommended, which was thrown at me, whenever I looked out for a customizable browser. Firefox does all this and more with its awesome plugin system. However, the same plugin system is a hindrance for further customizations. I realized this once I dived into qutebrowser. 

The name is little distracting. Beware, the browser is far from qute. It gives complete power to the user. I have never seen a more configurable modern browser. As I started going through the process of making the browser my own according to my way of using it, it took me further into the configurable world of modern browsers. I am just blown away by the customizations you can do with this browser. Really, sky is the limit. I have just touched a drop of water from the sea. Congratulations to the dev and all the users who have share their customizations over the public network. As usual, I dont beleive in re-inventing the wheel and kanged as much configuration as possible from the public network and very little from the documentation.
 

Create a start page with your most visited web pages and create a variable in the config.py file like so

home = 'file://home/my_name/../../startpage.html'

Plenty of examples are available over the public network for creation of a startpage. You can then reuse the variable like

#open new tab with startpage
cconfig.bind('gh', 'open -t ' + home)

#The config below will open qutebrowser with the startpage
c.url.start_pages = home


# Editor settings to open your favourite editor to be used in editable text fields
c.editor.command = [
    "alacritty",
    "-e",
    "nvim",
    "-f",
    "{file}",
    "-c",
    "normal {line}G{column0}1"
]


# aliases to do most with keypresses

c.aliases = {
        'incognito': 'open --private',
        'q':    'close',
        'qa':   'quit',
        'w':    'session-save',
        'wq':   'quit --save',
        'wqa':  'quit --save',
        'bkl': 'bookmark-list',
        'bko': 'bookmark-load',
        'bkd': 'bookmark-list',
        'bka': 'bookmark-list',
        'firefox': 'spawn --detach firefox {url}'
        }



# My favourite settings

# Bindings for normal mode
config.unbind('d')
config.unbind('xo')
config.bind('t', 'set-cmd-text -s :open -t')
config.bind('m', 'hint links spawn cvlc {hint-url}')
config.bind('M', 'quickmark-save')
config.bind('q', 'tab-close')
config.bind('cs', 'set-cmd-text :config-source')
config.bind('ce', 'config-edit')
config.bind(';', 'set-cmd-text :')                                                                                             config.bind('ct', 'config-cycle content.user_stylesheets themes/default.css themes/gruvbox.css')
config.bind('di', 'hint images spawn wget -P Pictures {hint-url}')
config.bind('dl', 'hint links spawn wget -P Downloads {hint-url}')
config.bind('gH', 'open ' + home)
config.bind('gh', 'open -t ' + home)
config.bind('pt', 'open -t -- {clipboard}')
config.bind('pw', 'open -w -- {clipboard}')
config.bind('yc', 'hint links yank')
config.bind('yi', 'hint images yank')
config.bind('=', 'zoom-in')
config.bind('+', 'zoom')
config.bind('pb', 'open -p ')
config.bind(',b', 'config-cycle content.blocking.enabled true false')
config.bind(',s', 'config-cycle content.javascript.enabled true false')
config.bind('<Ctrl-Tab>', 'tab-next')
config.bind('<Ctrl-Shift-Tab>', 'tab-prev')
config.bind('<Ctrl-/>', 'undo')
config.bind('<Ctrl-Backspace>', 'back')
config.bind('<Ctrl-Shift-Backspace>', 'forward')



# open your links faster. Open links with two key strokes

config.bind(',1', 'open https://yewtu.be')
config.bind(',2', 'open -t https://linuxtoday.com')


# adblock lists

c.content.blocking.hosts.lists = [
                    "https://www.malwaredomainlist.com/hostslist/hosts.txt",
                    "https://someonewhocares.org/hosts/ipv6/hosts",
                    "http://winhelp2002.mvps.org/hosts.zip",
                    "http://malwaredomains.lehigh.edu/files/justdomains.zip",
                    "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext",
                    "https://easylist.to/easylist/easylist.txt",
                    "https://easylist.to/easylist/easyprivacy.txt",
                    "https://secure.fanboy.co.nz/fanboy-annoyance.txt",
                    "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt",
                    "https://easylist-downloads.adblockplus.org/abp-filters-anti-cv.txt",
                    "https:/raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters-2023.txt"]


# Plenty of options for search engines

c.url.searchengines = {"DEFAULT": "https://duckduckgo.com/?q={}",
        's':        'https://searx.ninja/?q={}',
        'w':        'https://en.wikipedia.org/wiki/{}',
        'v':        'https://invidious.snopyta.org/search?q={}',
        'i':        'https://searx.ninja/?q=!images+{}',
        }

If you are a fan of darkreader plugin on firefox, there is one for qutebrowser. Kindly search the public network since the links might get outdated.


Again, the above are just few of my favorites. Many are scattered over the public network. Happy hunting.
Thank you again, to the dev, the contributors, the users and the entire freedom software ecosystem to make all this possible.

Friday, October 30, 2020

Going "console only "on GNU/Linux

Got frustrated with the time taken for the browser to load up and then dependency trap for installing other gui applications. Add to that the nuisance of gtk and qt quirks on a 4K monitor. The feeling is share by many. But as we shall see living in this place is not easy. The major difficult piece of the puzzle is the browser. All your banking, shopping options are ruled out in the terminal. 

 

What I did here was to disable even the start of the X server. I disabled sytemd unit which is supposed to reach the graphical login target. Disabled the graphical login manager, lightdm in my case. Disabled all the cloud stuff which ubuntu GNU/Linux starts with lot of difficulty. In fact, because of this the first boot of ubuntu after install is a hit or a miss. After boot do not try to login immediately. There are plenty of things ubuntu is doing in that phase. If you try to login, it will fail. Wait for 10 minutes, approx, it might be higher so that it spews many lines of information over the login prompt, then it will allow you to login and change the default password. 

 

Disabled ssh service, because the rpi 4 is connected to a 4K monitor. Even during login, ubuntu tries to plenty of things. It will try to check for updates and provide a notification once in the motd. It will also provide information from the ubuntu motd server which canonical wants you to see. It will also spew out certain information from your computer like memory usage, load on the cpu etc. All this will take plenty of time considering the rpi 4. Find the respective scripts and disable them to speed up the time required to reach the login prompt. So, we have reached the login prompt. The fonts are so tiny, you have to squint to type any commands. First thing is to first reconfigure the fonts. Get the biggest font available while running the re configuring tool. Yes, the size can be changed, but the fonts are horrible. They are not for your daily tasks. All the fonts which you had installed in your X is now out of reach. 

 

The console well, is a console. It will display fonts which are baked into the linux kernel. If anybody knows how to change the fonts on the default console, kindly advice or drop a link. But, as of now, we have a readable console and the font size is alright. The fonts are not. We have been pampered for the variety of fonts on X. It is a requirement that we should do something about it. Step in, fbterm. As the name suggests it is a terminal emulator designed to work with a framebuffer. The biggest advantage, supports all the fonts supported on X. There goes my first gripe about the console. So, we install fbterm and start and run it at the console. The console is taken over by fbterm and again we have micro-sized fonts, but nice looking fonts taken from the X environment you had installed earlier. Let us go ahead and fix the fonts by restarting fbterm with fbterm -s 24. This was for my monitor. Try experimenting with different sizes to get the optimum size. 

 

The config file for fbterm is in .fbtermrc. Well, I already see your smiling face and I have received your gratitude and in turn it is time to congratulate you for completing the first time required for living in the console. Whatever further tools we are planning to used depends on this success. The fonts are beautiful and they are your favorite ones. They look good and it is as though you are back on your terminal emulator on X, but without all its bells and whistles(another name for bloat). You now can clearly distinguish between l and 1, 0 and O, I and L. I would like to thank all the creators of fonts which can clearly distinguish the characters of the English language. It is an artists job and the creator of any font is an artist. 

 

You opened the fbterm man page and want to edit the configuration file by reading the manual, you are out of luck. You are on the console. There are no windowing systems. What d you do, you press C-A-F2 and switch to the next virtual console and login again. Then you can switch between the virtual consoles. Your are now flabbergasted. You have started hating yourself for moving away from X. But, fritter not, there are further goodies which come with fbterm. You can create multiple windows and switch to them using shortcuts as mentioned in the fbterm man page. This will give you a method of moving between multiple windows and then moving between them. 

 

 Let us go to the next step. Now, you would like to group certain windows and recognize them for a specific task group. You have a web page related, you have a manual page related and couple of windows concerned to the programming task related to the web page and the man page. You are out of luck. You cant see all the windows at once together on one single screen. Frustration. Enter terminal multiplexer. The first name which comes to he mind is tmux, if you are a year 2000 person and screen, if you are before that. These are excellent tools and are blind faith groups unto themselves. So, if you like a tool, silently use them. Do not compare them and publish your comparisons. This is because, if you have reached a position where you compare both these tools, that means you already "prefer" one among them. This will start a war. We already have the longest running war between Vi and GNU Emacs. These are the kitchen sinks of terminal multiplexers. 

 

If you are a person believing in the *nix philosophy of "One tool that does one thing and does it best", then you have an alternate option. Many a times I had tried to pull myself together and learn tmux, but since I was using the i3 wm, I thought that it is not worth the effort. I could open as many windows and all would be started side by side preparing a huge canvas for exchanging information. I am in love with i3 wm for its simplicity and doing what it is supposed to do and doesnt do anything more. A huge shoutout to all the devs and users of this fantastic wm. Now, once again my terminal multiplexer flames were re-kindled by Mr. Bronie Robertson on his youtube channel. I like his videos. They are short and to the point with excellent examples and use case scenarios. 

 

Plentiful thanks to him for introducing me to abduco. Such a strange name. If there are explanations for the name kindly enlighten me. A session management tool with such a strange and difficult to pronounce name. However, what caught my attention was the ease with which Bronie did the session management. No obscure keystrokes to remember. Just session management and nothing else. In fact, I understood session management in that under 10 minutes video, than I had tried for a good 10 years. So, Thank you Bronie. Yes, there might be plenty other things required for complex setups, but for a desktop use and a home network user, that is exactly what the doctor would prescribe. 

 

 So, three main things which a session manager has to do. Create a session. Detach a session. Re-connect to a session. abduco does all the three with elan. All technicalities, I would redirect you to Mr. Bronie. So to create a session, let us understand what is a session. A session is a group of tasks related to one another. It is a method of grouping applications and open files related to a task on hand. Let us say the session you have created contains a compile task which will take another hour. Now, you are free to let us say, listen to some music, read a novel, well, things like that. What we now do is, detach the task on hand. And now, the compiling and all other windows are moved to the background and keep running. We will now create another session and do the relaxing stuff related to music and reading. You now want to continue listening to music and then you would like to check your online accounts like your email, your toots etc. You detach the multimedia session and start a new session with these applications. Its been an hour and you would like check on your compile session, You detach the online session and re-connect to compiling session and so on. That is session management for dummies. 

 

But in a session, if you have to have multiple windows grouped together, it is all good in an X environment. If you remember we are at a console running fbterm. We were very happy with good fonts but a bit sad about moving between windows as every window occupied the complete screen making it very difficult to share information between windows. Enter dvtm. The expansion will be dynamic virtual terminal manager. The name tells everything. It is there to manage windows. It will create, position, delete windows. It is an equivalent to i3 wm and more close to dwm wm but for terminals. When we create a new window in dvtm, we are starting a new terminal waiting for our input. dvtm does exactly what i3 does. It just arranges windows side by side in many different ways. But all your window contents are there for you to see and transfer between windows in the same screen. For our case it is a window manager for the console. 

 

I hated the console because if you wanted to refer to a man page and return back to the editor, you had to suspend the editor read up and remember the man page and then suspend the man page and bring back the editor to the foreground and dump whatever you remembered from the man page. This is no way ideal. For the optimal setup, we combine a session manager with a terminal manager and you have Window management for the console. How do we do it? Well just run both the commands in unison as so.

 

abduco -c session_name dvtm -m ^x 

 

What we are doing is asking our session manager abduco to create(-c) a new session and name that session "session-name" and the application it has to run is dvtm. The next option is for the MOD key. The default key for the MOD key is ^g. Yes, you are a bit confused here. For i3 users, the MOD key used to be a single key like the super key or the ALT key. But, these keys are not recognized by the console. So keep the default or change it to the value which I use, since x is close to the control key than the g key. Once you run this command, a session is created and control is handed over to dvtm. Now here you can start using the keybindings as suggested in the man page of dvtm. MOD-c will create a window in the tiled mode. Another MOD-c press will create another terminal window and so on. MOD-j and MOD-k will move between the windows and all windows are available in one single screen. 

 

I cannot express my joy, when I saw my console splitting into multiple windows. For everything else there is MasterCard. You did plenty of work by moving between windows and your program is now copiling. Time to relax. Detach the session by pressing MOD-\. You now land back at your console. Now run another command as so abduco -c relax dvtm -m ^x You get a fresh canvas. Create multiple windows again for playing your music with lyrics, reading a book by the next window. 

 

Enough of recreation, back to work. But, you want the music continue to play and want the book you were reading to be at the same place. Detach this session again by pressing MOD-\. Run without any arguments, abduco, will list all the live sessions. Run this command with the session name abduco -a session_name Now you are connected back to your compiling and editing session with all the windows as you left them when you detached from this session. The compiling is not complete, detach again and then re-connect to your relax session and continue reading your book. 

 

You are smiling. Your low spec PC is so responsive. But, But, We are living in a modern world and it is very difficult to survive without a pdf viewer, an image viewer, a video player, an ebook reader, a music player, a text reader(should we talk about it), web browser, a spread sheet, a document writer, a presentation tool and what not........ 

 

Let us try and resolve these applications one by one.

1. Let us start with a pdf viewer. This was rather easy. I was happy that the less command is more than capable of displaying text based pdfs. It will display pdfs with images, but the images are ignored.

2. An image viewer. For this the framebuffer image viewer, fbi is upto the task and is enough for viewing images and also includes the capability to perform a slideshow of the images supplied to the command.

3. For a Text reader/editor we are spoilt for choice and I would rather not talk about the options here. Whatever I talk about would be less.

4. If we come to the web browser, we do have choices, but none capable of handling 2 - 4GB of modern websites. We have applications for displaying true html. Blogs written with text only are a joy to read. I would recommend w3m. It also has support for images(I have not tried out this feature). If you access gopher holes or the modern avatar, the gemini space, then you are in luck and there are plenty of options. With the gopher and gemini protocol, you are at home in the console. Want to access your banking site, forget it.

5. If you are on the fediverse, there are clients for the mastodon network. There are clients for reddit.

6. For reading ebooks like epubs and mobis, I would recommend epy.

7. For searching the web we have the duckduckgo client ddgr and surfraw. Both are powerful and meet all the web searching requirements. 

8. Playing music has always been easy on the console with plenty of applications. My personal favorite is the mpd and mpc combination with ncmcpp added into the mix. 

9. For playing video, mpv is my default goto. The framebuffer device plays most of the videos thrown at it. 

This has already been a very long post. If you made it this far, then you are definitely a console junkie. If I could give you a hint of the entrance to the rabbit hole, then I would be most happy. Dont forget to buy yourself a mechanical keyboard. Thanks to all the devs and users who wrote all those wonderful applications and of course GNU/Linux. The journey with the tux and the beastie and the puffer since the year 2000 has been nothing but joy. I would like to end the post with the tagline of distrowatch. "Put the fun back into computing. Use GNU/Linux, Freebsd, Openbsd, Netbsd, Plan9, templeos, Haiku, Minix, GNU ..."



Friday, June 12, 2020

Well, What is on my raspberry pi 4

The first thing I install is my client for the cloud based notes application. I use simplenote. It has the advantage that it is available on all the major platforms. There is a terminal client called sncli. This is my go to client.
The next thing is to install terminology for the terminal. After trying out many, I observed that terminology is the fastest on the pi.
i3 window manager. I cannot live without it. None of my Gnu/Linux installations is complete without this. It is lightweight, easily configurable and simple.
For the browser, since I have started using computers I have sided with Firefox. I am at home with this browser. I install noscript, ublock, privacy badger and dark reader plugins. I like it. It has always met my expectations.
For the application launcher i go with rofi. The run menu is shown in a small window in the bottom left corner of my monitor.
For searching on the command line I use ddgr(DuckDuckgo client for the terminal) and surfraw. After installing surfraw I install a small script called menu-sufraw available on github. This integrates beautifully with rofi. Must try.
For the office suite, My choice was OpenOffice before it went to the butcher's table with the Apache foundation. Now it is libreoffice. I like it. It gets the job done.
For my text editor, wait, wait, I use both Neovim and Doom emacs as demanded by the situation. I use emacs with the client/server model. It is quick and very snappy to start and to work.
Feh for my wallpaper needs.
There is one more plugin which I install on firefox, it is called play-with. This I combine with mpv. We now have an awesome combination for playing streaming content on the pi. For this configuration to work there is one more piece of software required and that is youtube-dl. A beautiful example of the unix philosophy working for the modern age of the internet.
Not to forget that all the apps are in dark mode, if available. I like the dark mode. It has been excellent for my eyes. Even now when firefox flashes before loading a tab, I close my eyes for a while. Thank you, Apple, only for bringing the dark mode into vogue.
My hardware setup is already discussed in one of my previous posts.
font-awesome for that "graphics" in the terminal.
d2code for the font, wherever possible. I like its legibility.
I use i3status showing the date, time, empty space, processor speed and the temperature.

Thanks to all the devs/users of all the freedom software. My respect to one and all without which this post wouldn't exist.