From 4a3f092b9ec64ac1c07c26903a1d45af4f39da55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Sun, 28 Feb 2021 21:59:03 +0300 Subject: [PATCH] Fixed DWM bug --- scripts/readability | 74 ++++++++++++++++++++++++++++++++++++++ scripts/status-bar/network | 4 +-- suckless/dwm/keybind.h | 1 - 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100755 scripts/readability diff --git a/scripts/readability b/scripts/readability new file mode 100755 index 00000000..f4d2d83d --- /dev/null +++ b/scripts/readability @@ -0,0 +1,74 @@ +#!/usr/bin/env node + +var program = require('commander') + , read = require('node-readability') + , he = require('he') + , pkg = require('../package.json') + , clc = require('cli-color'); + + + +program + .version(pkg.version) + .option('-c, --color', 'use colors in terminal') + .option('-f, --format [format]', 'set the format for the result (text or html)', '') + .parse(process.argv); + +var styles = {}; +styles.h1 = styles.h2 = styles.muted = function(s) { return s; }; + +if(program.color) { + styles.h1 = clc.underline.bold; + styles.h2 = clc.bold; + styles.muted = clc.white; + console.log(clc.reset); +} + +var error = function(msg) { + if(msg) console.log(clc.red("Error: ")+msg); + console.log(); + usage(); + process.exit(0); +} + +var usage = function() { + console.log("Usage: readability [url]"); + console.log(); + console.log("E.g.: readability http://techcrunch.com/2014/02/12/marc-andreessen-tech-is-still-recovering-from-a-depression"); + console.log(); +} + + +if(process.argv.length < 2) return error(); +var url = process.argv[2]; + +if(typeof url!='string' || !url.match(/^https?:\/\//)) return error(url+" is an invalid url"); + +console.log(url); +read(url, function(err, article, meta) { + // The title of the page. + console.log(); + console.log(styles.h1(article.title)); + console.log(); + // The main body of the page. + // console.log(article.content); + var content = article.content; + + if(program.format == 'html') return console.log(content); + + content = content.replace(/([^<])+<\/h[2-9]>/gi, function(match, header) { + return styles.h2(match); + }); + + content = content.replace(/ {2,*}|\t/g,' '); + + var content = content.replace(/<\/?[^>]+(>|$)/g, ""); + content = he.decode(content); + console.log(content); + + // The raw HTML code of the page + //console.log(article.html); + // The document object of the page + //console.log(article.document); + +}); diff --git a/scripts/status-bar/network b/scripts/status-bar/network index 9fd90321..6e991bec 100755 --- a/scripts/status-bar/network +++ b/scripts/status-bar/network @@ -9,11 +9,11 @@ is_wlan_used=$(cat /sys/class/net/${WLAN_IT}/carrier) echo -n "^c#88c0d0^" if [ "$is_eth_used" -eq 1 ]; then # wired network is carrying - icon="^d^ " #uF6FF + icon=" ^d^ " #uF6FF elif [ "$is_wlan_used" -eq 1 ]; then # wireless network is carrying icon="直 ^d^ $(nmcli -t -f active,ssid dev wifi | egrep '^yes' | cut -d\' -f2 | cut -d ':' -f2)" #uF1EB else - icon="^d^" #uf128 # no network + icon=" ^d^" #uf128 # no network fi echo -n $icon diff --git a/suckless/dwm/keybind.h b/suckless/dwm/keybind.h index c1c580c9..621a2a21 100644 --- a/suckless/dwm/keybind.h +++ b/suckless/dwm/keybind.h @@ -98,7 +98,6 @@ static Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) - TAGKEYS( XK_0, 9) { MODKEY|ShiftMask, XK_q, spawn, {.v = outmenu} }, { MODKEY|ShiftMask, XK_t, spawn, {.v = trackpad} }, { MODKEY, XK_x, spawn, {.v = lock } },