Skip to content

Atreyagaurav/scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scripts files

This repo contains small scripts I have written for various tasks, some still work, some are under development and some I have abandoned.

The summary of scripts are in following table, you can refer to specific section for full details.

Script GroupFile namelanguageShort description
Args Open./args-open.shBashOpens a command with given arguments.
Autocomplete*./autocomplete.pypythonAutocomplete frequent phrases
Battery Logs./battery.pyPythonLogs the battery percentage
Battery Logs./plot_battery.gnuplotGnuplotPlots the battery log and shows trend
Battery Logs./plot_battery.pyPythonPlots the battery log
Brightness./brightness.shBashControl the brightness of screen.
Capture Clip./capture_clipboard.pyPythonCapture the contents of the clipboard.
Conky./conky.shBashConky start scripts and prerequisites
Conky./daily_for_conky.shBashScripts to run daily for conky.
File Open./file-open.shBashOpens a file with a command.
Latex-compile./latex-compilebashCompile the latex file given.
Mail./mail.pyPythonChecks for the emails and sends notification
Menu./menu.shBashdmenu based menu for scripts
Microphone./microphone.shbashChanges Mic volume and shows shows it
Move Download./move-downloadbashMove recently downloaded files to PWD
Notification./notification.shbashNotification rules for dunst
OCR screen./ocr-screen.shbashRun tesserace OCR on selected rectangle
Pdf Images*./pdf_extract_images.pyPythonExtract images from pdfs.
Radio./radio.shBashPlays chosen radio from the given list.
Rename All./rename-all.pyPythonRenames all the files to snake case.
Save Screenshot./save-screenshotBashSaves the screenshot from clip to file.
Searchable PDFs./make-pdf-searchable.shBashMake image pdfs searchable.
Speak./speak.shbashTTS whatever is typed after command.
Timer./timer.pyPythonTimer
Volume./volume.shbashChanges Speaker volume and shows it
Word Count./word-count.shbashCount the number of lines/words/chars
Youtube./myyt.shBashSearches and plays videos from YouTube.

Note: * denotes the script is either incomplete or there is better alternative.

Autocomplete

Abandoned project

Basically saves a json of phrases you use frequently and then you can use them.

I’m planning to update this one using Dmenu, with two script options

  • Add new phrase
  • Insert phrase

I’ll probably rewrite it on bash if I do it again.

Battery Logs

Logs the % of battery you give to it in a file. There is plot_battery.{gnuplot,py} scripts to visualize the logged data.

Conky

Script to run the scripts I have on conky directory, as well as to run the necessary scripts before the conky one.

The file daily_for_conky.sh is to put into the crontab.

File Open

It uses dmenu to open a file, It’s basically same as using dmenu to open a program, but the second option will be like a file browser so you can pass that filename as an argument to the program.

Mail

It checks the email, sees if there is changes from the saved previous mails. And sends notification if there is a new one. It also prints the text in a colored format for conky.

Save Screenshot

It’s a simple script which saves the screenshot/image on the clipboard to a file. You can give a filename, or just let it save as screenshot.png which replaces the old one.

I use this line of command (import png:- | xclip -selection c -t image/png binded to PrtSc key) to take screenshots and keep it in the clipboard. I can just paste the screenshot into places that takes image input, instead of saving it always, so when I do want to save it, I use this script.

Timer

Simple timer to time events continuously. Like Lap time thing.

Rename all

It renames all the files into given path a snake case format. Ignores the hidden files.

Radio

Plays chosen radio from the list.

Youtube

This script can search and play videos from youtube, it uses your google API and the youtube-dl program. I forgot where exactly I got it from but it should be from somewhere in reddit.

Searchable PDFs

This script uses the tesseract OCR tool to convert a pdf into a searchable pdf. It converts the pdf to images and runs OCR on them then joins all the output from the OCR.

Capture Clip

This script captures the clipboard continuously and prints the contents on the stdout.This is useful when you want to collect a bunch of things like the links to various youtube videos from search address, or copy a buuch of lines or paragraphs in to a same place.

Brightness

This is to simply change the brightness because the default driver was not working for me for some reasons.

You can use -inc val or -dec val or -set val to increase, decrease or set the brightness to/by certain percentage.

Menu

This is just a dmenu based menu to run scripts, the scripts could be ones from here or any other program with specific command/arguments.

For example, this is my menu.json file that is used by menu.sh script. I have to make it show the tooltips someway inn future.

{
  "bgcolor": "black",
  "scripts": {
    "c2-picture": {
      "name": "c2 picture",
      "script": "feh /home/gaurav/Pictures/cc.jpg",
      "tooltip": "c2 background incase I need black blackground for transparent windows"
    },
    "radio-online": {
      "name": "Online Radio",
      "script": "/home/gaurav/scripts/radio.sh",
      "tooltip": "Play different radios online, from the list on file."
    },
    "file-open": {
      "name": "Open Files",
      "script": "/home/gaurav/scripts/file-open.sh",
      "tooltip": "open the program with command line arguments while opening."
    },
    "ddg-search": {
      "name": "Search word in DuckDuckGo",
      "script": "firefox --new-tab \"duckduckgo.com/$(xclip -o)\"",
      "tooltip": "Searches the highlighed word in duckduckgo."
    }
  }
}

Get Pdf Images [Don’t use it]

It extracts the images from pdf files, it can recursively look through the pdf files in the path.

Recently Found out poppler-tools has pdfimages which does it for us, so no need to use it.

latex-compile

Compile latex files.

Few flags and arguments are added for ease of operation.

Here is the help output for the script.

  Usage: latex-compile [-a|--auto] [-s|--supress] [-d|--debug] [-w|--watch <files>] [-r|--recipe <recipe>] [-c|--commands <args>] [-h|--help] [<files>]

Options:
  [-a|--auto]
    Automatically compile latex each time file is modified.
  [-s|--supress]
    Supress as much output as possible.
  [-d|--debug]
    Debug mode; print variables and exit.
  [-w|--watch] <files>
    Add more files to watch list which trigger auto compile.
  [-r|--recipe] <recipe>
    Recipe to use for compilation
  [-c|--commands] <args>
    Arguments to pass to latex compile program.
  [-h|--help]
    Display this and exit.
  [<files>]
    Files to compile, defaults to all .tex in PWD.

Most helpful, and the reason I wrote this is the -a|--auto flag which means the latex will be recompiled whenever I change something and save the tex file. Along with auto refreshing in the viewer we can set a automatic compile and see setup.

volume scripts

i3status config to get the output.

  
read_file volume{
	path = "/tmp/volume"
	format = "Spk: %content"
	format_bad = "Spk: MUTE"
}

read_file mic{
	path = "/tmp/mic"
	format = "Mic: %content"
	format_bad = "Mic: MUTE"
}

And this is how I have keybindings in my i3 config file, you can make similar things.

# Use pactl to adjust volume in PulseAudio.
set $refresh_i3status killall -SIGUSR1 i3status

bindsym XF86AudioRaiseVolume exec --no-startup-id ~/scripts/volume.sh -inc 5 && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id ~/scripts/volume.sh -dec 5 && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id ~/scripts/volume.sh -toggle && $refresh_i3status


bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
bindsym XF86MonBrightnessUp exec --no-startup-id ~/scripts/brightness.sh -inc 5
bindsym XF86MonBrightnessDown exec --no-startup-id ~/scripts/brightness.sh -dec 5

bindsym $mod+XF86AudioRaiseVolume exec --no-startup-id ~/scripts/microphone.sh -inc 5 && $refresh_i3status
bindsym $mod+XF86AudioLowerVolume exec --no-startup-id ~/scripts/microphone.sh -dec 5 && $refresh_i3status
bindsym $mod+XF86AudioMute exec --no-startup-id ~/scripts/microphone.sh -toggle && $refresh_i3status

# to set up and make the files
exec --no-startup-id ~/scripts/microphone.sh -echo
exec --no-startup-id ~/scripts/volume.sh -echo
# bindsym XF86MonBrightnessUp exec --no-startup-id 
# bindsym XF86MonBrightnessDown exec --no-startup-id   

notification

This script plays notification sounds for notifications form dunst.

put this in the dunstrc file. (NOTE: ~~/scripts/notification.sh~ is the path to this script.)

[notification_sound]
   summary = "*"
   script = ~/scripts/notification.sh

About

Small Scripts to do specific tasks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published