Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 10 Dec 2018, 16:33
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
cal command alternatives
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [26 Posts]   Goto page: Previous 1, 2
Author Message
rufwoof

Joined: 24 Feb 2014
Posts: 2706

PostPosted: Sat 01 Dec 2018, 09:14    Post subject:  

MochiMoppel wrote:
@ rufwoof: cal chokes on $1 $2. Works when I place IFS='|' after the cal commands

Thanks. That IFS setting is unneccessary so I've edit that post to just IFS=

_________________
( ͡° ͜ʖ ͡°) :wq
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 2706

PostPosted: Sat 01 Dec 2018, 09:17    Post subject:  

musher0 wrote:
Finally, perhaps I'm way off, but shouldn't there be a mention of calcurse
on this thread?

I do mostly use calcurse myself, but also don't forget osmo

_________________
( ͡° ͜ʖ ͡°) :wq
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13147
Location: Gatineau (Qc), Canada

PostPosted: Sat 01 Dec 2018, 10:15    Post subject:  

Osmo? Yerk! Twisted Evil
_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1705
Location: Japan

PostPosted: Sat 01 Dec 2018, 10:27    Post subject:  

Here is my attempt. Not better than anything presented so far, hopefully not much worse. I tried to implement the idea to cut the first column, add it to the right and then shift it one notch up.
It can easily be made portable (executable with busybox ash) by redirecting SUND and REST to temp files and then reading these files with paste. I just don't like tmp files Crying or Very sad
Code:
 #!/bin/bash
## Usage: scriptname [month [year]]
## Defaults to current month year if no parameters passed
MNTH=${1:-$(date +%m)}
YEAR=${2:-$(date +%Y)}
CLDR=$(cal $MNTH $YEAR)
BODY=$(echo "$CLDR" | tail +3)
HEAD=$(echo "$CLDR" | head -2 | sed -r '2s/(...)(.*)/\2 \1/')
EMTY='                     '
BODY=$EMTY$'\n'$BODY
BODY=$(echo "$BODY" | sed  -r "s/.*/&$EMTY/ ; s/(.{21}).*/\1/")
SUND=$(echo "$BODY" | grep -o ^... | tail +2)
REST=$(echo "$BODY" | grep -o ..................$)
BODY=$(paste -d '' <(echo -n "$REST" ) <(echo -n "$SUND" )  )
BODY=$(echo "$BODY" | sed -r "s/ *$//; /^ *$/d")
echo "$HEAD"$'\n'"$BODY"
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13147
Location: Gatineau (Qc), Canada

PostPosted: Sat 01 Dec 2018, 10:53    Post subject:  

Hi MM.

Thanks.

The script name is... ?

Right up my alley, too. I love gory variable names, such as Body, Head.
Plus you're inflicting all sorts of operations on them. Miam.
(Blame that dark humor on the Kashoggi affair...)

Never mind the script name. I decided to call it "gory-cal.sh" Twisted Evil

BFN.

_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 2706

PostPosted: Sat 01 Dec 2018, 12:06    Post subject:  

Very nice!
_________________
( ͡° ͜ʖ ͡°) :wq
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 175

PostPosted: Thu 06 Dec 2018, 11:10    Post subject:  

MochiMoppel wrote:
torm wrote:
util-linux cal command output on the screenshot is correct for my locale, while
the BusyBox output is "somewhat strange", if you look at the details..
And what is your locale?
If busybox cal fails to display weekday abbreviations then I would consider this to be a serious bug. Would make no sense to start any reformatting acrobatic before this issue is solved.

On the other hand I have found no other reports regarding this issue. Strange indeed.


et_EE
Weekday abbreviations appear to be broken in tahrpup32bit606 and 64bit605 while 32bit605 is ok, no idea..
Other calendar programs/commands work fine, and for now I just skip anything BusyBox cal related.
Well.. until I have a solid fix for it.
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 175

PostPosted: Thu 06 Dec 2018, 11:15    Post subject:  

ncal

ncal is a small ( around 20-30 kb size ) FreeBSD alternative to cal command.
It should be possible to extract official version of ncal from bsdmainutils package.
ncal is released under MIT-style license.

ncal supports:
-full year view
-horizontal and vertical weeks layout
-week-start-day from current locale or by option
-julian dates
-3 months view
-years 1 to 9999
-month selection by number ( 1 - 12 ) or month name in the current locale
-... and then some more stuff, like Easter date, etc.

dependencies:
libtinfo.so.5 ( ncurses ) is most likely pre-installed in puppy.

Official source turned out to be a bit "unusual" , so I made a more compact and
stand-alone source package for it, to simplify compile and install.
Think of it as TEST source at this point.
There is manpage and a small README included, read them when in doupt.

Should compile and install with:
make
make install

To run ncal with the usual cal layout, type:
ncal -b

To view manual page for more options, type:
man ncal
ncal_C-source_01.tar.gz
Description  ncal C source and user manual
gz

 Download 
Filename  ncal_C-source_01.tar.gz 
Filesize  22.48 KB 
Downloaded  5 Time(s) 
ncal_different_layouts.jpg
 Description   ncal with different layouts
 Filesize   55.68 KB
 Viewed   144 Time(s)

ncal_different_layouts.jpg

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1705
Location: Japan

PostPosted: Fri 07 Dec 2018, 05:17    Post subject:  

torm wrote:
Other calendar programs/commands work fine, and for now I just skip anything BusyBox cal related.
I noticed that in your list of cal alternatives you didn't mention dialog, with layout very similar to cal and - as a CLI application - pretty lightweight. Unlike cal it's interactive.
Code:
#!/bin/bash
OUTPUT=$(dialog --stdout --calendar "" 0 0 15 8 2018)
clear
echo "You selected: $OUTPUT"
dialog--calendar.png
 Description   
 Filesize   6.13 KB
 Viewed   98 Time(s)

dialog--calendar.png

Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 13147
Location: Gatineau (Qc), Canada

PostPosted: Fri 07 Dec 2018, 06:34    Post subject:  

Torm did not mention it because it is ugly!... Twisted Evil (IMO)
_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
torm


Joined: 07 Mar 2015
Posts: 175

PostPosted: Yesterday, at 10:37    Post subject:  

How to set the correct week-start-day in dialog ( cdialog ) ?
By patching the preinstalled binary in puppy .. ?

PS.
It is not about how it looks - that would be a matter of settings.
Type:
dialog --create-rc /root/.dialogrc
..and edit that file. Wink
dialog_calendar.jpg
 Description   dialog_screenshot
 Filesize   69.85 KB
 Viewed   32 Time(s)

dialog_calendar.jpg

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 2 [26 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0819s ][ Queries: 13 (0.0148s) ][ GZIP on ]