Date:2010-07-28 17:37:46 (10 years 7 months ago)
Author:kyak
Commit:2fe6ccee025915304ce8ce384337ed9c7094cea8
Message:fbsize, a small utility to show current terminal size

Files: fbsize/Makefile (1 diff)
fbsize/fbsize (0 diffs)
fbsize/files/fbsize.c (1 diff)

Change Details

fbsize/Makefile
1#
2# kyak@freenode/#qi-hardware
3#
4# This is free software, licensed under the GNU General Public License v2.
5#
6
7include $(TOPDIR)/rules.mk
8
9PKG_NAME:=fbsize
10PKG_VERSION:=0.0.1
11PKG_RELEASE:=1
12
13include $(INCLUDE_DIR)/package.mk
14
15define Package/fbsize
16  SECTION:=utils
17  CATEGORY:=Utilities
18  TITLE:=fbsize shows current terminal size
19  SUBMENU:=Terminal
20endef
21
22define Package/fbsize/description
23  fbsize, a dummy utility to show current terminal size (might be handy)
24endef
25
26define Build/Compile
27    $(TARGET_CC) -o fbsize ./files/fbsize.c
28endef
29
30define Package/fbsize/install
31    $(INSTALL_DIR) \
32        $(1)/usr/bin
33
34    $(INSTALL_BIN) \
35        fbsize \
36        $(1)/usr/bin/fbsize
37
38endef
39
40$(eval $(call BuildPackage,fbsize))
fbsize/fbsize
fbsize/files/fbsize.c
1#include <sys/ioctl.h>
2#include <string.h>
3#include <errno.h>
4#include <stdlib.h>
5#include <stdio.h>
6
7int
8main(int argc,char **argv)
9{
10struct winsize ws;
11
12if (ioctl(0,TIOCGWINSZ,&ws)!=0) {
13fprintf(stderr,"TIOCGWINSZ:%s\n",strerror(errno));
14exit(1);
15}
16printf("row=%d, col=%d, xpixel=%d, ypixel=%d\n",
17ws.ws_row,ws.ws_col,ws.ws_xpixel,ws.ws_ypixel);
18return 0;
19}

Archive Download the corresponding diff file



interactive