Results 1 to 7 of 7

Thread: 7.4.2 - Have you ever wanted a BS-free time format in mc?

Threaded View

  1. #1
    Member registered user
    Join Date
    Oct 2004
    Posts
    32

    7.4.2 - Have you ever wanted a BS-free time format in mc?

    Ever since 2008 when I started using Knoppix 5.3.1 (heavily remastered) I was stunned by the really obfuscating style of displaying access/modify/change time for files in mc.

    Simply looking at the whole column of time in a panel in mc is bound to get someone in a mental institution.

    I never understood the process of thinking on this aspect of the programmers who wrote this piece of software, otherwise very very useful.

    When it comes to representation of time, the only format that makes sense to me is "YYYY-mm-dd HH:MM".

    (Right, the year needs all 4 digits, anyone trying to tell me otherwise is missing some critical lamps. And the format having "day/month/year" is really retarded, especially when the year has only 2 digits and it's impossible to tell which is the month and which is the day and which is the year!! That is really really stupid, I'm sorry but there's just no other way of saying it.)

    Why "YYYY-mm-dd HH:MM"? Simply because it sorts itself out naturally timewise by means of regular alphabetical sorting if used in any indexing system.

    For instance I scan all my receipts from stores and save them in my data storage. And guess what the format of the file name is? "YYYY-mm-dd HH.MM Store_Name.tif"

    Simply displaying them in konqueror or any file manager they get sorted temporally by themselves.

    Quite a while ago I dug up the sources for mc-4.6.1 and started looking for a way to change the display format.
    I came up with a patch (see attachments to this message) which successfully gave me the time format displayed the way I wanted in mc.

    So now, since I started using Knoppix 7.4.2 it crossed my mind this would be the next nice trick to do in it.

    So here's what I did:
    (NOTE: everything described below is being done as root under the original Knoppix 7.4.2 DVD Live environment)

    Open a konsole window as root in an empty directory (for instance /home/knoppix/Downloads).
    Do the following:

    Code:
    sed -i -e "s/\.de\./.us./g" /etc/apt/sources.list
    rm -fv /var/cache/apt/*.bin
    rm -fv /var/lib/apt/lists/*debian*
    apt-get update
    Just for the record, I executed the code above on 2015 Jan 02. (It matters since at some point in the future the list of available package versions will change and the above code will have different consequences).

    Then I downloaded two packages from snapshot.debian.org:

    Code:
    wget http://snapshot.debian.org/archive/debian/20140317T222027Z/pool/main/libg/libgcrypt20/libgcrypt20-dev_1.6.1-2_i386.deb
    wget http://snapshot.debian.org/archive/debian/20140903T220917Z/pool/main/libs/libssh2/libssh2-1-dev_1.4.3-4_i386.deb
    Then I downloaded the sources for the version of mc in Knoppix 7.4.2:

    Code:
    wget http://snapshot.debian.org/archive/debian/20140402T100841Z/pool/main/m/mc/mc_4.8.12-1.debian.tar.xz
    wget http://snapshot.debian.org/archive/debian/20140402T100841Z/pool/main/m/mc/mc_4.8.12-1.dsc
    wget http://snapshot.debian.org/archive/debian/20140402T100841Z/pool/main/m/mc/mc_4.8.12.orig.tar.xz
    Then I made up a patch for the sources, that changes the time display format in mc's panels to what I described above.
    You can download it from the attachments to this message (mc-4.8.12-BS-free_time_format.patch.gz).

    Also you will need a script I prepared (update.sh) which looks like this:

    Code:
    #!/bin/sh
    
    #### RUN THIS AS ROOT !!!!! #####
    
    # src/setup.c lines 216 & 217 changed from:
    #define FMTYEAR _("%b %e  %Y")
    #define FMTTIME _("%b %e %H:%M")
    #                      to:
    #define FMTYEAR _("%Y-%m-%d %H:%M")
    #define FMTTIME _("%Y-%m-%d %H:%M")
    # (but it turns out it works without this, so it's not necessary)
    
    # lib/timefmt.c line 81 changed from:
    #    return i18n_timelength_cache
    #                to:
    #    return 16;
    
    # lib/timefmt.c line 114 changed from:
    #    return i18n_timelength_cache
    #                 to:
    #    return 16;
    
    # lib/timefmt.c line 139 changed from:
    #    FMT_LOCALTIME (timebuf, sizeof (timebuf), fmt, when);
    #                 to:
    #    FMT_LOCALTIME (timebuf, sizeof (timebuf), _("%Y-%m-%d %H:%M"), when);
    
    
    # Install dependencies required by the (re)building process.
    # At the time of running this script I had run "apt-get update" on 2015-Jan-02
    # after previously deleting /var/cache/apt/*.bin and /var/lib/apt/lists/*debian*
    echo -e "\n\n-------- removing libgnutls-dev ---------\n"
    apt-get -y remove libgnutls-dev
    echo -e "\n\n-------- removing libgcrypt11-dev ---------\n"
    apt-get -y remove libgcrypt11-dev
    echo -e "\n\n-------- installing libgcrypt20-dev ---------\n"
    dpkg -i libgcrypt20-dev_1.6.1-2_i386.deb
    echo -e "\n\n-------- installing libssh2-1-dev ---------\n"
    dpkg -i libssh2-1-dev_1.4.3-4_i386.deb
    echo -e "\n\n-------- installing a whole bunch ---------\n"
    apt-get -y install dh-autoreconf autopoint intltool bison check e2fslibs-dev libaspell-dev libgpm-dev libslang2-dev
    
    echo -e "\n\n-------- extracting mc-4.8.12 sources ---------\n"
    dpkg-source -x mc_4.8.12-1.dsc
    cd mc-4.8.12
    # now change src/setup.c and lib/timefmt.c as described above
    echo -e "\n\n-------- applying patch ---------\n"
    patch -p1 <../mc-4.8.12-BS-free_time_format.patch
    echo -e "\n\n-------- committing changes ---------\n"
    dpkg-source --commit
    echo -e "\n\n-------- rebuilding mc-4.8.12 debian packages ---------\n"
    dpkg-buildpackage -us -uc
    
    echo -e "\n\n-------- (re)installing mc-4.8.12 debian packages ---------\n"
    cd ..
    dpkg -i *.deb
    
    exit 0
    Copy/Paste the code above in kwrite and save it as "update.sh" in the same dir as the rest of the files.
    So at this point, your directory should look like this:

    Code:
    knoppix@Microknoppix:~/Downloads$ ls -1
    libgcrypt20-dev_1.6.1-2_i386.deb
    libssh2-1-dev_1.4.3-4_i386.deb
    mc_4.8.12-1.debian.tar.xz
    mc_4.8.12-1.dsc
    mc-4.8.12-BS-free_time_format.patch
    mc_4.8.12.orig.tar.xz
    update.sh
    Now simply type:

    Code:
    . update.sh
    or make the "update.sh" file executable and run it.

    It should run flawlessly until the end and when it's done, your directory should look like this:

    Code:
    knoppix@Microknoppix:~/Downloads$ ls -1
    libgcrypt20-dev_1.6.1-2_i386.deb
    libssh2-1-dev_1.4.3-4_i386.deb
    mc-4.8.12
    mc_4.8.12-1.debian.tar.xz
    mc_4.8.12-1.dsc
    mc_4.8.12-1_i386.changes
    mc_4.8.12-1_i386.deb
    mc-4.8.12-BS-free_time_format.patch
    mc_4.8.12.orig.tar.xz
    mc-data_4.8.12-1_all.deb
    mc-dbg_4.8.12-1_i386.deb
    update.sh
    Of course you can save the *.deb files somewhere and include them later in a Knoppix 7.4.2 remaster permanently.

    Now you can just type mc and you should see something like the snapshot attached to this message.

    Of course, first you need to go in mc's menu at "Left" or "Right" or both and change the "Listing mode" for panels to "User defined" (include "mtime" or "atime" or "ctime" somewhere in there) otherwise the time column won't be displayed.

    For instance this is what I had for "User defined" "Listing mode" when I took the snapshot:

    Code:
    half type name | size | mtime | perm | owner | group
    Attached Images Attached Images
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


ACASIS 2.5/3.5 inch 2 Bay SATA USB 3.0 Hard Drive Disk HDD SSD Enclosure 4 RAID picture

ACASIS 2.5/3.5 inch 2 Bay SATA USB 3.0 Hard Drive Disk HDD SSD Enclosure 4 RAID

$58.99



LSI 9305-16i SATA SAS 12Gbs RAID Controller PCIe 3.0 x8 IT-Mode 4* 8643 SATA picture

LSI 9305-16i SATA SAS 12Gbs RAID Controller PCIe 3.0 x8 IT-Mode 4* 8643 SATA

$229.99



HPE 727263-003 BL460c G9 Raid BBWC Smartstorage Battery picture

HPE 727263-003 BL460c G9 Raid BBWC Smartstorage Battery

$24.99



HPE 869102-001 Smart Array E208i-a SR Gen10 Storage Controller RAID SP: 871039 picture

HPE 869102-001 Smart Array E208i-a SR Gen10 Storage Controller RAID SP: 871039

$116.99



Inspur LSI 9300-8i Raid Card 12Gbps HBA HDD Controller High Profile IT MODE picture

Inspur LSI 9300-8i Raid Card 12Gbps HBA HDD Controller High Profile IT MODE

$15.98



LSI MegaRAID 9361-8i 12Gb PCIe 8-Port SAS/SATA RAID 1Gb w/BBU/CacheVault/License picture

LSI MegaRAID 9361-8i 12Gb PCIe 8-Port SAS/SATA RAID 1Gb w/BBU/CacheVault/License

$39.95



LSI MegaRAID 9361-8i 12Gbps PCIe 3 x8 SATA SAS 3 8 Port RAID + BBU & CacheVault picture

LSI MegaRAID 9361-8i 12Gbps PCIe 3 x8 SATA SAS 3 8 Port RAID + BBU & CacheVault

$39.00



ORICO Multi Bay RAID Hard Drive Enclosure USB 3.0/ Type-C For 2.5/3.5'' HDD SSDs picture

ORICO Multi Bay RAID Hard Drive Enclosure USB 3.0/ Type-C For 2.5/3.5'' HDD SSDs

$82.49



4 Bay RAID External Hard Drive Enclosure for 2.5/3.5

4 Bay RAID External Hard Drive Enclosure for 2.5/3.5" SATA HDD/SSD

$79.99



2 Bay RAID Hard Drive Enclosure USB 3.0 Type-B for 2.5

2 Bay RAID Hard Drive Enclosure USB 3.0 Type-B for 2.5" SATA SSD/HDD Enclosure

$59.99