scripts

random assortment of scripts
git clone git://git.andersuno.nu/scripts.git
Log | Files | Refs

commit 3eaa155809538894571a8a58e447094ddfcdd04e
Author: andersuno <anders.hedman01@gmail.com>
Date:   Thu,  9 Jan 2020 02:21:48 +0100

 Initial commit

 Changes to be committed:
	new file:   .scriptmenu
	new file:   brightdown.sh
	new file:   brightup.sh
	new file:   bspwmscreenOFF.sh
	new file:   bspwmscreenVGA.sh
	new file:   dotfilesync.sh
	new file:   emojilist.txt
	new file:   emojimenu.sh
	new file:   hello.sh
	new file:   keepasssync.sh
	new file:   newsboatreload.sh
	new file:   pacmanupdates.sh
	new file:   pfetch
	new file:   polybar.sh
	new file:   screenoutput.sh
	new file:   surfraw.sh
	new file:   sxhkd.sh
	new file:   terminator.sh
	new file:   terminatorlayout.sh
	new file:   timeshiftsync.sh
	new file:   uber.sh

Diffstat:
A.scriptmenu | 8++++++++
Abrightdown.sh | 15+++++++++++++++
Abrightup.sh | 15+++++++++++++++
AbspwmscreenOFF.sh | 3+++
AbspwmscreenVGA.sh | 4++++
Adotfilesync.sh | 5+++++
Aemojilist.txt | 1401+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aemojimenu.sh | 18++++++++++++++++++
Ahello.sh | 3+++
Akeepasssync.sh | 9+++++++++
Anewsboatreload.sh | 14++++++++++++++
Apacmanupdates.sh | 21+++++++++++++++++++++
Apfetch | 1401+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apolybar.sh | 5+++++
Ascreenoutput.sh | 23+++++++++++++++++++++++
Asurfraw.sh | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asxhkd.sh | 4++++
Aterminator.sh | 4++++
Aterminatorlayout.sh | 4++++
Atimeshiftsync.sh | 14++++++++++++++
Auber.sh | 9+++++++++
21 files changed, 3104 insertions(+), 0 deletions(-)

