initial commit
This commit is contained in:
commit
8f7afc28a2
2
N33R_status.sh
Executable file
2
N33R_status.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
sudo nmap minecraft.youdieifyou.work -PN -n -sV -p minecraft
|
53
battery.scm
Normal file
53
battery.scm
Normal file
@ -0,0 +1,53 @@
|
||||
;;; Battery monitoring daemon script.
|
||||
|
||||
(import shell)
|
||||
|
||||
(import srfi-1)
|
||||
|
||||
;; Constant values.
|
||||
|
||||
;; Battery level control interval, in seconds.
|
||||
|
||||
(define check-interval 5)
|
||||
|
||||
;; Path to the virtual file containing the battery percentage number.
|
||||
|
||||
(define capacity-path "/sys/class/power_supply/BAT1/capacity")
|
||||
|
||||
;; Association list of threshold levels and formatting functions.
|
||||
|
||||
(define thresholds
|
||||
`((20 . ,(lambda (battery-level)
|
||||
(string-append "Battery level low: " (number->string battery-level) "%.")))
|
||||
(5 . ,(lambda (battery-level)
|
||||
(string-append "Battery level critical: " (number->string battery-level) "%.")))))
|
||||
|
||||
;; Utility functions.
|
||||
|
||||
;; Get the battery level, return it as a number.
|
||||
|
||||
(define (get-battery-level)
|
||||
(with-input-from-file capacity-path read))
|
||||
|
||||
;; Method to display a notification dialog.
|
||||
|
||||
(define (user-notify message)
|
||||
(run ("notify-send '" ,message "'")))
|
||||
|
||||
;; Core daemon loop.
|
||||
|
||||
(define (monitor-battery previous-level)
|
||||
(let ((current-level (get-battery-level)))
|
||||
(let ((crossed-thresholds
|
||||
(filter (lambda (n)
|
||||
(and (>= n current-level)
|
||||
(< n previous-level)))
|
||||
(map car thresholds))))
|
||||
(if (not (null? crossed-thresholds))
|
||||
(user-notify ((cdr (assoc (last crossed-thresholds) thresholds)) current-level))))
|
||||
(sleep check-interval)
|
||||
(monitor-battery current-level)))
|
||||
|
||||
;; Entry point of the program.
|
||||
|
||||
(monitor-battery 100)
|
3
battery_monitor.sh
Executable file
3
battery_monitor.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
BATTERY_PATH="/sys/class/power_supply/BAT1"
|
||||
watch -tn 1 "cat $BATTERY_PATH/status && cat $BATTERY_PATH/capacity"
|
2
browse_source.sh
Executable file
2
browse_source.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
highlight -O ansi $1 | less -R
|
4
coding-terminal
Executable file
4
coding-terminal
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
xrdb -merge ~/.Xresources.green
|
||||
urxvt -fn xft:inconsolata-22 -letsp -1 -im none &
|
||||
xrdb -merge ~/.Xresources
|
20
define.lisp
Normal file
20
define.lisp
Normal file
@ -0,0 +1,20 @@
|
||||
(asdf:load-system :drakma)
|
||||
(asdf:load-system :yason)
|
||||
|
||||
(defun wiktionary-query (search-string)
|
||||
(let ((query-string (format nil "https://en.wikipedia.org/w/rest.php/v1/search/page?q=~A&limit=1" search-string)))
|
||||
(let ((http-result (handler-case (drakma:http-request query-string)
|
||||
(usocket:ns-host-not-found-error (c)
|
||||
(princ "Host not found.")
|
||||
nil))))
|
||||
(let ((json (yason:parse (coerce (map 'list #'code-char http-result) 'string))))
|
||||
(let ((results (gethash "pages" json)))
|
||||
(if (null results)
|
||||
(princ "No results found.")
|
||||
(let ((page-query-string (format nil "https://en.wikipedia.org/api/rest_v1/page/summary/~A" (gethash "title" (car results)))))
|
||||
(let ((page-result (handler-case (drakma:http-request page-query-string)
|
||||
(usocket:ns-host-not-found-error (c)
|
||||
(princ "Host not found when retreiving data.")
|
||||
nil))))
|
||||
(let ((json (yason:parse (map 'string #'code-char page-result))))
|
||||
(princ (gethash "extract" json)))))))))))
|
2
disable_internet.sh
Executable file
2
disable_internet.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
newgrp no-internet
|
2
float_xinput_device.sh
Executable file
2
float_xinput_device.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
xinput --float `xinput | grep "$1" | grep -o 'id=[[:digit:]]\+' | cut -d'=' -f2`
|
2
spotify-open
Executable file
2
spotify-open
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri $1
|
37
wikifortune
Executable file
37
wikifortune
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/python3
|
||||
import requests
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
def connection_error():
|
||||
print("Could not contact wikipedia servers.")
|
||||
sys.exit(1)
|
||||
|
||||
def get_random_page():
|
||||
params = {
|
||||
'action' : 'query',
|
||||
'format' : 'json',
|
||||
'list' : 'random',
|
||||
'rnlimit' : 1,
|
||||
'rnnamespace' : 0
|
||||
}
|
||||
try:
|
||||
return requests.get('https://en.wikipedia.org/w/api.php', params).json()['query']['random'][0]
|
||||
except ConnectionError:
|
||||
connection_error()
|
||||
|
||||
def get_page_with_summary(title):
|
||||
try:
|
||||
return requests.get('https://en.wikipedia.org/api/rest_v1/page/summary/' + title).json()
|
||||
except ConnectionError:
|
||||
connection_error()
|
||||
|
||||
def main():
|
||||
while True:
|
||||
page = get_page_with_summary(get_random_page()['title'])
|
||||
if page['type'] == 'standard':
|
||||
break
|
||||
print(page['title'] + ':\n\n' + textwrap.fill(page['extract'], width=80))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
55
wikipedia
Executable file
55
wikipedia
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/python3
|
||||
import requests
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
def connection_error():
|
||||
print("Could not contact wikipedia servers.")
|
||||
sys.exit(1)
|
||||
|
||||
def page_search(string):
|
||||
params = {
|
||||
'q' : string,
|
||||
'limit' : 1
|
||||
}
|
||||
try:
|
||||
return requests.get('https://en.wikipedia.org/w/rest.php/v1/search/page', params).json()['pages']
|
||||
except ConnectionError:
|
||||
connection_error()
|
||||
|
||||
def get_page_with_summary(title):
|
||||
try:
|
||||
return requests.get('https://en.wikipedia.org/api/rest_v1/page/summary/' + title).json()
|
||||
except ConnectionError:
|
||||
connection_error()
|
||||
|
||||
def get_page_links(title):
|
||||
params = {
|
||||
'action' : 'query',
|
||||
'titles' : title,
|
||||
'prop' : 'links',
|
||||
'format' : 'json'
|
||||
}
|
||||
try:
|
||||
return list(requests.get('https://en.wikipedia.org/w/api.php', params).json()['query']['pages'].values())[0]['links']
|
||||
except ConnectionError:
|
||||
connection_error()
|
||||
|
||||
def main():
|
||||
if not sys.argv[1:]:
|
||||
print("Usage: wikipedia <list of search terms>")
|
||||
sys.exit(1)
|
||||
else:
|
||||
result = page_search(' '.join(sys.argv[1:]))
|
||||
if result:
|
||||
page = get_page_with_summary(result[0]['title'])
|
||||
if page['type'] == 'disambiguation':
|
||||
print('Ambiguous result, please clarify:\n ' + '\n '.join([link['title'] for link in get_page_links(page['title'])]))
|
||||
else:
|
||||
print(page['title'] + ':\n\n' + textwrap.fill(page['extract'], width=80))
|
||||
else:
|
||||
print('No result found.')
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user