Choose style:

Author Topic: Random choice (SOLVED)  (Read 674 times)

0 Members and 1 Guest are viewing this topic.

Offline emegra

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1885
  • Karma: 410
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 9 64bit
Random choice (SOLVED)
« on: December 14, 2017, 04:59:22 pm »
Hi guys
I'm looking for a bit of help I'm trying to write a conky script that will display a random entry from the calendar command as per the screenshot and my coding skills are not quite up to the task



as you can see from the screenshot my script works but it's only displaying the first line in the calendar command I would like it to display random entries from the command every n seconds or minutes

below is the line of code I've used to display the first entry
Code: [Select]
${goto -50}${font Tall Films:size=60}${execi 10 calendar | head -n1}

As you can see my coding skills are quite basic so is it possible to select a random entry and display it at a preset interval instead of just the first entry ?

Many thanks


Graeme

« Last Edit: December 16, 2017, 05:01:04 am by emegra »
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Random choice
« Reply #1 on: December 14, 2017, 05:30:56 pm »
Code: [Select]
${goto -50}${font Tall Films:size=60}${execi 10 calendar | shuf -n 1}
maybe ?

"shuf -n 1" randomly shuffles the output from calendar then displays a single line.
« Last Edit: December 14, 2017, 05:33:14 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline emegra

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1885
  • Karma: 410
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 9 64bit
Re: Random choice
« Reply #2 on: December 16, 2017, 05:00:09 am »
I've never heard of the shuf command before but that was the answer works perfectly

Thank you :)



Graeme
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Random choice (SOLVED)
« Reply #3 on: December 16, 2017, 08:17:28 am »
Glad it did what you wanted .. and you're welcome :)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Online VinDSL

  • Global Moderator
  • Hero
  • *****
  • Posts: 5309
  • Karma: 943
  • Peppermint Mod
    • View Profile
  • Peppermint version(s): Developmental Builds
Re: Random choice (SOLVED)
« Reply #4 on: December 16, 2017, 08:03:21 pm »
Heh! Guess I need to work on my Conky, too   ;D

I swapped out a couple of monitors in my tree - 2 x 19" Dells to 2 x 23" AOCs.

Took a few minutes to remember how to go about setting up the telemetry in LXRandr.

Here's the 'lxrandr-autostart.desktop' respin:

Code: [Select]
[Desktop Entry]
Type=Application
Name=LXRandR autostart
Comment=Start xrandr with settings done in LXRandR
Exec=sh -c 'xrandr --output HDMI-0 --mode 2560x1080 --pos 610x0 --rate 60.00 --output DVI-D-0 --mode 1920x1080 --pos 0x1080 --rate 60.00 --output VGA-0 --mode 1920x1080 --pos 1920x1080 --rate 60.00'
OnlyShowIn=LXDE

 Now, for the fun part. Check out my poor Conky ...  ::)





Bwahahahahaha! That's good for about 6 hours of moving things around, pixel by pixel.
« Last Edit: December 16, 2017, 08:15:05 pm by VinDSL, Reason: Typo Demon Strikes Again »

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Random choice (SOLVED)
« Reply #5 on: December 17, 2017, 07:20:47 am »
Ya still got a bit of work to do there mate :)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Online VinDSL

  • Global Moderator
  • Hero
  • *****
  • Posts: 5309
  • Karma: 943
  • Peppermint Mod
    • View Profile
  • Peppermint version(s): Developmental Builds
Re: Random choice (SOLVED)
« Reply #6 on: December 17, 2017, 12:08:52 pm »
Took a little over 5 hours - labor of love, you know?   8)

I have one file (weather widget) that I've never commented (which is unlike me) and it's always a challenge. 

Code: [Select]
#################################################
## VinDSL | rev. 17-12-16 22:17 | ver. GRAPHIC ##
#################################################
## IMPERIAL WEATHER TEMPLATE for Conkywx 5.0.0 ##
#################################################
${voffset -4}${font RadioSpace:size=31.8}${color6}${alignc -18}[PT]${font}${font Arrows:size=26}${voffset -13}${offset 2}${color6}[FCTTF]${font}
${voffset 5}${font DroidSansFallback:bold:size=7.4}${alignc 6}${color5}Feels${offset 3}like${offset 1}:${offset 2}${color6}[FL]${offset 2}${color5}/${offset 3}${color6}[FCTT]${font}
${voffset -58}${goto 188}${font KRARound:size=41.6}${color6}I${font}
${voffset -37}${goto 203}${font DroidSansFallback:bold:size=8.3}${color6}[D1T]${font}
${voffset -5}${goto 203}${font DroidSansFallback:bold:size=7.2}${color5}CoR${offset 3}${color6}[D1P]${font}
${voffset 12}${font Ubuntu:size=22.75}${color5}${alignc}[CT]${font}
${voffset 7}${goto 34}${font DroidSansFallback:bold:size=8}${color5}Sunrise${offset 1}:${offset 1}${color6}[SR]${font}${voffset -2}${offset 3}${font Arrows:size=14}${color6}[FCTSRF]${font}${voffset -1}${offset 10}${font DroidSansFallback:bold:size=8}${color5}Sunset${offset 1}:${offset 1}${color6}[SS]${font}${voffset -2}${offset 3}${font Arrows:size=14}${color6}[FCTSSF]${font}
${voffset 8}${goto 87}${font DroidSansFallback:bold:size=7.55}${color5}Humidity${offset 1}:${offset 2}${color6}[HM]${font}${voffset -2}${offset 4}${font Arrows:size=14}${color6}[FCTHF]${font}${voffset 11}${goto 86}${font DroidSansFallback:bold:size=7.55}${color5}Barometer${offset 1}:${offset 2}${color6}[BR]${font}${voffset -2}${offset 4}${font Arrows:size=14}${color6}[FCTPF]${font}${voffset 11}${goto 86}${font DroidSansFallback:bold:size=7.55}${color5}Moonrise${offset 1}:${offset 1}${color6}[MR]${font}${voffset -2}${offset 4}${font Arrows:size=14}${color6}[FCTMRF]${font}${voffset 11}${goto 86}${font DroidSansFallback:bold:size=7.55}${color5}Moonset${offset 1}:${offset 1}${color6}[MS]${font}${voffset -2}${offset 4}${font Arrows:size=14}${color6}[FCTMSF]${font}${voffset 11}${goto 87}${font DroidSansFallback:bold:size=7.55}${color5}Full${offset 3}Moon${offset 1}:${offset 2}${color6}[FM]${font}
${voffset -65}${goto 16}${font ConkyWindNESW:size=41.6}${color6}[BF]${font}
${voffset -31}${font DroidSans:bold:size=10.5}${color6}${alignc -91}[MV]${font}
${voffset 15}${goto 22}${font DroidSans:bold:size=8.45}${color3}[WS] mph${voffset 0}${goto 205}[MP]${font}
${voffset 9}${goto 24}${font DroidSans:bold:size=8.5}${color5}[D2D]${goto 85}[D3D]${goto 142}[D4D]${goto 200}[D5D]${font}
${image [PIC] -p 12,535-s 48x48}${image [D2I] -p 20,758 -s 34x34}${image [D3I] -p 81,758 -s 34x34}${image [D4I] -p 138,758 -s 34x34}${image [D5I] -p 197,758 -s 34x34}${image [MIC] -p 188,662 -s 46x46}
${voffset 25}${goto 23}${font DroidSansFallback:bold:size=8.5}${color3}[D2T]${goto 84}[D3T]${goto 142}[D4T]${goto 200}[D5T]${font}
${voffset -1}${goto 23}${font DroidSans:bold:size=8.45}${color5}CoR${offset 3}${color3}[D2P]${goto 84}${color5}CoR${offset 3}${color3}[D3P]${goto 142}${color5}CoR${offset 3}${color3}[D4P]${goto 200}${color5}CoR${offset 3}${color3}[D5P]${font}

Plus, I realized I hadn't updated the algo that's determines which months contain 6 calendar weeks since last December (outta sight, outta mind).

It adjusts the calendar geometry accordingly. Won't need to do it again until Dec 2019 ;D

Code: [Select]
## Uncomment for "SUNDAY = First Day-of-the-Week" valid Dec.2017 - Dec.2019 (use mono fonts only)
## Tweaked for proper alignment of annoying months with six calendar weeks.
${if_match "${time %b %G}"=="Dec 2017"}${voffset -72}${else}${if_match "${time %b %G}"=="Sep 2018"}${voffset -72}${else}${if_match "${time %b %G}"=="Dec 2018"}${voffset -72}${else}${if_match "${time %b %G}"=="Mar 2019"}${voffset -72}${else}${voffset -66}${endif}${endif}${endif}${endif}${font DroidSansMono:size=7.55}${color3}${execpi 60 VinDSL_Cal_9=`date +%-d`; cal -h | sed -e 's/\r//g' -e 's/^/ /g' -e '1d' -e s/^/"\$\{offset 100"\}/ -e 's/\<'"$VinDSL_Cal_9"'\>/${color9}&${color3}/'}

Anyway, that's good enough for now. I'm always fiddling with it ...



Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 25661
  • Karma: 2819
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Random choice (SOLVED)
« Reply #7 on: December 17, 2017, 12:11:58 pm »
enough for now. I'm always fiddling with it ...

Too much info ?
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec