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 | |
| 7 | include $(TOPDIR)/rules.mk |
| 8 | |
| 9 | PKG_NAME:=fbsize |
| 10 | PKG_VERSION:=0.0.1 |
| 11 | PKG_RELEASE:=1 |
| 12 | |
| 13 | include $(INCLUDE_DIR)/package.mk |
| 14 | |
| 15 | define Package/fbsize |
| 16 | SECTION:=utils |
| 17 | CATEGORY:=Utilities |
| 18 | TITLE:=fbsize shows current terminal size |
| 19 | SUBMENU:=Terminal |
| 20 | endef |
| 21 | |
| 22 | define Package/fbsize/description |
| 23 | fbsize, a dummy utility to show current terminal size (might be handy) |
| 24 | endef |
| 25 | |
| 26 | define Build/Compile |
| 27 | $(TARGET_CC) -o fbsize ./files/fbsize.c |
| 28 | endef |
| 29 | |
| 30 | define Package/fbsize/install |
| 31 | $(INSTALL_DIR) \ |
| 32 | $(1)/usr/bin |
| 33 | |
| 34 | $(INSTALL_BIN) \ |
| 35 | fbsize \ |
| 36 | $(1)/usr/bin/fbsize |
| 37 | |
| 38 | endef |
| 39 | |
| 40 | $(eval $(call BuildPackage,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 | |
| 7 | int |
| 8 | main(int argc,char **argv) |
| 9 | { |
| 10 | struct winsize ws; |
| 11 | |
| 12 | if (ioctl(0,TIOCGWINSZ,&ws)!=0) { |
| 13 | fprintf(stderr,"TIOCGWINSZ:%s\n",strerror(errno)); |
| 14 | exit(1); |
| 15 | } |
| 16 | printf("row=%d, col=%d, xpixel=%d, ypixel=%d\n", |
| 17 | ws.ws_row,ws.ws_col,ws.ws_xpixel,ws.ws_ypixel); |
| 18 | return 0; |
| 19 | } |
Download the corresponding diff file