Skip to content

Instantly share code, notes, and snippets.

@Theldus
Created October 20, 2020 17:38
Show Gist options
  • Save Theldus/6381f72209191d293dab5e47eff56fd2 to your computer and use it in GitHub Desktop.
Save Theldus/6381f72209191d293dab5e47eff56fd2 to your computer and use it in GitHub Desktop.
Increase maximum recent files on VLC
# Increase maximum recent files on VLC, by Theldus
#
# First of all, this is not an official patch!, apply at your
# own risk, nonetheless, it should be safe =).
#
# Second of all, it's so much easy to increase this limit, why on earth VLC
# uses a hardcoded number? 10 at the moment. VLC already saves more than 10
# items on the ~/.config/vlc/vlc-qt-interface.conf, so why not makes use of
# such thing? I really dont know. Anyway, apply this and be happy.
#
# Tested on:
# * Ubuntu 18.04.3 LTS
# * VLC 3.0.8 Vetinari
# -> http://download.videolan.org/pub/videolan/vlc/3.0.8/vlc-3.0.8.tar.xz
# (not tested on others environments/versions)
#
# Build instructions:
#
# All the following instructions were adapted/grabbed from:
# -> https://techpiezo.com/linux/install-vlc-media-player-in-ubuntu/
#
# Ubuntu dependencies:
# sudo apt-get install git build-essential
# sudo apt-get install pkg-config libtool automake
# sudo apt-get install autopoint gettext
#
# sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev
# sudo apt-get install libxcb-keysyms1-dev libxcb-randr0-dev
# sudo apt-get install libxcb-composite0-dev
#
# sudo apt-get --no-install-recommends build-dep vlc
#
# Build:
# cd vlc-3.0.8/
# patch -p1 < ../vlc_recent_files.patch
# ./configure
# time make -j$(nproc)
#
# And enjoy =)
# export VLC_RECENT_MAX=<amount-you-want>
# ./vlc
#
# Add VLC_RECENT_MAX=<amount> on your /etc/environment to become system-wide
#
diff -ruN vlc-3.0.8-orig/modules/gui/qt/menus.cpp vlc-3.0.8/modules/gui/qt/menus.cpp
--- vlc-3.0.8-orig/modules/gui/qt/menus.cpp 2018-07-05 05:53:54.000000000 -0300
+++ vlc-3.0.8/modules/gui/qt/menus.cpp 2020-10-20 14:17:23.563628598 -0300
@@ -1591,7 +1591,7 @@
}
else
{
- for( int i = 0; i < __MIN( l.count(), 10) ; ++i )
+ for( int i = 0; i < __MIN( l.count(), rmrl->maxRecents()) ; ++i )
{
QString mrl = l.at( i );
char *psz = vlc_uri_decode_duplicate( qtu( mrl ) );
diff -ruN vlc-3.0.8-orig/modules/gui/qt/recents.cpp vlc-3.0.8/modules/gui/qt/recents.cpp
--- vlc-3.0.8-orig/modules/gui/qt/recents.cpp 2017-11-24 13:29:17.000000000 -0200
+++ vlc-3.0.8/modules/gui/qt/recents.cpp 2020-10-20 14:24:45.491644458 -0300
@@ -81,6 +81,22 @@
delete filter;
}
+int RecentsMRL::maxRecents()
+{
+ int recent_max = 10;
+
+ // Try to read the recent-max parameter, if not exist, create one.
+ const char *rmax = getenv( "VLC_RECENT_MAX" );
+ if ( rmax != NULL )
+ {
+ // I know I know, atoi is not safe and blah blah, this is just
+ // a quick hack, don't take this too much serious, =).
+ recent_max = atoi( rmax );
+ }
+
+ return recent_max;
+}
+
void RecentsMRL::addRecent( const QString &mrl )
{
if ( !isActive || ( filter && filter->indexIn( mrl ) >= 0 ) )
@@ -109,7 +125,7 @@
{
recents.prepend( mrl );
times.prepend( "-1" );
- if( recents.count() > RECENTS_LIST_SIZE ) {
+ if( recents.count() > maxRecents() ) {
recents.takeLast();
times.takeLast();
}
diff -ruN vlc-3.0.8-orig/modules/gui/qt/recents.hpp vlc-3.0.8/modules/gui/qt/recents.hpp
--- vlc-3.0.8-orig/modules/gui/qt/recents.hpp 2017-11-24 13:29:17.000000000 -0200
+++ vlc-3.0.8/modules/gui/qt/recents.hpp 2020-10-20 14:11:42.647616364 -0300
@@ -33,8 +33,6 @@
class QRegExp;
class QSignalMapper;
-#define RECENTS_LIST_SIZE 30
-
class Open
{
public:
@@ -57,6 +55,8 @@
friend class Singleton<RecentsMRL>;
public:
+ int maxRecents();
+
void addRecent( const QString & );
QStringList recentList();
QSignalMapper *signalMapper;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment