about summary refs log blame commit diff stats
path: root/src/menu.c
blob: b5173bb054d710306523fde50da226ffe555ef12 (plain) (tree)
1
2
3
4
5
6
7
8
                    
                   

                
 
 
                    
                                          






                                      
                                                         
                     

                           
                            

 
                               
                           

                                


                               



                                     


                                                                
 
                
                            
 
#include <ncurses.h>
#include <string.h>

#include "lua.h"


int menu_column = 0;
void draw_string_on_menu (const char* s) {
  mvaddstr(LINES-1, menu_column, " ");
  ++menu_column;
  mvaddstr(LINES-1, menu_column, s);
  menu_column += strlen(s);
  mvaddstr(LINES-1, menu_column, " ");
  ++menu_column;
}
void draw_menu_item (const char* key, const char* name) {
  attroff(A_REVERSE);
  draw_string_on_menu(key);
  attron(A_REVERSE);
  draw_string_on_menu(name);
}

void draw_menu (lua_State *L) {
  attron(A_BOLD|A_REVERSE);
  for (int x = 0; x < COLS; ++x)
    mvaddch(LINES-1, x, ' ');
  menu_column = 2;
  draw_menu_item("^x", "exit");
  draw_menu_item("^e", "edit");

  /* render any app-specific items */
  lua_getglobal(L, "menu");
  int table = lua_gettop(L);
  if (lua_istable(L, -1))
    for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1))
      draw_menu_item(lua_tostring(L, -2), lua_tostring(L, -1));

  lua_pop(L, 1);
  attroff(A_BOLD|A_REVERSE);
}
{ color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#+TITLE: Cetus

Cetus is a wallpaper tool written in Go. It can set wallpapers from various
sources. Default behaviour is to set a random wallpaper.

* Uses
- on system startup for new wallpaper at every startup
- as a cron job to change wallpaper at set intervals
* Demo
I just run some cetus commands on my computer, nothing fancy. I'll make better
demo videos someday.

| Version | Video                                                                |
|---------+----------------------------------------------------------------------|
| v0.2.0  | https://diode.zone/videos/watch/12db31e1-3517-4888-ad06-55f3859447a1 |
* Features
- Set Daily, Weekly or Random wallpaper
- Supports multiple sources
* Dependency
- [[https://feh.finalrewind.org/][feh]]
* Examples
** Daily wallpaper
*** from Astronomy Picture of the Day
#+BEGIN_SRC sh
cetus -src=apod -wall=daily
#+END_SRC
*** from Bing Photo of the Day
#+BEGIN_SRC sh
cetus -src=bpod -wall=daily
#+END_SRC
*** from Unsplash Source
#+BEGIN_SRC sh
cetus -src=unsplash -wall=daily
#+END_SRC
*** from any service (choosen randomly)
#+BEGIN_SRC sh
cetus -src=random -wall=daily

cetus -wall=daily # This is same as above
#+END_SRC
** Weekly wallpaper
*** from Unsplash Source
#+BEGIN_SRC shp
cetus -src=unsplash -wall=weekly
#+END_SRC
** Random wallpaper
*** from Bing Photo of the Day
#+BEGIN_SRC sh
cetus -src=bpod -bpod-num 16 -wall=random # select from last 16 images

cetus -src=bpod # This is same as above
#+END_SRC
*** from Unsplash Source
#+BEGIN_SRC sh
cetus -src=unsplash -wall=random -width 1920 -height 1080

cetus -src=unsplash # This is same as above
#+END_SRC
*** from any service (choosen randomly)
#+BEGIN_SRC sh
cetus -src=random -wall=random

cetus # This is same as above
#+END_SRC
* Defaults
| flag | var  | default                                   |
|------+------+-------------------------------------------|
| wall | wall | random (daily when random is unavailable) |
| src  | src  | random                                    |

Currently only Unsplash Source random is supported for width, height
| width  | width  | 1920 |
| height | height | 1080 |
** Astronomy Picture of the Day
| flag         | var        | default                             |
|--------------+------------+-------------------------------------|
| apod-api     | apodAPI    | https://api.nasa.gov/planetary/apod |
| apod-api-key | apodAPIKey | DEMO_KEY                            |
| wall         | wall       | daily                               |
** Bing Photo of the Day
| flag     | var     | default                                  |
|----------+---------+------------------------------------------|
| bpod-api | bpodAPI | https://www.bing.com/HPImageArchive.aspx |
| bpod-num | bpodNum | 7 (max 7)                                |
** Unsplash Source
| flag         | var         | default                     |
|--------------+-------------+-----------------------------|
| unsplash-api | unsplashAPI | https://source.unsplash.com |