summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-13 04:54:48 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-13 04:54:48 +0200
commitb7166385deb8939567735925f2e967f40452bec9 (patch)
treec0eb82bbb542b8e023ebdc375c985641e7de0a1c
parent43604bf71a21c31aad68114f8612a9c4180f22ad (diff)
downloadserenity-b7166385deb8939567735925f2e967f40452bec9.zip
RetroFetch: Add a silly neofetch-like program.
The idea is to print out various system info suitable for screenshots. :^)
-rw-r--r--Base/res/serenity.ansi.txt21
-rw-r--r--Demos/RetroFetch/.gitignore3
-rw-r--r--Demos/RetroFetch/Makefile21
-rw-r--r--Demos/RetroFetch/main.cpp71
-rwxr-xr-xKernel/makeall.sh2
-rwxr-xr-xKernel/sync.sh1
6 files changed, 119 insertions, 0 deletions
diff --git a/Base/res/serenity.ansi.txt b/Base/res/serenity.ansi.txt
new file mode 100644
index 0000000000..f7370e8c72
--- /dev/null
+++ b/Base/res/serenity.ansi.txt
@@ -0,0 +1,21 @@
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+
diff --git a/Demos/RetroFetch/.gitignore b/Demos/RetroFetch/.gitignore
new file mode 100644
index 0000000000..83be6f7100
--- /dev/null
+++ b/Demos/RetroFetch/.gitignore
@@ -0,0 +1,3 @@
+RetroFetch
+*.o
+*.d
diff --git a/Demos/RetroFetch/Makefile b/Demos/RetroFetch/Makefile
new file mode 100644
index 0000000000..eb73af2f8b
--- /dev/null
+++ b/Demos/RetroFetch/Makefile
@@ -0,0 +1,21 @@
+include ../../Makefile.common
+
+OBJS = main.o
+
+APP = RetroFetch
+
+DEFINES += -DUSERLAND
+
+all: $(APP)
+
+$(APP): $(OBJS)
+ $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc
+
+.cpp.o:
+ @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
+
+-include $(OBJS:%.o=%.d)
+
+clean:
+ @echo "CLEAN"; rm -f $(APP) $(OBJS) *.d
+
diff --git a/Demos/RetroFetch/main.cpp b/Demos/RetroFetch/main.cpp
new file mode 100644
index 0000000000..1b0abfdf08
--- /dev/null
+++ b/Demos/RetroFetch/main.cpp
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <AK/Assertions.h>
+
+static void moveto(int row, int column)
+{
+ printf("\033[%d;%dH", row, column);
+ fflush(stdout);
+}
+
+int main()
+{
+ printf("\033[3J\033[H\033[2J");
+ fflush(stdout);
+ int fd = open("/res/serenity.ansi.txt", O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ return 0;
+ }
+ for (;;) {
+ char buffer[BUFSIZ];
+ int nread = read(fd, buffer, sizeof(buffer));
+ if (nread < 0) {
+ perror("read");
+ return 1;
+ }
+ if (nread == 0)
+ break;
+ int nwritten = write(STDOUT_FILENO, buffer, nread);
+ if (nwritten < 0) {
+ perror("write");
+ return 1;
+ }
+ ASSERT(nwritten == nread);
+ }
+ close(fd);
+
+ printf("\n");
+ printf("\033[s");
+
+ char hostname[128];
+ int rc = gethostname(hostname, sizeof(hostname));
+ if (rc < 0) {
+ perror("gethostname");
+ return 1;
+ }
+
+ int column = 42;
+
+ moveto(3, column);
+ printf("%s@%s\n", getlogin(), hostname);
+
+ moveto(4, column);
+ printf("\033[34;1mOS:\033[0m Serenity\n");
+
+ moveto(5, column);
+ printf("\033[34;1mKernel:\033[0m ");
+ fflush(stdout);
+ system("uname -nrm");
+
+ moveto(6, column);
+ printf("\033[34;1mUptime:\033[0m ");
+ fflush(stdout);
+ system("uptime");
+
+ printf("\033[u\n");
+ return 0;
+}
+
diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh
index c46a637b62..73616b02af 100755
--- a/Kernel/makeall.sh
+++ b/Kernel/makeall.sh
@@ -50,6 +50,8 @@ $make_cmd -C ../Shell clean && \
$make_cmd -C ../Shell && \
$make_cmd -C ../Demos/HelloWorld clean && \
$make_cmd -C ../Demos/HelloWorld && \
+$make_cmd -C ../Demos/RetroFetch clean && \
+$make_cmd -C ../Demos/RetroFetch && \
$make_cmd clean &&\
$make_cmd && \
sudo ./sync.sh
diff --git a/Kernel/sync.sh b/Kernel/sync.sh
index 705e14cc97..86e685b7d9 100755
--- a/Kernel/sync.sh
+++ b/Kernel/sync.sh
@@ -80,6 +80,7 @@ ln -s Shell mnt/bin/sh
cp -v kernel.map mnt/
cp -v ../Demos/HelloWorld/HelloWorld mnt/bin/HelloWorld
ln -s HelloWorld mnt/bin/hw
+cp -v ../Demos/RetroFetch/RetroFetch mnt/bin/RetroFetch
# Run local sync script, if it exists
if [ -f sync-local.sh ]; then