From 33a3e2f268028b27bad00adcfc3210d8d04b7b05 Mon Sep 17 00:00:00 2001 From: sech1p Date: Sat, 6 Nov 2021 00:34:53 +0100 Subject: [PATCH] Add iOS support (partially) --- README.md | 5 ++++- res/ascii/ios.txt | 8 +++++++ uwufetch.1 | 3 ++- uwufetch.1.gz | Bin 1549 -> 1566 bytes uwufetch.c | 53 ++++++++++++++++++++++++++++++++++++---------- 5 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 res/ascii/ios.txt diff --git a/README.md b/README.md index d4d9061..3f7adaf 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ AmogOwOS, Nyalpine, Nyarch Linuwu, ArcOwO, Nyartix Linuwu, Debinyan, endevaOwO, ### Partial support (Either no ASCII art, or no image is provided) -KDE NeOwOn, nixOwOs, xuwulinux; Plus FweeBSD, OwOpenBSD and macOwOS; Plus WinyandOwOws. +KDE NeOwOn, nixOwOs, xuwulinux; Plus FweeBSD, OwOpenBSD, macOwOS and iOwOS; Plus WinyandOwOws. ## Building and installation @@ -38,6 +38,7 @@ Build requisites: - Make - A C compiler + - A iOS patched SDK (if you build UwUfetch under iOS device) To install UwUfetch from the source, type these commands in the terminal: @@ -70,6 +71,8 @@ make termux_uninstall # uninstall for termux ### How to use images +Notice: images are currently disabled under iOS due to lack of a one command in UwUfetch code + First of all, you will need `viu`, which you can install by following the [guide](https://github.com/atanunq/viu#installation). `viu` supports [kitty](https://github.com/kovidgoyal/kitty) and [iTerm](https://iterm2.com/)'s image protocols. diff --git a/res/ascii/ios.txt b/res/ascii/ios.txt new file mode 100644 index 0000000..552873e --- /dev/null +++ b/res/ascii/ios.txt @@ -0,0 +1,8 @@ + {GREEN} .:` + .--``--. +{YELLOW} ww OωO w +{RED} w w +{PINK} w w + +{BLUE} www_-_www + diff --git a/uwufetch.1 b/uwufetch.1 index 44da023..dc294d7 100644 --- a/uwufetch.1 +++ b/uwufetch.1 @@ -27,7 +27,7 @@ you can choose the logo to print by the distro name prints a help page .TP .B -i --image -prints image instead of ascii logo uses a custom image if one is provided +prints image instead of ascii logo uses a custom image if one is provided (disabled on iOS) .TP .B -l --list prints a list of all supported distributions @@ -89,6 +89,7 @@ xuwulinux \fBxerolinux\fR FweeBSD \fBfreebsd\fR OwOpenBSD \fBopenbsd\fR macOwOS \fBmacos\fR +iOwOS \fBios\fR WinyandOwOws \fBwindows\fR .EE .SH EXAMPLES diff --git a/uwufetch.1.gz b/uwufetch.1.gz index e96679abc3679d5e0e581f512274c67b7e7d60ae..566e89874e9baf6b71089d7d79a8ad0880f998bb 100644 GIT binary patch delta 1516 zcmV44w=JABzYG;k|{C2S$GkXLx2fGreyYY`~OsP6?Ll%vYjz+(})tLK{|i z=Z#?AilhhRqLh|#mgy?MqUebk@vj%wF)N&9t`yA4aGEY?QSq8Jd@UHSa}rpQ(fOAv z;aVYT_KCKByQ1^vPmF9dMpoSH4(L+wT-NJoa~f^=2AWLPIh+wWtQfvFyeWTKD_zMH zUkOF{J2bbD zFmK8Ij=sPt&z$Ef?j=3MWchz(`H(K|pFr-#=U>^tuRS94`KQmHF4)DV-Y@tauu4=g zyR%MIIIz&nX{{*k&$9O0i=>BW4Ac4jY&2brCgWt;E(_tZavvfMx`V21q(J~yJ5~!F z5#gGiKCj^+cgzvHC)P|A^DH0{?HU13BgB((VwTahmk* z*bQelH)Ja5ybOc~VvHJf#JtcUNF=nm6Ln@-+K)A)Xt)9GZkNQZ1V znlEOfyJdV4!;=6}(uJf2FOdtXaUB~E%jf6U<2l62c*j)}YUjxxl%p^x0|3UT_O$*4 zVCeNG1CveK$@jLk3gv2lgp=Dd5Mdw;`$Msk^$wvv_aT3Wn9~IWnhAdkcFq7%ti1`C z2a)TRGxqL~0%F4h;1T`k{0IW9A=a7zb*Nu!{J_@}fRA3j$TmFk_xf~8R7OV_+~ObJ z>UWqbNR2*248FX4MBH#w1r+>jL_J^5)3b9lgcb>TqXcgPZmJswtbJ#%(X>0`wi$oq z)j+&wcHV#TY}4{qoI|W4v7rpGu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A?MWK7)kvh(hvEZ))A* zDdPN=n%!0O5XDsD;gWP^K6)8Erff1}gZcev#3tkCS1R>ErPoKYf(HmR9pR5*%Ekhl zb+?82NOo(vJ>fTO$Zb^FqLeB3`<<;Y$C7`*$iIJ^5083<5n^TYV{-SqU0S=niihho zKP`+b`ujpxB*$)RX$RGainoW;AKTrWj=OKRp&if_{_yuhH#2C43<4x@d!l&L4HK&? z@i+C%&>w?hH#E+M%_ZJGg~#xqHjOzDI=jfPP7KNzj5}Vivq%QCb9^SS%eIu=Ge%jA zxYmDP9S%E8r|Ec@j_*e)Jp$NoVXi4#wh5kGc$_eFVtT>sXWpCiaoR-}_WOf$kKW+1 zz1y3LF}+FA(&KiT3~n4#MH6~aoykBa9^$e0a@E6ATwon!U?;r5=>>MG5Z^-2 zqx*D>>pmC{F<_^!v(e+z;>g^|1ZQ}SBBDz${T`>!KVxiX=nCSR9)y{0c1EsC7axiy zoUU}PvA_5GYdp#P3bVNCBdQ@cn>&9plN~CwUvXLY!#q61(5v!Z@;@f_h!1}Z004Aj B>DvGR diff --git a/uwufetch.c b/uwufetch.c index a2cc9c8..e8a2232 100644 --- a/uwufetch.c +++ b/uwufetch.c @@ -15,6 +15,9 @@ #define _GNU_SOURCE // for strcasestr +#ifdef __APPLE__ +#include // for checking iOS +#endif #include #include #include @@ -378,7 +381,7 @@ int pkgman() } #ifdef __APPLE__ -int uptime_mac() +int uptime_apple() { int mib[2] = {CTL_KERN, KERN_BOOTTIME}; sysctl(mib, 2, &time_buffer, &time_buffer_len, NULL, 0); @@ -457,7 +460,7 @@ void print_info() responsively_printf(print_buf, "%s%s%sSHEWW %s%s", terminal_cursor_move, NORMAL, BOLD, NORMAL, shell); -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(TARGET_OS_IPHONE) if (show_pkgs) system("ls $(brew --cellar) | wc -l | awk -F' ' '{print \" \x1b[34mw w \x1b[0m\x1b[1mPKGS\x1b[0m \"$1 \" (brew)\"}'"); #else @@ -472,7 +475,7 @@ void print_info() { #ifdef __APPLE__ - uptime = uptime_mac(); + uptime = uptime_apple(); #else #ifdef __FREEBSD__ uptime = uptime_freebsd(); @@ -517,7 +520,7 @@ void write_cache() return; // writing all info to the cache file #ifdef __APPLE__ - uptime = uptime_mac(); + uptime = uptime_apple(); #else #ifdef __FREEBSD__ uptime = uptime_freebsd(); @@ -755,7 +758,7 @@ void get_info() fclose(os_release); } else - { // try for android vars, next for macOS var, or unknown system + { // try for android vars, next for Apple var, or unknown system DIR *system_app = opendir("/system/app/"); DIR *system_priv_app = opendir("/system/priv-app/"); DIR *library = opendir("/Library/"); @@ -779,13 +782,17 @@ void get_info() break; #endif } - else if (library) // macOS + else if (library) // Apple { closedir(library); #ifdef __APPLE__ sysctlbyname("machdep.cpu.brand_string", &cpu_buffer, &cpu_buffer_len, NULL, 0); + #ifndef TARGET_OS_IPHONE sprintf(version_name, "macos"); + #else + sprintf(version_name, "ios"); + #endif sprintf(cpu_model, "%s", cpu_buffer); #endif } @@ -1038,13 +1045,13 @@ void list(char *arg) " %sDebian/%sUbuntu %sbased:\n" " %samogos, debian, %slinuxmint, neon %spop, %sraspbian %subuntu\n\n" " %sBSD %sbased:\n" - " %sfreebsd, %sopenbsd, %sm%sa%sc%so%ss\n\n" + " %sfreebsd, %sopenbsd, %sm%sa%sc%so%ss, %sios\n\n" " %sOther/spare distributions:\n" " %salpine, %sfedora, %sgentoo, %sslackware, %ssolus, %svoid, opensuse-leap, android, %sgnu, guix, %swindows, %sunknown\n\n", arg, BLUE, NORMAL, BLUE, MAGENTA, GREEN, BLUE, // Arch based colors RED, YELLOW, NORMAL, RED, GREEN, BLUE, RED, YELLOW, // Debian based colors - RED, NORMAL, RED, YELLOW, GREEN, YELLOW, RED, PINK, BLUE, // BSD colors + RED, NORMAL, RED, YELLOW, GREEN, YELLOW, RED, PINK, BLUE, WHITE, // BSD/Apple colors NORMAL, BLUE, BLUE, PINK, MAGENTA, WHITE, GREEN, YELLOW, BLUE, WHITE); // Other/spare distributions colors } @@ -1156,6 +1163,7 @@ void print_ascii() void print_image() { // prints logo (as an image) of the given system. distributions listed alphabetically. +#ifndef TARGET_OS_IPHONE char command[256]; if (strlen(image_name) > 1) sprintf(command, "viu -t -w 18 -h 8 %s 2> /dev/null", image_name); @@ -1179,6 +1187,16 @@ void print_image() " for more info.\n\n", RED); } +#else +// unfortunately, the iOS stdlib does not have system(); +// because it reports that it is not available under iOS during compilation + printf("\033[0E\033[3C%s\n" + " There was an\n" + " error: images\n" + " are currently\n" + " disabled on iOS.\n\n", + RED); +#endif } void usage(char *arg) @@ -1188,13 +1206,24 @@ void usage(char *arg) " -c --config use custom config path\n" " -d, --distro lets you choose the logo to print\n" " -h, --help prints this help page\n" +#ifndef TARGET_OS_IPHONE " -i, --image prints logo as image and use a custom image if provided\n" " %sworks in most terminals\n" +#else + " -i, --image prints logo as image and use a custom image if provided\n" + " %sdisabled under iOS\n" +#endif " read README.md for more info%s\n" " -l, --list lists all supported distributions\n" " -w, --write-cache writes to the cache file (~/.cache/uwufetch.cache)\n" " using the cache set $UWUFETCH_CACHE_ENABLED to TRUE, true or 1\n", - arg, BLUE, NORMAL); + arg, +#ifndef TARGET_OS_IPHONE + BLUE, +#else + RED, +#endif + NORMAL); } #ifdef __WINDOWS__ @@ -1270,8 +1299,9 @@ void uwu_kernel() // BSD else KERNEL_TO_UWU(splitted[i], "freebsd", "FweeBSD"); else KERNEL_TO_UWU(splitted[i], "openbsd", "OwOpenBSD"); - + //// Apple family else KERNEL_TO_UWU(splitted[i], "macos", "macOwOS"); + else KERNEL_TO_UWU(splitted[i], "ios", "iOwOS"); // Windows else KERNEL_TO_UWU(splitted[i], "windows", "WinyandOwOws"); @@ -1348,8 +1378,9 @@ void uwu_name() // BSD else STRING_TO_UWU("freebsd", "FweeBSD"); else STRING_TO_UWU("openbsd", "OwOpenBSD"); - + //// Apple family else STRING_TO_UWU("macos", "macOwOS"); + else STRING_TO_UWU("ios", "iOwOS"); // Windows else STRING_TO_UWU("windows", "WinyandOwOws");