diff --git a/.scriptmenu b/.scriptmenu @@ -0,0 +1,8 @@ +#!/bin/sh + +chosen=$(find "$HOME/Scripts/" -perm /u+x -type f -printf "%f\n" | sort | dmenu -i -l 20 -fn Monospace-16) + +[ "$chosen" != "" ] || exit + +notify-send "$chosen" "Running Script" +"$HOME/Scripts/$chosen" diff --git a/brightdown.sh b/brightdown.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +brightness_file=/sys/class/backlight/intel_backlight/brightness +brightness=$(< $brightness_file) + +if [ $((brightness > 0)) '=' 1 ] +then + brightness=$((brightness - 10)) + + if [ $((brightness < 1)) '=' 1 ] + then + brightness=1 + fi + echo -n $brightness > $brightness_file +fi diff --git a/brightup.sh b/brightup.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +brightness_file=/sys/class/backlight/intel_backlight/brightness +brightness=$(< $brightness_file) + +if [ $((brightness < 187)) '=' 1 ] +then + brightness=$((brightness + 10)) + + if [ $((brightness > 187)) '=' 1 ] + then + brightness=187 + fi + echo -n $brightness > $brightness_file +fi diff --git a/bspwmscreenOFF.sh b/bspwmscreenOFF.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +bspc monitor eDP1 -d I II III IV V VI VII VIII IX X diff --git a/bspwmscreenVGA.sh b/bspwmscreenVGA.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +bspc monitor eDP1 -d I II III IV V +bspc monitor DP1 -d VI VII VIII IX X diff --git a/dotfilesync.sh b/dotfilesync.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +sudo rsync -v -a --files-from=/home/anders/dotfiles.list --update /home/anders/ /home/anders/dotfiles >> /home/anders/Log/dotfilesync.log +sudo rsync -v -a --update /etc/i3status.conf /home/anders/dotfiles >> /home/anders/Log/dotfilesync.log +sudo rsync -v -a --update /etc/sudoers /home/anders/dotfiles >> /home/anders/Log/dotfilesync.log diff --git a/emojilist.txt b/emojilist.txt @@ -0,0 +1,1401 @@ + fa-500px + fa-address-book + fa-address-book-o + fa-address-card + fa-address-card-o + fa-adjust + fa-adn + fa-align-center + fa-align-justify + fa-align-left + fa-align-right + fa-amazon + fa-ambulance + fa-american-sign-language-interpreting + fa-anchor + fa-android + fa-angellist + fa-angle-double-down + fa-angle-double-left + fa-angle-double-right + fa-angle-double-up + fa-angle-down + fa-angle-left + fa-angle-right + fa-angle-up + fa-apple + fa-archive + fa-area-chart + fa-arrow-circle-down + fa-arrow-circle-left + fa-arrow-circle-o-down + fa-arrow-circle-o-left + fa-arrow-circle-o-right + fa-arrow-circle-o-up + fa-arrow-circle-right + fa-arrow-circle-up + fa-arrow-down + fa-arrow-left + fa-arrow-right + fa-arrow-up + fa-arrows + fa-arrows-alt + fa-arrows-h + fa-arrows-v + fa-asl-interpreting (alias) + fa-assistive-listening-systems + fa-asterisk + fa-at + fa-audio-description + fa-automobile (alias) + fa-backward + fa-balance-scale + fa-ban + fa-bandcamp + fa-bank (alias) + fa-bar-chart + fa-bar-chart-o (alias) + fa-barcode + fa-bars + fa-bath + fa-bathtub (alias) + fa-battery (alias) + fa-battery-0 (alias) + fa-battery-1 (alias) + fa-battery-2 (alias) + fa-battery-3 (alias) + fa-battery-4 (alias) + fa-battery-empty + fa-battery-full + fa-battery-half + fa-battery-quarter + fa-battery-three-quarters + fa-bed + fa-beer + fa-behance + fa-behance-square + fa-bell + fa-bell-o + fa-bell-slash + fa-bell-slash-o + fa-bicycle + fa-binoculars + fa-birthday-cake + fa-bitbucket + fa-bitbucket-square + fa-bitcoin (alias) + fa-black-tie + fa-blind + fa-bluetooth + fa-bluetooth-b + fa-bold + fa-bolt + fa-bomb + fa-book + fa-bookmark + fa-bookmark-o + fa-braille + fa-briefcase + fa-btc + fa-bug + fa-building + fa-building-o + fa-bullhorn + fa-bullseye + fa-bus + fa-buysellads + fa-cab (alias) + fa-calculator + fa-calendar + fa-calendar-check-o + fa-calendar-minus-o + fa-calendar-o + fa-calendar-plus-o + fa-calendar-times-o + fa-camera + fa-camera-retro + fa-car + fa-caret-down + fa-caret-left + fa-caret-right + fa-caret-square-o-down + fa-caret-square-o-left + fa-caret-square-o-right + fa-caret-square-o-up + fa-caret-up + fa-cart-arrow-down + fa-cart-plus + fa-cc + fa-cc-amex + fa-cc-diners-club + fa-cc-discover + fa-cc-jcb + fa-cc-mastercard + fa-cc-paypal + fa-cc-stripe + fa-cc-visa + fa-certificate + fa-chain (alias) + fa-chain-broken + fa-check + fa-check-circle + fa-check-circle-o + fa-check-square + fa-check-square-o + fa-chevron-circle-down + fa-chevron-circle-left + fa-chevron-circle-right + fa-chevron-circle-up + fa-chevron-down + fa-chevron-left + fa-chevron-right + fa-chevron-up + fa-child + fa-chrome + fa-circle + fa-circle-o + fa-circle-o-notch + fa-circle-thin + fa-clipboard + fa-clock-o + fa-clone + fa-close (alias) + fa-cloud + fa-cloud-download + fa-cloud-upload + fa-cny (alias) + fa-code + fa-code-fork + fa-codepen + fa-codiepie + fa-coffee + fa-cog + fa-cogs + fa-columns + fa-comment + fa-comment-o + fa-commenting + fa-commenting-o + fa-comments + fa-comments-o + fa-compass + fa-compress + fa-connectdevelop + fa-contao + fa-copy (alias) + fa-copyright + fa-creative-commons + fa-credit-card + fa-credit-card-alt + fa-crop + fa-crosshairs + fa-css3 + fa-cube + fa-cubes + fa-cut (alias) + fa-cutlery + fa-dashboard (alias) + fa-dashcube + fa-database + fa-deaf + fa-deafness (alias) + fa-dedent (alias) + fa-delicious + fa-desktop + fa-deviantart + fa-diamond + fa-digg + fa-dollar (alias) + fa-dot-circle-o + fa-download + fa-dribbble + fa-drivers-license (alias) + fa-drivers-license-o (alias) + fa-dropbox + fa-drupal + fa-edge + fa-edit (alias) + fa-eercast + fa-eject + fa-ellipsis-h + fa-ellipsis-v + fa-empire + fa-envelope + fa-envelope-o + fa-envelope-open + fa-envelope-open-o + fa-envelope-square + fa-envira + fa-eraser + fa-etsy + fa-eur + fa-euro (alias) + fa-exchange + fa-exclamation + fa-exclamation-circle + fa-exclamation-triangle + fa-expand + fa-expeditedssl + fa-external-link + fa-external-link-square + fa-eye + fa-eye-slash + fa-eyedropper + fa-fa (alias) + fa-facebook + fa-facebook-f (alias) + fa-facebook-official + fa-facebook-square + fa-fast-backward + fa-fast-forward + fa-fax + fa-feed (alias) + fa-female + fa-fighter-jet + fa-file + fa-file-archive-o + fa-file-audio-o + fa-file-code-o + fa-file-excel-o + fa-file-image-o + fa-file-movie-o (alias) + fa-file-o + fa-file-pdf-o + fa-file-photo-o (alias) + fa-file-picture-o (alias) + fa-file-powerpoint-o + fa-file-sound-o (alias) + fa-file-text + fa-file-text-o + fa-file-video-o + fa-file-word-o + fa-file-zip-o (alias) + fa-files-o + fa-film + fa-filter + fa-fire + fa-fire-extinguisher + fa-firefox + fa-first-order + fa-flag + fa-flag-checkered + fa-flag-o + fa-flash (alias) + fa-flask + fa-flickr + fa-floppy-o + fa-folder + fa-folder-o + fa-folder-open + fa-folder-open-o + fa-font + fa-font-awesome + fa-fonticons + fa-fort-awesome + fa-forumbee + fa-forward + fa-foursquare + fa-free-code-camp + fa-frown-o + fa-futbol-o + fa-gamepad + fa-gavel + fa-gbp + fa-ge (alias) + fa-gear (alias) + fa-gears (alias) + fa-genderless + fa-get-pocket + fa-gg + fa-gg-circle + fa-gift + fa-git + fa-git-square + fa-github + fa-github-alt + fa-github-square + fa-gitlab + fa-gittip (alias) + fa-glass + fa-glide + fa-glide-g + fa-globe + fa-google + fa-google-plus + fa-google-plus-circle (alias) + fa-google-plus-official + fa-google-plus-square + fa-google-wallet + fa-graduation-cap + fa-gratipay + fa-grav + fa-group (alias) + fa-h-square + fa-hacker-news + fa-hand-grab-o (alias) + fa-hand-lizard-o + fa-hand-o-down + fa-hand-o-left + fa-hand-o-right + fa-hand-o-up + fa-hand-paper-o + fa-hand-peace-o + fa-hand-pointer-o + fa-hand-rock-o + fa-hand-scissors-o + fa-hand-spock-o + fa-hand-stop-o (alias) + fa-handshake-o + fa-hard-of-hearing (alias) + fa-hashtag + fa-hdd-o + fa-header + fa-headphones + fa-heart + fa-heart-o + fa-heartbeat + fa-history + fa-home + fa-hospital-o + fa-hotel (alias) + fa-hourglass + fa-hourglass-1 (alias) + fa-hourglass-2 (alias) + fa-hourglass-3 (alias) + fa-hourglass-end + fa-hourglass-half + fa-hourglass-o + fa-hourglass-start + fa-houzz + fa-html5 + fa-i-cursor + fa-id-badge + fa-id-card + fa-id-card-o + fa-ils + fa-image (alias) + fa-imdb + fa-inbox + fa-indent + fa-industry + fa-info + fa-info-circle + fa-inr + fa-instagram + fa-institution (alias) + fa-internet-explorer + fa-intersex (alias) + fa-ioxhost + fa-italic + fa-joomla + fa-jpy + fa-jsfiddle + fa-key + fa-keyboard-o + fa-krw + fa-language + fa-laptop + fa-lastfm + fa-lastfm-square + fa-leaf + fa-leanpub + fa-legal (alias) + fa-lemon-o + fa-level-down + fa-level-up + fa-life-bouy (alias) + fa-life-buoy (alias) + fa-life-ring + fa-life-saver (alias) + fa-lightbulb-o + fa-line-chart + fa-link + fa-linkedin + fa-linkedin-square + fa-linode + fa-linux + fa-list + fa-list-alt + fa-list-ol + fa-list-ul + fa-location-arrow + fa-lock + fa-long-arrow-down + fa-long-arrow-left + fa-long-arrow-right + fa-long-arrow-up + fa-low-vision + fa-magic + fa-magnet + fa-mail-forward (alias) + fa-mail-reply (alias) + fa-mail-reply-all (alias) + fa-male + fa-map + fa-map-marker + fa-map-o + fa-map-pin + fa-map-signs + fa-mars + fa-mars-double + fa-mars-stroke + fa-mars-stroke-h + fa-mars-stroke-v + fa-maxcdn + fa-meanpath + fa-medium + fa-medkit + fa-meetup + fa-meh-o + fa-mercury + fa-microchip + fa-microphone + fa-microphone-slash + fa-minus + fa-minus-circle + fa-minus-square + fa-minus-square-o + fa-mixcloud + fa-mobile + fa-mobile-phone (alias) + fa-modx + fa-money + fa-moon-o + fa-mortar-board (alias) + fa-motorcycle + fa-mouse-pointer + fa-music + fa-navicon (alias) + fa-neuter + fa-newspaper-o + fa-object-group + fa-object-ungroup + fa-odnoklassniki + fa-odnoklassniki-square + fa-opencart + fa-openid + fa-opera + fa-optin-monster + fa-outdent + fa-pagelines + fa-paint-brush + fa-paper-plane + fa-paper-plane-o + fa-paperclip + fa-paragraph + fa-paste (alias) + fa-pause + fa-pause-circle + fa-pause-circle-o + fa-paw + fa-paypal + fa-pencil + fa-pencil-square + fa-pencil-square-o + fa-percent + fa-phone + fa-phone-square + fa-photo (alias) + fa-picture-o + fa-pie-chart + fa-pied-piper + fa-pied-piper-alt + fa-pied-piper-pp + fa-pinterest + fa-pinterest-p + fa-pinterest-square + fa-plane + fa-play + fa-play-circle + fa-play-circle-o + fa-plug + fa-plus + fa-plus-circle + fa-plus-square + fa-plus-square-o + fa-podcast + fa-power-off + fa-print + fa-product-hunt + fa-puzzle-piece + fa-qq + fa-qrcode + fa-question + fa-question-circle + fa-question-circle-o + fa-quora + fa-quote-left + fa-quote-right + fa-ra (alias) + fa-random + fa-ravelry + fa-rebel + fa-recycle + fa-reddit + fa-reddit-alien + fa-reddit-square + fa-refresh + fa-registered + fa-remove (alias) + fa-renren + fa-reorder (alias) + fa-repeat + fa-reply + fa-reply-all + fa-resistance (alias) + fa-retweet + fa-rmb (alias) + fa-road + fa-rocket + fa-rotate-left (alias) + fa-rotate-right (alias) + fa-rouble (alias) + fa-rss + fa-rss-square + fa-rub + fa-ruble (alias) + fa-rupee (alias) + fa-s15 (alias) + fa-safari + fa-save (alias) + fa-scissors + fa-scribd + fa-search + fa-search-minus + fa-search-plus + fa-sellsy + fa-send (alias) + fa-send-o (alias) + fa-server + fa-share + fa-share-alt + fa-share-alt-square + fa-share-square + fa-share-square-o + fa-shekel (alias) + fa-sheqel (alias) + fa-shield + fa-ship + fa-shirtsinbulk + fa-shopping-bag + fa-shopping-basket + fa-shopping-cart + fa-shower + fa-sign-in + fa-sign-language + fa-sign-out + fa-signal + fa-signing (alias) + fa-simplybuilt + fa-sitemapconnection network + fa-skyatlas + fa-skype + fa-slack + fa-sliders + fa-slideshare + fa-smile-o + fa-snapchat + fa-snapchat-ghost + fa-snapchat-square + fa-snowflake-o + fa-soccer-ball-o (alias) + fa-sort + fa-sort-alpha-asc + fa-sort-alpha-desc + fa-sort-amount-asc + fa-sort-amount-desc + fa-sort-asc + fa-sort-desc + fa-sort-down (alias) + fa-sort-numeric-asc + fa-sort-numeric-desc + fa-sort-up (alias) + fa-soundcloud + fa-space-shuttle + fa-spinner + fa-spoon + fa-spotify + fa-square + fa-square-o + fa-stack-exchange + fa-stack-overflow + fa-star + fa-star-half + fa-star-half-empty (alias) + fa-star-half-full (alias) + fa-star-half-o + fa-star-o + fa-steam + fa-steam-square + fa-step-backward + fa-step-forward + fa-stethoscope + fa-sticky-note + fa-sticky-note-o + fa-stop + fa-stop-circle + fa-stop-circle-o + fa-street-view + fa-strikethrough + fa-stumbleupon + fa-stumbleupon-circle + fa-subscript + fa-subway + fa-suitcase + fa-sun-o + fa-superpowers + fa-superscript + fa-support (alias) + fa-table + fa-tablet + fa-tachometer + fa-tag + fa-tags + fa-tasks + fa-taxi + fa-telegram + fa-television + fa-tencent-weibo + fa-terminal + fa-text-height + fa-text-width + fa-th + fa-th-large + fa-th-list + fa-themeisle + fa-thermometer (alias) + fa-thermometer-0 (alias) + fa-thermometer-1 (alias) + fa-thermometer-2 (alias) + fa-thermometer-3 (alias) + fa-thermometer-4 (alias) + fa-thermometer-empty + fa-thermometer-full + fa-thermometer-half + fa-thermometer-quarter + fa-thermometer-three-quarters + fa-thumb-tack + fa-thumbs-down + fa-thumbs-o-down + fa-thumbs-o-up + fa-thumbs-up + fa-ticket + fa-times + fa-times-circle + fa-times-circle-o + fa-times-rectangle (alias) + fa-times-rectangle-o (alias) + fa-tint + fa-toggle-down (alias) + fa-toggle-left (alias) + fa-toggle-off + fa-toggle-on + fa-toggle-right (alias) + fa-toggle-up (alias) + fa-trademark + fa-train + fa-transgender + fa-transgender-alt + fa-trash + fa-trash-o + fa-tree + fa-trello + fa-tripadvisor + fa-trophy + fa-truck + fa-try + fa-tty + fa-tumblr + fa-tumblr-square + fa-turkish-lira (alias) + fa-tv (alias) + fa-twitch + fa-twitter + fa-twitter-square + fa-umbrella + fa-underline + fa-undo + fa-universal-access + fa-university + fa-unlink (alias) + fa-unlock + fa-unlock-alt + fa-unsorted (alias) + fa-upload + fa-usb + fa-usd + fa-user + fa-user-circle + fa-user-circle-o + fa-user-md + fa-user-o + fa-user-plus + fa-user-secret + fa-user-times + fa-users + fa-vcard (alias) + fa-vcard-o (alias) + fa-venus + fa-venus-double + fa-venus-mars + fa-viacoin + fa-viadeo + fa-viadeo-square + fa-video-camera + fa-vimeo + fa-vimeo-square + fa-vine + fa-vk + fa-volume-control-phone + fa-volume-down + fa-volume-off + fa-volume-up + fa-warning (alias) + fa-wechat (alias) + fa-weibo + fa-weixin + fa-whatsapp + fa-wheelchair + fa-wheelchair-alt + fa-wifi + fa-wikipedia-w + fa-window-close + fa-window-close-o + fa-window-maximize + fa-window-minimize + fa-window-restore + fa-windows + fa-won (alias) + fa-wordpress + fa-wpbeginner + fa-wpexplorer + fa-wpforms + fa-wrench + fa-xing + fa-xing-square + fa-y-combinator + fa-y-combinator-square (alias) + fa-yahoo + fa-yc (alias) + fa-yc-square (alias) + fa-yelp + fa-yen (alias) + fa-yoast + fa-youtube + fa-youtube-play + fa-youtube-square +#️ number pound sign hashtag +*️ asterisk +0️ digit zero +1️ digit one +2️ digit two +3️ digit three +4️ digit four +5️ digit five +6️ digit six +7️ digit seven +8️ digit eight +9️ digit nine +©️ copyright +®️ registered +‼️ double exclamation mark +⁉️ exclamation question mark +™️ trade mark +ℹ️ information +↔️ left-right arrow +↕️ up-down arrow +↖️ up-left arrow +↗️ up-right arrow +↘️ down-right arrow +↙️ down-left arrow +↩️ right arrow curving left +↪️ left arrow curving right +⌚ watch +⌛ hourglass done +⌨️ keyboard +⏏️ eject button +⏩ fast-forward button +⏪ fast reverse button rewind symbol +⏫ fast up button up-pointing double triangle +⏬ fast down button down-pointing double triangle +⏭️ next track button skip forward symbol +⏮️ last track button previous track skip backward symbol +⏯️ play or pause button symbol +⏰ alarm clock +⏱️ stop watch +⏲️ timer clock +⏳ hourglass not done +⏸️ pause button +⏹️ stop button +⏺️ record button +Ⓜ️ circled M +▪️ black small square +▫️ white small square +▶️ play button +◀️ reverse button +◻️ white medium square +◼️ black medium square +◽ white medium-small square +◾ black medium-small square +☀️ sun +☁️ cloud +☂️ umbrella +☃️ snowman +☄️ comet +☎️ black telephone +☑️ ballot box with check +☔ umbrella with rain drops +☕ hot beverage +☘️ shamrock +☝️ index pointing up +☠️ skull and crossbones +☢️ radioactive sign +☣️ biohazard sign +☦️ orthodox cross +☪️ star and crescent +☮️ peace symbol +☯️ yin yang +☸️ wheel of dharma +☹️ frowning face +☺️ smiling face +♀️ female sign +♂️ male sign +♈ Aries +♉ taurus +♊ gemini +♋ cancer +♌ leo +♍ virgo +♎ libra +♏ scorpio scorpius +♐ sagittarius +♑ capricorn +♒ aquarius +♓ pisces +♟️ chess pawn +♠️ spade suit +♣️ club suit +♥️ heart suit +♦️ diamond suit +♨️ hot springs +♻️ recycling symbol +♾️ infinity +♿ wheelchair symbol +⚒️ hammer and pick +⚓ anchor +⚔️ crossed swords +⚕️ medical symbol staff of aesculapius +⚖️ balanced scale +⚗️ alembic +⚙️ gear +⚛️ atom symbol +⚜️ fleur-de-lis +⚠️ warning +⚡ high voltage +⚪ white circle +⚫ black circle +⚰️ coffin +⚱️ funeral urn +⚽ soccer ball +⚾ baseball +⛄ snowman without snow +⛅ sun behind cloud +⛈️ cloud with lightning and rain +⛎ Ophiuchus +⛏️ pick +⛑️ rescue worker’s helmet +⛓️ chains +⛔ no entry +⛩️ shinto shrine +⛪ church +⛰️ mountain +⛱️ umbrella on ground +⛲ fountain +⛳ flag in hole +⛴️ ferry boat +⛵ sailboat +⛷️ skier +⛸️ ice skate +⛹️ person bouncing ball +⛺ tent +⛽ fuel pump +✂️ scissors +✅ white heavy check mark +✈️ airplane +✉️ envelope +✊ raised fist hand +✋ raised hand +✌️ victory hand +✍️ writing hand +✏️ pencil +✒️ black nib +✔️ heavy check mark +✖️ heavy multiplication x +✝️ latin cross +✡️ star of David +✨ sparkles +✳️ eight-spoked asterisk +✴️ eight-pointed star +❄️ snowflake +❇️ sparkle +❌ cross mark +❎ cross mark button +❓ question mark +❔ white question mark +❕ white exclamation mark +❗ exclamation mark +❣️ heavy heart exclamation +❤️ red heart +➕ heavy plus sign +➖ heavy minus sign +➗ heavy division sign +➡️ right arrow +➰ curly loop +➿ double curly loop +⤴️ right arrow curving up +⤵️ right arrow curving down +⬅️ left arrow +⬆️ up arrow +⬇️ down arrow +⬛ black large square +⬜ white large square +⭐ star +⭕ heavy large circle +〰️ wavy dash +〽️ part alternation mark +㊗️ Japanese “congratulations” button +㊙️ Japanese “secret” button +🀄 mahjong red dragon +🃏 joker +🅰️ A button (blood type) +🅱️ B button (blood type) +🅾️ O button (blood type) +🅿️ P button +🆎 AB button (blood type) +🆑 CL button +🆒 cool button +🆓 free button +🆔 id button +🆕 new button +🆖 ng button +🆗 ok button +🆘 sos button +🆙 up! button +🆚 VS button +#🇦..🇿) regional indicator symbol letter a..regional indicator symbol letter z +🈁 Japanese “here” button +🈂️ Japanese “service charge” button +🈚 Japanese “free of charge” button +🈯 Japanese “reserved” button +🈲 Japanese “prohibited” button +🈺 Japanese “open for business” button +🉐 Japanese “bargain” button +🉑 Japanese “acceptable” button +🌀 cyclone +🌂 closed umbrella +🌈 rainbow +🌊 water wave +🌋 volcano +🌍 earth globe europe-africa +🌎 earth globe americas +🌏 earth globe asia-australia +🌑 new moon +🌒 waxing crescent moon +🌓 first quarter moon +🌔 waxing gibbous moon +🌕 full moon +🌖 waning gibbous moon +🌗 last quarter moon +🌘 waning crescent moon +🌙 crescent moon +🌟 glowing star +🌠 shooting star +🌡️ thermometer +🌤️ sun behind small cloud +⛅ sun behind cloud +🌦️ sun behind rain cloud +🌧️ cloud with rain +🌨️ cloud with snow +🌩️ cloud with lightning +🌪️ tornado +🌬️ wind face +🌭 hot dog +🌮 taco +🌯 burrito +🌰 chestnut +🌱 seedling +🌲 evergreen tree +🌳 deciduous rounded tree +🌴 palm tree +🌵 cactus +🌶️ hot pepper +🌷 tulip +🌸 cherry blossom +🌹 rose +🌺 hibiscus +🌻 sunflower +🌼 daisy blossom +🌽 corn maize +🌾 rice +🌿 herb +🍀 four leaf clover +🍁 maple leaf +🍂 fallen leaf +🍃 leaf fluttering in wind +🍄 mushroom +🍅 tomato +🍆 eggplant aubergine +🍇 grapes +🍈 melon +🍉 watermelon +🍊 tangerine +🍋 lemon +🍌 banana +🍍 pineapple +🍎 red apple +🍏 green apple +🍐 pear +🍑 peach ass +🍒 cherries cherry +🍓 strawberry +🍔 hamburger +🍕 pizza slice +🍖 meat bone +🍗 poultry leg meat +🍘 rice cracker +🍙 rice ball +🍚 cooked rice +🍛 curry and rice +🍜 steaming bowl ramen +🍝 spaghetti +🍞 bread +🍟 french fries pommes frites +🍠 roasted sweet potato +🍡 dango skewer +🍢 oden skewer +🍣 sushi +🍤 fried shrimp +🍥 fish cake with swirl design +🍦 soft ice cream +🍧 shaved ice cream +🍨 ice cream +🍩 doughnut donut +🍪 cookie +🍫 chocolate bar +🍬 candy +🍭 lollipop +🍮 custard +🍯 honey pot +🍰 short cake +🍱 bento box +🍲 pot of food +🍳 cooking frying pan +🍴 fork and knife +🍵 teacup without handle +🍶 sake bottle and cup +🍷 wine glass +🍸 cocktail glass +🍹 tropical drink +🍺 beer mug +🍻 clinking beer mugs +🍼 baby bottle +🍽️ fork and knife with plate +🍾 bottle with popping cork +🍿 popcorn +🎀 ribbon +🎁 wrapped present +🎂 birthday cake +🎃 jack-o-lantern halloween +🎄 christmas tree +🎅 father christmas santa claus +🎆 fireworks +🎇 fireworks sparkler +🎈 balloon +🎉 party popper +🎊 confetti ball +🎋 tanabata tree +🎌 crossed japanese flags +🎍 pine decoration japanese +🎎 japanese dolls +🎏 carp streamer fish +🎐 wind chime +🎑 moon viewing ceremony japanese +🎒 school satchel rucksack bag +🎓 graduation cap +🎖️ military medal +🎗️ reminder ribbon +🎙️ studio microphone +🎚️ level slider +🎛️ control knobs +🎞️ film frames +🎟️ admission tickets +🎠 carousel horse +🎡 ferris wheel +🎢 roller coaster +🎣 fishing pole and fish +🎤 microphone +🎥 movie camera +🎦 cinema camera +🎧 headphone +🎨 artist palette +🎩 top hat +🎪 circus tent +🎫 ticket +🎬 clapper board movie +🎭 performing art mask +🎮 video game controller +🎯 direct hit dart board +🎰 slot machine +🎱 billiards 8-ball +🎲 game die +🎳 bowling +🎴 flower playing cards +🎵 musical note +🎶 multiple musical notes +🎷 saxophone +🎸 guitar +🎹 musical keyboard +🎺 trumpet +🎻 violin +🎼 musical score +🎽 running shirt with sash +🎾 tennis raquet with ball +🎿 ski +🏀 basketball +🏁 chequered flag +🏂 person snowboarder +🏃 person running +🏄 person surfing +🏅 sports medal +🏆 trophy +🏇 person horse racing +🏈 american football +🏉 rugby football +🏊 person swimming +🏋️ person lifting weights +🏎️ racing car +🏏 cricket game +🏓 ping pong +🏔️ snow-capped mountain +🏟️ stadium +🏠 house +🏰 castle +🏳️ white flag +🏴 black flag +🏵️ rosette +🏷️ label +🏸 badminton +#🏿 dark skin tone +🐀 rat +🐾 paw prints +🐿️ chipmunk +👀 eyes +👁️ eye +👂 ear +💤 sleeping symbol +💦 splashing sweat symbol +💩 pile of poo +💪 flexing biceps +💯 hundred points symbol +💰 money bag dollar +💲 heavy dollar sign +💳 credit card +💻 personal computer +💾 floppy disk +💿 optical disk cd +📀 optical disk dvd +📁 file folder +📂 open file folder +📃 page with curl +📄 page facing up +📅 calendar +📆 calendar tear-off +📋 clipboard +📌 pushpin +📍 round pushpin +📎 paperclip +📝 memo paper with pen +📞 telephone +📡 satellite antenna +📤 outbox tray up +📥 inbox tray down +📦 package +📧 e-mail symbol email +📨 incoming envelope mail +📩 envelope down arrow mail +📪 closed mailbox lowered flag +📫 closed mailbox raised flag +📬 open mailbox raised flag +📭 open mailbox lowered flag +📷 camera +📸 camera with flash +📹 video camera +📼 videocassette +📽️ film projector +📿 prayer beads +🔀 shuffle tracks button +🔇 speaker mute +🔈 speaker low +🔉 speaker mid +🔊 speaker high +🔌 electric plug +🔐 closed lock with key +🔑 key +🔒 closed lock +🔓 opened lock +🔧 wrench +🔨 hammer +🔪 hocho knife +🔼 upwards button +🔽 downwards button +🕉️ om +🕊️ dove +🕋 kaaba +🕎 menorah +🕐 one o’clock +🕧 twelve-thirty +🕯️ candle +🕰️ mantelpiece clock +🕳️ hole +🕹️ joystick +🕺 man dancing +🖇️ linked paperclips +🖊️ pen +🖍️ crayon +🖐️ hand with fingers splayed +🖕 middle finger +🖖 vulcan salute +🖤 black heart +🖥️ desktop computer +🖨️ printer +🖱️ computer mouse +🖲️ trackball +🖼️ framed picture +🗂️ card index dividers +🗄️ file cabinet +🗑️ wastebasket +🗓️ spiral calendar +🗜️ clamp +🗞️ rolled-up newspaper +🗡️ dagger +🗣️ speaking head +🗨️ left speech bubble +🗯️ right anger bubble +🗳️ ballot box with ballot +🗺️ world map +🗻 mount fuji +🗿 moai +😀 grinning face +😁 beaming face with smiling eyes +😈 smiling face with horns +😍 smiling face with heart-shaped eyes +😎 smiling face with sunglasses +😏 smirking face +😐 neutral face +😑 expressionless face +😒 unamused face +😔 pensive face +😕 confused face +😖 confounded face +😗 kissing face +😘 face blowing a kiss +😙 kissing face with smiling eyes +😚 kissing face with closed eyes +😛 face with tongue +😜 winking face with tongue +😞 disappointed face +😟 worried face +😠 angry face +😥 sad but relieved face +😦 frowning face with open mouth +😧 anguished face +😨 fearful face +😫 tired face +😬 grimacing face +😭 loudly crying face +😮 face with open mouth +😯 hushed face +😰 anxious face with sweat +😳 flushed face +😴 sleeping face +😵 dizzy face +🙀 weary cat face +🙁 slightly frowning face +🙂 slightly smiling face +🙃 upside-down face +🙄 face with rolling eyes +🙅 person gesturing NO +🙏 folded hands +🚀 rocket +🛅 left luggage +🛋️ couch and lamp +🛏️ bed +🛐 place of worship +🛑 stop sign +🛒 shopping cart +🛠️ hammer and wrench +🛥️ motor boat +🛩️ small airplane +🛫 airplane departure +🛬 airplane arrival +🛰️ satellite +🛳️ passenger ship +🛴 kick scooter +🛶 canoe +🛷 sled +🛸 flying saucer +🛹 skateboard +🤐 zipper-mouth face +🤘 sign of the horns +🤙 call me hand +🤞 crossed fingers +🤟 love-you gesture +🤠 cowboy hat face +🤧 sneezing face +🤨 face with raised eyebrow +🤯 exploding head +🤰 pregnant woman +🤱 breast-feeding +🤲 palms up together +🤳 selfie +🤺 person fencing +🤼 people wrestling +🤾 person playing handball +🥀 wilted flower +🥅 goal net +🥇 1st place medal +🥈 2nd place medal +🥉 3rd place medal +🥋 martial arts uniform +🥌 curling stone +🥍 lacrosse +🥏 flying disc +🥐 croissant +🥞 pancakes +🥟 dumpling +🥫 canned food +🥬 leafy green +🥰 smiling face with 3 hearts +🥳 partying face +🥶 cold face +🥺 pleading face +🥼 lab coat +🥿 woman’s flat shoe +🦀 crab +🦄 unicorn face +🦅 eagle +🦑 squid +🦒 giraffe +🦗 cricket +🦘 kangaroo +🦢 swan +🦰 red-haired +🦹 supervillain +🧀 cheese wedge +🧁 cupcake +🧂 salt +🧐 face with monocle +🧦 socks +🧧 red envelope +🧲 magnet +🧿 nazar amulet diff --git a/emojimenu.sh b/emojimenu.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Give dmenu list of all unicode characters to copy. +# Shows the selected character in dunst if running. + +# Must have xclip installed to even show menu. +#xclip -h >/dev/null || exit + +chosen=$(grep -v "#" ~/Scripts/emojilist.txt | dmenu -i -l 20 -fn Monospace-18) + +[ "$chosen" != "" ] || exit + +c=$(echo "$chosen" | sed "s/ .*//") +echo "$c" | tr -d '\n' | xclip -selection clipboard +notify-send $c "copied to clipboard." -u low & + +s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}') +echo "$s" | tr -d '\n' | xclip +notify-send $s "copied to primary." -u low & diff --git a/hello.sh b/hello.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +notify-send hello bspwm diff --git a/keepasssync.sh b/keepasssync.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +#ENV variable for my notify-send when ran as cronjob +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus + +ping -c 1 192.168.1.17 >/dev/null || exit + +sudo rsync -a --update anders@192.168.1.17::webdav/Database.kdbx /home/anders/.kp/ +sudo rsync -a --update /home/anders/.kp/Database.kdbx anders@192.168.1.17::webdav/ && notify-send -i keepassxc "Keepass" "Database Synced" diff --git a/newsboatreload.sh b/newsboatreload.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +#ENV variable for my notify-send when ran as cronjob +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus + +ping -c 1 google.com >/dev/null || exit + +result=$(newsboat -x reload print-unread) + +#Log entries when ran as cronjob +echo "Reloading Newsboat" +echo "$result" + +[ "$result" != "" ] && notify-send -u low -i rss "Newsboat" "$result" diff --git a/pacmanupdates.sh b/pacmanupdates.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +ping -c 1 google.com >/dev/null 2>&1 || exit + +cmd="sudo pacman" + +[ "$1" = "-a" ] && cmd="yay" + +$cmd -Sy >> /dev/null || exit +output=$($cmd -Quq | wc -l) + +if [ "$1" = "-a" ]; then + nonaur=$(sudo pacman -Quq | wc -l) + output=$(("$output" - "$nonaur")) + output="📦AUR:$output" +else + output="📦:$output" +fi + +echo "$output" +exit diff --git a/pfetch b/pfetch @@ -0,0 +1,1401 @@ +#!/bin/sh +# +# pfetch - Simple POSIX sh fetch script. + +log() { + # The 'log()' function handles the printing of information. + # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info + # happen independently of each other. + # + # The size of the ascii art is stored and the ascii is printed first. + # Once the ascii is printed, the cursor is located right below the art + # (See marker $[1]). + # + # Using the stored ascii size, the cursor is then moved to marker $[2]. + # This is simply a cursor up escape sequence using the "height" of the + # ascii art. + # + # 'log()' then moves the cursor to the right the "width" of the ascii art + # with an additional amount of padding to add a gap between the art and + # the information (See marker $[3]). + # + # When 'log()' has executed, the cursor is then located at marker $[4]. + # When 'log()' is run a second time, the next line of information is + # printed, moving the cursor to marker $[5]. + # + # Markers $[4] and $[5] repeat all the way down through the ascii art + # until there is no more information left to print. + # + # Every time 'log()' is called the script keeps track of how many lines + # were printed. When printing is complete the cursor is then manually + # placed below the information and the art according to the "heights" + # of both. + # + # The math is simple: move cursor down $((ascii_height - info_height)). + # If the aim is to move the cursor from marker $[5] to marker $[6], + # plus the ascii height is 8 while the info height is 2 it'd be a move + # of 6 lines downwards. + # + # However, if the information printed is "taller" (takes up more lines) + # than the ascii art, the cursor isn't moved at all! + # + # Once the cursor is at marker $[6], the script exits. This is the gist + # of how this "dynamic" printing and layout works. + # + # This method allows ascii art to be stored without markers for info + # and it allows for easy swapping of info order and amount. + # + # $[2] ___ $[3] goldie@KISS + # $[4](.· | $[5] os KISS Linux + # (<> | + # / __ \ + # ( / \ /| + # _/\ __)/_) + # \/-____\/ + # $[1] + # + # $[6] /home/goldie $ + + # End here if no data was found. + [ "$2" ] || return + + # Store the value of '$1' as we reset the argument list below. + name=$1 + + # Use 'set --' as a means of stripping all leading and trailing + # white-space from the info string. This also normalizes all + # white-space inside of the string. + # + # Disable the shellcheck warning for word-splitting + # as it's safe and intended ('set -f' disables globbing). + # shellcheck disable=2046,2086 + { + set -f + set +f -- $2 + info=$* + } + + # Move the cursor to the right, the width of the ascii art with an + # additional gap for text spacing. + printf '[%sC' "${ascii_width--1}" + + # Print the info name and color the text. + printf '[3%s;1m%s' "${PF_COL1-4}" "$name" + + # Print the info name and info data separator. + printf '%s' "$PF_SEP" + + # Move the cursor backward the length of the *current* info name and + # then move it forwards the length of the *longest* info name. This + # aligns each info data line. + printf '[%sD[%sC' "${#name}" "${PF_ALIGN-$info_length}" + + # Print the info data, color it and strip all leading whitespace + # from the string. + printf '[3%sm%s\n' "${PF_COL2-7}" "$info" + + # Keep track of the number of times 'log()' has been run. + info_height=$((${info_height:-0} + 1)) +} + +get_title() { + # Username is retrieved by first checking '$USER' with a fallback + # to the 'id -un' command. + user=${USER:-$(id -un)} + + # Hostname is retrieved by first checking '$HOSTNAME' with a fallback + # to the 'hostname' command. + # + # Disable the warning about '$HOSTNAME' being undefined in POSIX sh as + # the intention for using it is allowing the user to overwrite the + # value on invocation. + # shellcheck disable=SC2039 + hostname=${HOSTNAME:-${hostname:-$(hostname)}} + + log "[3${PF_COL3:-1}m${user}${c7}@[3${PF_COL3:-1}m${hostname}" " " >&6 +} + +get_os() { + # This function is called twice, once to detect the distribution name + # for the purposes of picking an ascii art early and secondly to display + # the distribution name in the info output (if enabled). + # + # On first run, this function displays _nothing_, only on the second + # invocation is 'log()' called. + [ "$distro" ] && { + log os "$distro" >&6 + return + } + + case $os in + Linux*) + # Some Linux disttributions (which are based on others) + # fail to identify as they **do not** change the upstream + # distributions identification packages or files. + # + # It is senseless to add a special case in the code for + # each and every distribution (which _is_ technically no + # different from what it is based on) as they're either too + # lazy to modify upstream's identification files or they + # don't have the know-how (or means) to ship their own + # lsb-release package. + # + # This causes users to think there's a bug in system detection + # tools like neofetch or pfetch when they technically *do* + # function correctly. + # + # Exceptions are made for distributions which are independent, + # not based on another distribution or follow different + # standards. + # + # This applies only to distributions which follow the standard + # by shipping unmodified identification files and packages + # from their respective upstreams. + if command -v lsb_release; then + distro=$(lsb_release -sd) + + else + # This used to be a simple '. /etc/os-release' but I believe + # this is insecure as we blindly executed whatever was in the + # file. This parser instead simply handles 'key=val', treating + # the file contents as plain-text. + while IFS='=' read -r key val; do + case $key in + PRETTY_NAME) distro=$val ;; + esac + done < /etc/os-release + fi + + # 'os-release' and 'lsb_release' sometimes add quotes + # around the distribution name, strip them. + distro=${distro##[\"\']} + distro=${distro%%[\"\']} + + # Special cases for (independent) distributions which + # don't follow any os-release/lsb standards whatsoever. + command -v crux && distro=$(crux) + command -v guix && distro='Guix System' + + # Check to see if Linux is running in Windows 10 under + # WSL1 (Windows subsystem for Linux [version 1]) and + # append a string accordingly. + # + # If the kernel version string ends in "-Microsoft", + # we're very likely running under Windows 10 in WSL1. + [ "${kernel%%*-Microsoft}" ] || + distro="$distro on Windows 10 [WSL1]" + + # Check to see if Linux is running in Windows 10 under + # WSL2 (Windows subsystem for Linux [version 2]) and + # append a string accordingly. + # + # This checks to see if '$WSLENV' is defined. This + # appends the Windows 10 string even if '$WSLENV' is + # empty. We only need to check that is has been _exported_. + distro="${distro}${WSLENV+ on Windows 10 [WSL2]}" + ;; + + Darwin*) + # Parse the SystemVersion.plist file to grab the macOS + # version. The file is in the following format: + # + # <key>ProductVersion</key> + # <string>10.14.6</string> + # + # 'IFS' is set to '<>' to enable splitting between the + # keys and a second 'read' is used to operate on the + # next line directly after a match. + # + # '_' is used to nullify a field. '_ _ line _' basically + # says "populate $line with the third field's contents". + while IFS='<>' read -r _ _ line _; do + case $line in + # Match 'ProductVersion' and read the next line + # directly as it contains the key's value. + ProductVersion) + IFS='<>' read -r _ _ mac_version _ + break + ;; + esac + done < /System/Library/CoreServices/SystemVersion.plist + + # Use the ProductVersion to determine which macOS/OS X codename + # the system has. As far as I'm aware there's no "dynamic" way + # of grabbing this information. + case $mac_version in + 10.4*) distro='Mac OS X Tiger' ;; + 10.5*) distro='Mac OS X Leopard' ;; + 10.6*) distro='Mac OS X Snow Leopard' ;; + 10.7*) distro='Mac OS X Lion' ;; + 10.8*) distro='OS X Mountain Lion' ;; + 10.9*) distro='OS X Mavericks' ;; + 10.10*) distro='OS X Yosemite' ;; + 10.11*) distro='OS X El Capitan' ;; + 10.12*) distro='macOS Sierra' ;; + 10.13*) distro='macOS High Sierra' ;; + 10.14*) distro='macOS Mojave' ;; + 10.15*) distro='macOS Catalina' ;; + *) distro='macOS' ;; + esac + + distro="$distro $mac_version" + ;; + + Haiku) + # Haiku uses 'uname -v' for version information + # instead of 'uname -r' which only prints '1'. + distro=$(uname -sv) + ;; + + Minix|DragonFly) + distro="$os $kernel" + + # Minix and DragonFly don't support the escape + # sequences used, clear the exit trap. + trap '' EXIT + ;; + + SunOS) + # Grab the first line of the '/etc/release' file + # discarding everything after '('. + IFS='(' read -r distro _ < /etc/release + ;; + + *) + # Catch all to ensure '$distro' is never blank. + # This also handles the BSDs. + distro="$os $kernel" + ;; + esac +} + +get_kernel() { + case $os in + # Don't print kernel output on some systems as the + # OS name includes it. + *BSD*|Haiku|Minix) ;; + + *) + # '$kernel' is the cached output of 'uname -r'. + log kernel "$kernel" >&6 + ;; + esac +} + +get_host() { + case $os in + Linux*) + # Despite what these files are called, version doesn't + # always contain the version nor does name always contain + # the name. + read -r name < /sys/devices/virtual/dmi/id/product_name + read -r version < /sys/devices/virtual/dmi/id/product_version + read -r model < /sys/firmware/devicetree/base/model + + host="$name $version $model" + ;; + + Darwin*|FreeBSD*|DragonFly*) + host=$(sysctl -n hw.model) + ;; + + NetBSD*) + host=$(sysctl -n machdep.dmi.system-vendor \ + machdep.dmi.system-product) + ;; + + *BSD*) + host=$(sysctl -n hw.vendor hw.product) + ;; + esac + + # Turn the host string into an argument list so we can iterate + # over it and remove OEM strings and other information which + # shouldn't be displayed. + # + # Disable the shellcheck warning for word-splitting + # as it's safe and intended ('set -f' disables globbing). + # shellcheck disable=2046,2086 + { + set -f + set +f -- $host + host= + } + + # Iterate over the host string word by word as a means of stripping + # unwanted and OEM information from the string as a whole. + # + # This could have been implemented using a long 'sed' command with + # a list of word replacements, however I want to show that something + # like this is possible in pure sh. + # + # This string reconstruction is needed as some OEMs either leave the + # identification information as "To be filled by OEM", "Default", + # "undefined" etc and we shouldn't print this to the screen. + for word; do + # This works by reconstructing the string by excluding words + # found in the "blacklist" below. Only non-matches are appended + # to the final host string. + case $word in + To | [Bb]e | [Ff]illed | by | O.E.M. | OEM |\ + Not | Applicable | Specified | System | Product | Name |\ + Version | Undefined | Default | string | INVALID | � ) + continue + ;; + esac + + host="$host$word " + done + + # '$arch' is the cached output from 'uname -m'. + log host "${host:-$arch}" >&6 +} + +get_uptime() { + # Uptime works by retrieving the data in total seconds and then + # converting that data into days, hours and minutes using simple + # math. + case $os in + Linux*|Minix*) + IFS=. read -r s _ < /proc/uptime + ;; + + Darwin*|*BSD*|DragonFly*) + s=$(sysctl -n kern.boottime) + + # Extract the uptime in seconds from the following output: + # [...] { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010 + s=${s#*=} + s=${s%,*} + + # The uptime format from 'sysctl' needs to be subtracted from + # the current time in seconds. + s=$(($(date +%s) - s)) + ;; + + Haiku) + # The boot time is returned in microseconds, convert it to + # regular seconds. + s=$(($(system_time) / 1000000)) + ;; + + SunOS) + # Split the output of 'kstat' on '.' and any white-space + # which exists in the command output. + # + # The output is as follows: + # unix:0:system_misc:snaptime 14809.906993005 + # + # The parser extracts: ^^^^^ + IFS=' .' read -r _ s _ <<-EOF + $(kstat -p unix:0:system_misc:snaptime) + EOF + ;; + esac + + # Convert the uptime from seconds into days, hours and minutes. + d=$((s / 60 / 60 / 24)) + h=$((s / 60 / 60 % 24)) + m=$((s / 60 % 60)) + + # Only append days, hours and minutes if they're non-zero. + [ "$d" = 0 ] || uptime="${uptime}${d}d " + [ "$h" = 0 ] || uptime="${uptime}${h}h " + [ "$m" = 0 ] || uptime="${uptime}${m}m " + + log uptime "${uptime:-0m}" >&6 +} + +get_pkgs() { + # This is just a simple wrapper around 'command -v' to avoid + # spamming '>/dev/null' throughout this function. + has() { command -v "$1" >/dev/null; } + + # This works by first checking for which package managers are + # installed and finally by printing each package manager's + # package list with each package one per line. + # + # The output from this is then piped to 'wc -l' to count each + # line, giving us the total package count of whatever package + # managers are installed. + # + # Backticks are *required* here as '/bin/sh' on macOS is + # 'bash 3.2' and it can't handle the following: + # + # var=$( + # code here + # ) + # + # shellcheck disable=2006 + packages=` + case $os in + Linux*) + # Commands which print packages one per line. + has bonsai && bonsai list + has pacman-key && pacman -Qq + has dpkg && dpkg-query -f '.\n' -W + has rpm && rpm -qa + has xbps-query && xbps-query -l + has apk && apk info + has guix && guix package --list-installed + + # Directories containing packages. + has kiss && printf '%s\n' /var/db/kiss/installed/*/ + has brew && printf '%s\n' "$(brew --cellar)/"* + has emerge && printf '%s\n' /var/db/pkg/*/*/ + has pkgtool && printf '%s\n' /var/log/packages/* + + # 'nix' requires two commands. + has nix-store && { + nix-store -q --requisites /run/current-system/sw + nix-store -q --requisites ~.nix-profile + } + ;; + + Darwin*) + # Commands which print packages one per line. + has pkgin && pkgin list + + # Directories containing packages. + has brew && printf '%s\n' /usr/local/Cellar/* + + # 'port' prints a single line of output to 'stdout' + # when no packages are installed and exits with + # success causing a false-positive of 1 package + # installed. + # + # 'port' should really exit with a non-zero code + # in this case to allow scripts to cleanly handle + # this behavior. + has port && { + pkg_list=$(port installed) + + [ "$pkg_list" = "No ports are installed." ] || + printf '%s\n' "$pkg_list" + } + ;; + + FreeBSD*|DragonFly*) + pkg info + ;; + + OpenBSD*) + printf '%s\n' /var/db/pkg/*/ + ;; + + NetBSD*) + pkg_info + ;; + + Haiku) + printf '%s\n' /boot/system/package-links/* + ;; + + Minix) + printf '%s\n' /usr/pkg/var/db/pkg/*/ + ;; + + SunOS) + has pkginfo && pkginfo -i + has pkg && pkg list + ;; + esac | wc -l + ` + + log pkgs "${packages:-?}" >&6 +} + +get_memory() { + case $os in + # Used memory is calculated using the following "formula": + # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable + # Source: https://github.com/KittyKatt/screenFetch/issues/386 + Linux*) + # Parse the '/proc/meminfo' file splitting on ':' and 'k'. + # The format of the file is 'key: 000kB' and an additional + # split is used on 'k' to filter out 'kB'. + while IFS=':k ' read -r key val _; do + case $key in + MemTotal) + mem_used=$((mem_used + val)) + mem_full=$val + ;; + + Shmem) + mem_used=$((mem_used + val)) + ;; + + MemFree|Buffers|Cached|SReclaimable) + mem_used=$((mem_used - val)) + ;; + esac + done < /proc/meminfo + + mem_used=$((mem_used / 1024)) + mem_full=$((mem_full / 1024)) + ;; + + # Used memory is calculated using the following "formula": + # (wired + active + occupied) * 4 / 1024 + Darwin*) + mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) + + # Parse the 'vmstat' file splitting on ':' and '.'. + # The format of the file is 'key: 000.' and an additional + # split is used on '.' to filter it out. + while IFS=:. read -r key val; do + case $key in + *wired*|*active*|*occupied*) + mem_used=$((mem_used + ${val:-0})) + ;; + esac + + # Using '<<-EOF' is the only way to loop over a command's + # output without the use of a pipe ('|'). + # This ensures that any variables defined in the while loop + # are still accessible in the script. + done <<-EOF + $(vm_stat) + EOF + + mem_used=$((mem_used * 4 / 1024)) + ;; + + OpenBSD*) + mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) + + # This is a really simpler parser for 'vmstat' which grabs + # the used memory amount in a lazy way. 'vmstat' prints 3 + # lines of output with the needed value being stored in the + # final line. + # + # This loop simply grabs the 3rd element of each line until + # the EOF is reached. Each line overwrites the value of the + # previous one so we're left with what we wanted. This isn't + # slow as only 3 lines are parsed. + while read -r _ _ line _; do + mem_used=${line%%M} + + # Using '<<-EOF' is the only way to loop over a command's + # output without the use of a pipe ('|'). + # This ensures that any variables defined in the while loop + # are still accessible in the script. + done <<-EOF + $(vmstat) + EOF + ;; + + # Used memory is calculated using the following "formula": + # mem_full - ((inactive + free + cache) * page_size / 1024) + FreeBSD*|DragonFly*) + mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) + + # Use 'set --' to store the output of the command in the + # argument list. POSIX sh has no arrays but this is close enough. + # + # Disable the shellcheck warning for word-splitting + # as it's safe and intended ('set -f' disables globbing). + # shellcheck disable=2046 + { + set -f + set +f -- $(sysctl -n hw.pagesize \ + vm.stats.vm.v_inactive_count \ + vm.stats.vm.v_free_count \ + vm.stats.vm.v_cache_count) + } + + # Calculate the amount of used memory. + # $1: hw.pagesize + # $2: vm.stats.vm.v_inactive_count + # $3: vm.stats.vm.v_free_count + # $4: vm.stats.vm.v_cache_count + mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024))) + ;; + + NetBSD*) + mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024)) + + # NetBSD implements a lot of the Linux '/proc' filesystem, + # this uses the same parser as the Linux memory detection. + while IFS=':k ' read -r key val _; do + case $key in + MemFree) + mem_free=$((val / 1024)) + break + ;; + esac + done < /proc/meminfo + + mem_used=$((mem_full - mem_free)) + ;; + + Haiku) + # Read the first line of 'sysinfo -mem' splitting on + # '(', ' ', and ')'. The needed information is then + # stored in the 5th and 7th elements. Using '_' "consumes" + # an element allowing us to proceed to the next one. + # + # The parsed format is as follows: + # 3501142016 bytes free (used/max 792645632 / 4293787648) + IFS='( )' read -r _ _ _ _ mem_used _ mem_full <<-EOF + $(sysinfo -mem) + EOF + + mem_used=$((mem_used / 1024 / 1024)) + mem_full=$((mem_full / 1024 / 1024)) + ;; + + Minix) + # Minix includes the '/proc' filesystem though the format + # differs from Linux. The '/proc/meminfo' file is only a + # single line with space separated elements and elements + # 2 and 3 contain the total and free memory numbers. + read -r _ mem_full mem_free _ < /proc/meminfo + + mem_used=$(((mem_full - mem_free) / 1024)) + mem_full=$(( mem_full / 1024)) + ;; + + SunOS) + hw_pagesize=$(pagesize) + + # 'kstat' outputs memory in the following format: + # unix:0:system_pages:pagestotal 1046397 + # unix:0:system_pages:pagesfree 885018 + # + # This simply uses the first "element" (white-space + # separated) as the key and the second element as the + # value. + # + # A variable is then assigned based on the key. + while read -r key val; do + case $key in + *total) pages_full=$val ;; + *free) pages_free=$val ;; + esac + done <<-EOF + $(kstat -p unix:0:system_pages:pagestotal \ + unix:0:system_pages:pagesfree) + EOF + + mem_full=$((pages_full * hw_pagesize / 1024 / 1024)) + mem_free=$((pages_free * hw_pagesize / 1024 / 1024)) + mem_used=$((mem_full - mem_free)) + ;; + esac + + log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 +} + +get_wm() { + case $os in + # Don't display window manager on macOS. + Darwin*) ;; + + *) + # xprop can be used to grab the window manager's properties + # which contains the window manager's name under '_NET_WM_NAME'. + # + # The upside to using 'xprop' is that you don't need to hardcode + # a list of known window manager names. The downside is that + # not all window managers conform to setting the '_NET_WM_NAME' + # atom.. + # + # List of window managers which fail to set the name atom: + # catwm, fvwm, dwm, 2bwm and monster. + # + # The final downside to this approach is that it does _not_ + # support Wayland environments. The only solution which supports + # Wayland is the 'ps' parsing mentioned below. + # + # A more naive implementation is to parse the last line of + # '~/.xinitrc' to extract the second white-space separated + # element. + # + # The issue with an approach like this is that this line data + # does not always equate to the name of the window manager and + # could in theory be _anything_. + # + # This also fails when the user launches xorg through a display + # manager or other means. + # + # + # Another naive solution is to parse 'ps' with a hardcoded list + # of window managers to detect the current window manager (based + # on what is running). + # + # The issue with this approach is the need to hardcode and + # maintain a list of known window managers. + # + # Another issue is that process names do not always equate to + # the name of the window manager. False-positives can happen too. + # + # This is the only solution which supports Wayland based + # environments sadly. It'd be nice if some kind of standard were + # established to identify Wayland environments. + # + # pfetch's goal is to remain _simple_, if you'd like a "full" + # implementation of window manager detection use 'neofetch'. + # + # Neofetch use a combination of 'xprop' and 'ps' parsing to + # support all window managers (including non-conforming and + # Wayland) though it's a lot more complicated! + + # Don't display window manager if X isn't running. + [ "$DISPLAY" ] || return + + # This is a two pass call to xprop. One call to get the window + # manager's ID and another to print its properties. + command -v xprop && { + # The output of the ID command is as follows: + # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 + # + # To extract the ID, everything before the last space + # is removed. + id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK) + id=${id##* } + + # The output of the property command is as follows: + # _NAME 8t + # _NET_WM_PID = 252 + # _NET_WM_NAME = "bspwm" + # _NET_SUPPORTING_WM_CHECK: window id # 0x400000 + # WM_CLASS = "wm", "Bspwm" + # + # To extract the name, everything before '_NET_WM_NAME = \"' + # is removed and everything after the next '"' is removed. + wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t) + wm=${wm##*_NET_WM_NAME = \"} + wm=${wm%%\"*} + } + ;; + esac + + log wm "$wm" >&6 +} + + +get_de() { + # This only supports Xorg related desktop environments though + # this is fine as knowing the desktop envrionment on Windows, + # macOS etc is useless (they'll always report the same value). + # + # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty, + # display the value of '$DESKTOP_SESSION'. + log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6 +} + +get_shell() { + # Display the basename of the '$SHELL' environment variable. + log shell "${SHELL##*/}" >&6 +} + +get_editor() { + # Display the value of '$VISUAL', if it's empty, display the + # value of '$EDITOR'. + log editor "${VISUAL:-$EDITOR}" >&6 +} + +get_palette() { + # Print the first 8 terminal colors. This uses the existing + # sequences to change text color with a sequence prepended + # to reverse the foreground and background colors. + # + # This allows us to save hardcoding a second set of sequences + # for background colors. + palette=" $c1 $c2 $c3 $c4 $c5 $c6 $c7 " + + # Print the palette with a newline before and after. + # The '\033[%sC' moves the text to the right, the + # length of the ascii art. + printf '\n[%sC%s\n' "${ascii_width-1}" "$palette" >&6 +} + +get_ascii() { + # This is a simple function to read the contents of + # an ascii file from 'stdin'. It allows for the use + # of '<<-EOF' to prevent the break in indentation in + # this source code. + # + # This function also sets the text colors according + # to the ascii color. + read_ascii() { + # 'PF_COL1': Set the info name color according to ascii color. + # 'PF_COL3': Set the title color to some other color. ¯\_(ツ)_/¯ + PF_COL1=${PF_COL1:-${1:-7}} + PF_COL3=${PF_COL3:-$((${1:-7}%8+1))} + + # POSIX sh has no 'var+=' so 'var=${var}append' is used. What's + # interesting is that 'var+=' _is_ supported inside '$(())' + # (arithmetic) though there's no support for 'var++/var--'. + # + # There is also no $'\n' to add a "literal"(?) newline to the + # string. The simplest workaround being to break the line inside + # the string (though this has the caveat of breaking indentation). + while IFS= read -r line; do + ascii="$ascii$line +" + done + } + + # This checks for ascii art in the following order: + # '$1': Argument given to 'get_ascii()' directly. + # '$PF_ASCII': Environment variable set by user. + # '$distro': The detected distribution name. + # '$os': The name of the operating system/kernel. + # + # NOTE: Each ascii art below is indented using tabs, this + # allows indentation to continue naturally despite + # the use of '<<-EOF'. + case ${1:-${PF_ASCII:-${distro:-$os}}} in + [Aa]lpine*) + read_ascii 4 <<-EOF + ${c4} /\\ /\\ + /${c7}/ ${c4}\\ \\ + /${c7}/ ${c4}\\ \\ + /${c7}// ${c4}\\ \\ + ${c7}// ${c4}\\ \\ + \\ + EOF + ;; + + [Aa]ndroid*) + read_ascii 2 <<-EOF + ${c2} ;, ,; + ';,.-----.,;' + ,' ', + / O O \\ + | | + '-----------------' + EOF + ;; + + [Aa]rch*) + read_ascii 4 <<-EOF + ${c6} /\\ + /^^\\ + /\\ \\ + /${c7} __ \\ + / ( ) \\ + / __| |__\\\\ + /// \\\\\\ + EOF + ;; + + [Aa]rco*) + read_ascii 4 <<-EOF + ${c4} /\\ + / \\ + / /\\ \\ + / / \\ \\ + / / \\ \\ + / / _____\\ \\ + /_/ \`----.\\_\\ + EOF + ;; + + [Aa]rtix*) + read_ascii 6 <<-EOF + ${c4} /\\ + / \\ + /\`'.,\\ + / ', + / ,\`\\ + / ,.'\`. \\ + /.,'\` \`'.\\ + EOF + ;; + + [Cc]ent[Oo][Ss]*) + read_ascii 5 <<-EOF + ${c2} ____${c3}^${c5}____ + ${c2} |\\ ${c3}|${c5} /| + ${c2} | \\ ${c3}|${c5} / | + ${c5}<---- ${c4}----> + ${c4} | / ${c2}|${c3} \\ | + ${c4} |/__${c2}|${c3}__\\| + ${c2} v + EOF + ;; + + [Dd]ebian*) + read_ascii 1 <<-EOF + ${c1} _____ + / __ \\ + | / | + | \\___- + -_ + --_ + EOF + ;; + + [Dd]ragon[Ff]ly*) + read_ascii 1 <<-EOF + ,${c1}_${c7}, + ('-_${c1}|${c7}_-') + >--${c1}|${c7}--< + (_-'${c1}|${c7}'-_) + ${c1}| + | + | + EOF + ;; + + [Ee]lementary*) + read_ascii <<-EOF + ${c7} _______ + / ____ \\ + / | / /\\ + |__\\ / / | + \\ /__/ / + \\_______/ + EOF + ;; + + [Ff]edora*) + read_ascii 4 <<-EOF + ${c7} _____ + / __)${c4}\\${c7} + | / ${c4}\\ \\${c7} + ${c4}__${c7}_| |_${c4}_/ /${c7} + ${c4}/ ${c7}(_ _)${c4}_/${c7} + ${c4}/ /${c7} | | + ${c4}\\ \\${c7}__/ | + ${c4}\\${c7}(_____/ + EOF + ;; + + [Ff]ree[Bb][Ss][Dd]*) + read_ascii 1 <<-EOF + ${c1} /\\ _____ /\\ + \\_) (_/ + / \\ + | | + | | + \ / + --_____-- + EOF + ;; + + [Gg]entoo*) + read_ascii 5 <<-EOF + ${c5} _-----_ + ( \\ + \\ 0 \\ + ${c7} \\ ) + / _/ + ( _- + \\____- + EOF + ;; + + [Gg]uix[Ss][Dd]*|[Gg]uix*) + read_ascii 3 <<-EOF + ${c3}|.__ __.| + |__ \\ / __| + \\ \\ / / + \\ \\ / / + \\ \\ / / + \\ \\/ / + \\__/ + EOF + ;; + + [Hh]aiku*) + read_ascii 3 <<-EOF + ${c3} ,^, + / \\ + *--_ ; ; _--* + \\ '" "' / + '. .' + .-'" "'-. + '-.__. .__.-' + |_| + EOF + ;; + + [Hh]yperbola*) + read_ascii <<-EOF + ${c7} |\`__.\`/ + \____/ + .--. + / \\ + / ___ \\ + / .\` \`.\\ + /.\` \`.\\ + EOF + ;; + + [Ll]inux*[Ll]ite*|[Ll]ite*) + read_ascii 3 <<-EOF + ${c3} /\\ + / \\ + / ${c7}/ ${c3}/ + > ${c7}/ ${c3}/ + \\ ${c7}\\ ${c3}\\ + \\_${c7}\\${c3}_\\ + ${c7} \\ + EOF + ;; + + [Ll]inux*[Mm]int*|[Mm]int) + read_ascii 2 <<-EOF + ${c2} ___________ + |_ \\ + | ${c7}| _____ ${c2}| + | ${c7}| | | | ${c2}| + | ${c7}| | | | ${c2}| + | ${c7}\\__${c7}___/ ${c2}| + \\_________/ + EOF + ;; + + + [Ll]inux*) + read_ascii 4 <<-EOF + ${c4} ___ + (${c7}.· ${c4}| + (${c5}<> ${c4}| + / ${c7}__ ${c4}\\ + ( ${c7}/ \\ ${c4}/| + ${c5}_${c4}/\\ ${c7}__)${c4}/${c5}_${c4}) + ${c5}\/${c4}-____${c5}\/ + EOF + ;; + + [Mm]ac[Oo][Ss]*|[Dd]arwin*) + read_ascii 1 <<-EOF + ${c1} .:' + _ :'_ + ${c2} .'\`_\`-'_\`\`. + :________.-' + ${c3}:_______: + ${c4} :_______\`-; + ${c5} \`._.-._.' + EOF + ;; + + [Mm]ageia*) + read_ascii 2 <<-EOF + ${c6} * + * + ** + ${c7} /\\__/\\ + / \\ + \\ / + \\____/ + EOF + ;; + + [Mm]anjaro*) + read_ascii 2 <<-EOF + ${c2}||||||||| |||| + ||||||||| |||| + |||| |||| + |||| |||| |||| + |||| |||| |||| + |||| |||| |||| + |||| |||| |||| + EOF + ;; + + [Mm]inix*) + read_ascii 4 <<-EOF + ${c4} ,, ,, + ;${c7},${c4} ', ,' ${c7},${c4}; + ; ${c7}',${c4} ',,' ${c7},'${c4} ; + ; ${c7}',${c4} ${c7},'${c4} ; + ; ${c7};, '' ,;${c4} ; + ; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ; + ', ${c7};${c4};; ;;${c7};${c4} ,' + '${c7};${c4}' '${c7};${c4}' + EOF + ;; + + [Mm][Xx]*) + read_ascii <<-EOF + ${c7} \\\\ / + \\\\/ + \\\\ + /\\/ \\\\ + / \\ /\\ + / \\/ \\ + /__________\\ + EOF + ;; + + [Nn]et[Bb][Ss][Dd]*) + read_ascii 3 <<-EOF + ${c7}\\\\${c3}\`-______,----__ + ${c7} \\\\ ${c3}__,---\`_ + ${c7} \\\\ ${c3}\`.____ + ${c7} \\\\${c3}-______,----\`- + ${c7} \\\\ + \\\\ + \\\\ + EOF + ;; + + [Nn]ix[Oo][Ss]*) + read_ascii 4 <<-EOF + ${c4} \\\\ \\\\ // + ==\\\\__\\\\/ // + // \\\\// + ==// //== + //\\\\___// + // /\\\\ \\\\== + // \\\\ \\\\ + EOF + ;; + + [Oo]pen[Bb][Ss][Dd]*) + read_ascii 3 <<-EOF + ${c3} _____ + \\- -/ + \\_/ \\ + | ${c7}O O${c3} | + |_ < ) 3 ) + / \\ / + /-_____-\\ + EOF + ;; + + [Oo]penSUSE*|[Oo]pen*SUSE*|SUSE*|suse*) + read_ascii 2 <<-EOF + ${c2} _______ + __| __ \\ + / .\\ \\ + \\__/ | + _______| + \\_______ + __________/ + EOF + ;; + + [Pp]arabola*) + read_ascii 5 <<-EOF + ${c5} __ __ __ _ + .\`_//_//_/ / \`. + / .\` + / .\` + /.\` + /\` + EOF + ;; + + [Pp]op!_[Oo][Ss]*) + read_ascii 6 <<-EOF + ${c6}______ + \\ _ \\ __ + \\ \\ \\ \\ / / + \\ \\_\\ \\ / / + \\ ___\\ /_/ + \\ \\ _ + __\\_\\__(_)_ + (___________) + EOF + ;; + + [Pp]ure[Oo][Ss]*) + read_ascii <<-EOF + ${c7} _____________ + | _________ | + | | | | + | | | | + | |_________| | + |_____________| + EOF + ;; + + [Ss]lackware*) + read_ascii 4 <<-EOF + ${c4} ________ + / ______| + | |______ + \\______ \\ + ______| | + | |________/ + |____________ + EOF + ;; + + [Ss]un[Oo][Ss]|[Ss]olaris*) + read_ascii 3 <<-EOF + ${c3} . .; . + . :; :: ;: . + .;. .. .. .;. + .. .. .. .. + .;, ,;. + EOF + ;; + + [Uu]buntu*) + read_ascii 3 <<-EOF + ${c3} _ + ---(_) + _/ --- \\ + (_) | | + \\ --- _/ + ---(_) + EOF + ;; + + [Vv]oid*) + read_ascii 2 <<-EOF + ${c2} _______ + _ \\______ - + | \\ ___ \\ | + | | / \ | | + | | \___/ | | + | \\______ \\_| + -_______\\ + EOF + ;; + + *) + # On no match of a distribution ascii art, this function calls + # itself again, this time to look for a more generic OS related + # ascii art (KISS Linux -> Linux). + [ "$1" ] || { + get_ascii "$os" + return + } + + printf 'error: %s is not currently supported.\n' "$os" >&6 + printf 'error: Open an issue for support to be added.\n' >&6 + exit 1 + ;; + esac + + # Store the "width" (longest line) and "height" (number of lines) + # of the ascii art for positioning. This script prints to the screen + # *almost* like a TUI does. It uses escape sequences to allow dynamic + # printing of the information through user configuration. + # + # Iterate over each line of the ascii art to retrieve the above + # information. The 'sed' is used to strip 'm' color codes from + # the ascii art so they don't affect the width variable. + while read -r line; do + ascii_height=$((${ascii_height:-0} + 1)) + + # This was a ternary operation but they aren't supported in + # Minix's shell. + [ "${#line}" -gt "${ascii_width:-0}" ] && + ascii_width=${#line} + + # Using '<<-EOF' is the only way to loop over a command's + # output without the use of a pipe ('|'). + # This ensures that any variables defined in the while loop + # are still accessible in the script. + done <<-EOF + $(printf %s "$ascii" | sed 's/\[3.m//g') + EOF + + # Add a gap between the ascii art and the information. + ascii_width=$((ascii_width + 4)) + + # Print the ascii art and position the cursor back where we + # started prior to printing it. + # '[1m': Print the ascii in bold. + # '[m': Clear bold. + # '[%sA': Move the cursor up '$ascii_height' amount of lines. + printf '%s[%sA' "$ascii" "$ascii_height" >&6 +} + +main() { + # Hide 'stderr' unless the first argument is '-v'. This saves + # polluting the script with '2>/dev/null'. + [ "$1" = -v ] || exec 2>/dev/null + + # Hide 'stdout' and selectively print to it using '>&6'. + # This gives full control over what it displayed on the screen. + exec 6>&1 >/dev/null + + # Generic color list. + # Disable warning about unused variables. + # shellcheck disable=2034 + { + c1=''; c2='' + c3=''; c4='' + c5=''; c6='' + c7=''; c8='' + } + + # Avoid text-wrapping from wrecking the program output + # and hide the cursor to hide its moving around during + # the printing process. + # + # Some terminals don't support these sequences, nor do they + # silently conceal them if they're printed resulting in + # partial sequences being printed to the terminal! + [ "$TERM" = dumb ] || + [ "$TERM" = minix ] || + [ "$TERM" = cons25 ] || { + # '[?7l': Disable line-wrapping. + # '[?25l': Hide the cursor. + printf '[?7l[?25l' >&6 + + # Leave the terminal how we found it on exit or Ctrl+C. + # '[?7h': Enable line-wrapping. + # '[?25h': Show the cursor. + trap 'printf [?7h[?25h >&6' EXIT + } + + # Store the output of 'uname' to avoid calling it multiple times + # throughout the script. 'read <<EOF' is the simplest way of reading + # a command into a list of variables. + read -r os kernel arch <<-EOF + $(uname -srm) + EOF + + # Always run 'get_os' for the purposes of detecting which ascii + # art to display. + get_os + + # Allow the user to specify the order and inclusion of information + # functions through the 'PF_INFO' environment variable. + # shellcheck disable=2086 + { + # Disable globbing and set the positional parameters to the + # contents of 'PF_INFO'. + set -f + set +f ${PF_INFO-ascii title os host kernel uptime pkgs memory} + + # Iterate over the info functions to determine the lengths of the + # "info names" for output alignment. The option names and subtitles + # match 1:1 so this is thankfully simple. + for info; do + command -v "get_$info" >/dev/null || continue + + # This was a ternary operation but they aren't supported in + # Minix's shell. + [ "${#info}" -gt "${info_length:-0}" ] && + info_length=${#info} + done + + # Add an additional space of length to act as a gap. + info_length=$((info_length + 1)) + + # Iterate over the above list and run any existing "get_" functions. + for info; do "get_$info"; done + } + + # Position the cursor below both the ascii art and information lines + # according to the height of both. If the information exceeds the ascii + # art in height, don't touch the cursor (0/unset), else move it down + # N lines. + # + # This was a ternary operation but they aren't supported in Minix's shell. + [ "${info_height:-0}" -lt "${ascii_height:-0}" ] && + cursor_pos=$((ascii_height - info_height)) + + # Print '$cursor_pos' amount of newlines to correctly position the + # cursor. This used to be a 'printf $(seq X X)' however 'seq' is only + # typically available (by default) on GNU based systems! + while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do + printf '\n' + i=$((i + 1)) + done >&6 +} + +main "$@" diff --git a/polybar.sh b/polybar.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +pgrep -x polybar >> /dev/null && pkill -x polybar >> /dev/null +sleep 1 +polybar mybar >> /dev/null 2>&1 & diff --git a/screenoutput.sh b/screenoutput.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +chosen=$(echo "1. VGA Off +2. VGA Above +3. VGA Right +4. VGA Left +5. HDMI Off +6. HDMI Above +7. HDMI Right +8. HDMI Left" | dmenu -i -l 20 -fn Monospace-18 | cut -c1) + +[ "$chosen" = "1" ] && xrandr --output DP1 --off && /home/anders/Scripts/bspwmscreenOFF.sh +[ "$chosen" = "2" ] && xrandr --output DP1 --auto --above eDP1 && /home/anders/Scripts/bspwmscreenVGA.sh +[ "$chosen" = "3" ] && xrandr --output DP1 --auto --right-of eDP1 && /home/anders/Scripts/bspwmscreenVGA.sh +[ "$chosen" = "4" ] && xrandr --output DP1 --auto --left-of eDP1 && /home/anders/Scripts/bspwmscreenVGA.sh +[ "$chosen" = "5" ] && xrandr --output HDMI2 --off +[ "$chosen" = "6" ] && xrandr --output HDMI2 --auto --above eDP1 +[ "$chosen" = "7" ] && xrandr --output HDMI2 --auto --right-of eDP1 +[ "$chosen" = "8" ] && xrandr --output HDMI2 --auto --left-of eDP1 + +[ "$chosen" != "" ] && sleep 1; /home/anders/.fehbg + +exit diff --git a/surfraw.sh b/surfraw.sh @@ -0,0 +1,124 @@ +#!/bin/sh + +search=$(echo "duckduckgo +youtube +google +archpkg +archwiki +aur +acronym +ads +alioth +amazon +arxiv +ask +austlii +bbcnews +bing +bookfinder +bugmenot +bugzilla +cia +cisco +cite +cliki +cnn +comlaw +commandlinefu +ctan +currency +cve +debbugs +debcodesearch +debcontents +deblists +deblogs +debpackages +debpkghome +debpts +debsec +debvcsbrowse +debwiki +deja +discogs +ebay +etym +excite +f5 +finkpkg +foldoc +freebsd +freedb +freshmeat +fsfdir +gcache +genbugs +genportage +github +gmane +gutenberg +imdb +ixquick +jamendo +javasun +jquery +l1sp +lastfm +leodict +lsm +macports +mathworld +mdn +mininova +musicbrainz +mysqldoc +netbsd +nlab +ntrs +openbsd +oraclesearch +pgdoc +pgpkeys +phpdoc +pin +piratebay +priberam +pubmed +rae +rfc +S +scholar +scpan +searx +slashdot +slinuxdoc +sourceforge +springer +stack +stockquote +thesaurus +translate +urban +W +w3css +w3html +w3link +w3rdf +wayback +webster +wikipedia +wiktionary +woffle +wolfram +worldwidescience +yahoo +yandex" | dmenu -i -p "Where to search?") + +term=$(echo "arch +linux +luke smith" | dmenu -i -p "Searchterm") + +[ -n "$term" ] || exit + +surfraw "$search" -browser=chromium "$term" +exit diff --git a/sxhkd.sh b/sxhkd.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +pgrep -x sxhkd >> /dev/null && pkill -x sxhkd >> /dev/null +sxhkd & diff --git a/terminator.sh b/terminator.sh @@ -0,0 +1,4 @@ +#!/bin/bash +terminator & +#sleep 0.3 +#compton & diff --git a/terminatorlayout.sh b/terminatorlayout.sh @@ -0,0 +1,4 @@ +#!/bin/bash +terminator --layout=test & +sleep 0.3 +compton & diff --git a/timeshiftsync.sh b/timeshiftsync.sh @@ -0,0 +1,14 @@ +#!/bin/bash + + # ">" resets log + # ">>" appends log + +echo "-------------------" > /home/anders/Log/rsync.log +echo "$(date +"%F %T ")" >> /home/anders/Log/rsync.log + +#Rsync verbose archive Hardlinks +sudo rsync -v -a -H --delete --update /timeshift/ root@192.168.1.17::backup/acer/timeshift >> /home/anders/Log/rsync.log + +echo "Script done" >> /home/anders/Log/rsync.log +echo "-------------------" >> /home/anders/Log/rsync.log +echo "$(date +"%F")" > /home/anders/Log/rsync.lastrun diff --git a/uber.sh b/uber.sh @@ -0,0 +1,9 @@ +#!/bin/bash +source "`ueberzug library`" + +[ -z "$5" ] && echo "Usage: $0 <image> <x> <y> <max height> <max width>" && exit + +ImageLayer 0< <( + ImageLayer::add [identifier]="example0" [x]="$2" [y]="$3" [max_width]="$5" [max_height]="$4" [path]="$1" + read +)