@ -1,114 +0,0 @@ | |||
/** | |||
* @name ClearVision | |||
* @author ClearVision Team | |||
* @version 6 | |||
* @description Highly customizable theme for BetterDiscord. | |||
* @source https://github.com/ClearVision/ClearVision-v6 | |||
* @website https://clearvision.gitlab.io | |||
* @invite 2fKpjAR | |||
*/ | |||
/* Credits to Zerthox for making the original theme. */ | |||
/* IMPORT CSS */ | |||
@import url(https://clearvision.gitlab.io/v6/main.css); | |||
/* SETTINGS */ | |||
:root { | |||
/* ACCENT COLORS */ | |||
--main-color: #2780e6; /* main accent color (hex, rgb or hsl) [default: #2780e6] */ | |||
--hover-color: #1e63b3; /* hover accent color (hex, rgb or hsl) [default: #1e63b3] */ | |||
--success-color: #43b581; /* success accent color (hex, rgb or hsl) [default: #43b581] */ | |||
--danger-color: #982929; /* danger accent color (hex, rgb or hsl) [default: #982929] */ | |||
/* Customization Patch */ | |||
--channel-unread: var(--main-color); /* Unread Server channel color. [default: var(--main-color)] THIS OVERRIDES YOUR MAIN COLOR*/ | |||
--channel-color: rgba(255,255,255,0.3); /*Read Server channel color [default: rgba(255,255,255,0.3);]*/ | |||
--muted-color: rgba(255,255,255,0.1); /*Muted channel color [default: rgba(255,255,255,0.1);]*/ | |||
--url-color: var(--main-color); /*The color of url links [default: var(--main-color)]*/ | |||
/* STATUS COLORS */ | |||
--online-color: #43b581; /* online status color (hex, rgb or hsl) [default: #43b581] */ | |||
--idle-color: #faa61a; /* idle status color (hex, rgb or hsl) [default: #faa61a] */ | |||
--dnd-color: #982929; /* dnd status color (hex, rgb or hsl) [default: #982929] */ | |||
--streaming-color: #593695; /* streaming status color (hex, rgb or hsl) [default: #593695] */ | |||
--offline-color: #808080; /* offline/invisible status color (hex, rgb or hsl) [default: #808080] */ | |||
/* GENERAL */ | |||
--main-font: Whitney, Helvetica Neue, Helvetica, Arial, sans-serif; /* main font for app (font must be installed) [default: Whitney, Helvetica Neue, Helvetica, Arial, sans-serif] */ | |||
--code-font: Consolas, Liberation Mono, Menlo, Courier, monospace; /* font for codeblocks (font must be installed) [default: Consolas, Liberation Mono, Menlo, Courier, monospace] */ | |||
--server-columns: 1; /* amount of server list columns [default: 1] */ | |||
--channels-width: 220px; /* channel list width (240px for Discord default) [default: 220px] */ | |||
--members-width: 240px; /* member list width [default: 240px] */ | |||
--avatar-roundness: 50%; /* avatar roundness (0% for squares, 50% for circles) [default: 50%] */ | |||
/* APP BACKGROUND */ | |||
--background-shading: 100%; /* app background shading (0 for complete smoothness) [default: 100%] */ | |||
--background-overlay: rgba(0, 0, 0, 0.6); /* app background overlay color/gradient [default: rgba(0, 0, 0, 0.6)] */ | |||
--background-image: url(https://clearvision.gitlab.io/images/sapphire.jpg); /* app background image (link must be HTTPS) [default: url(https://clearvision.gitlab.io/images/sapphire.jpg)]*/ | |||
--background-position: center; /* app background position [default: center] */ | |||
--background-size: cover; /* app background size [default: cover] */ | |||
--background-repeat: no-repeat; /* app background repeat [default: no-repeat] */ | |||
--background-attachment: fixed; /* app background attachment [default: fixed] */ | |||
--background-brightness: 100%; /* app background brightness (< 100% for darken, > 100% for lighten) [default: 100%] */ | |||
--background-contrast: 100%; /* app background contrast [default: 100%] */ | |||
--background-saturation: 100%; /* app background saturation [default: 100%] */ | |||
--background-invert: 0%; /* app background invert (0 - 100%) [default: 0%] */ | |||
--background-grayscale: 0%; /* app background grayscale ( 0 - 100%) [default: 0%] */ | |||
--background-sepia: 0%; /* app background sepia (0 - 100%) [default: 0%] */ | |||
--background-blur: 0px; /* app background blur [default: 0px] */ | |||
/* HOME BUTTON ICON */ | |||
--home-icon: url(https://clearvision.gitlab.io/icons/discord.svg); /* home button icon (link must be HTTPS) [default: url(https://clearvision.gitlab.io/icons/discord.svg)]*/ | |||
--home-position: center; /* home button icon position [default: center] */ | |||
--home-size: 40px; /* home button icon size [default: 40px] */ | |||
/* MODAL BACKDROP */ | |||
--backdrop-overlay: rgba(0, 0, 0, 0.8); /* modal backdrop overlay color/gradient [default: rgba(0, 0, 0, 0.8)] */ | |||
--backdrop-image: var(--background-image); /* modal backdrop image (link must be HTTPS) [default: var(---background-image)] */ | |||
--backdrop-position: var(--background-position); /* modal backdrop position [default: var(---background-position)] */ | |||
--backdrop-size: var(--background-size); /* modal backdrop size [default: var(---background-size)] */ | |||
--backdrop-repeat: var(--background-repeat); /* modal backdrop repeat [default: var(---background-repeat)] */ | |||
--backdrop-attachment: var(--background-attachment); /* modal backdrop attachment [default: var(--background-attachment)] */ | |||
--backdrop-brightness: var(--background-brightness); /* modal backdrop brightness (< 100% for darken, > 100% for lighten) [default: var(---background-brightness)] */ | |||
--backdrop-contrast: var(--background-contrast); /* modal backdrop contrast [default: var(---background-contrast)] */ | |||
--backdrop-saturation: var(--background-saturation); /* modal backdrop saturation [default: var(---background-saturation)] */ | |||
--backdrop-invert: var(--background-invert); /* modal backdrop invert (0 - 100%) [default: var(---background-invert)] */ | |||
--backdrop-grayscale: var(--background-grayscale); /* modal backdrop grayscale ( 0 - 100%) [default: var(---background-grayscale)] */ | |||
--backdrop-sepia: var(--background-sepia); /* modal backdrop sepia (0 - 100%) [default: var(---background-sepia)] */ | |||
--backdrop-blur: var(--background-blur); /* modal backdrop blur [default: var(--background-blur)] */ | |||
/* USER POPOUT BACKGROUND */ | |||
--user-popout-image: var(--background-image); /* app background image (link must be HTTPS) [default: var(---background-image)] */ | |||
--user-popout-position: var(--background-position); /* user popout background position [default: var(---background-position)] */ | |||
--user-popout-size: var(--background-size); /* user popout background size [default: var(---background-size)] */ | |||
--user-popout-repeat: var(--background-repeat); /* user popout background repeat [default: var(---background-repeat)] */ | |||
--user-popout-attachment: var(--background-attachment); /* user popout background attachment [default: var(--background-attachment)] */ | |||
--user-popout-brightness: var(--background-brightness); /* user popout background brightness (< 100% for darken, > 100% for lighten) [default: var(---background-brightness)] */ | |||
--user-popout-contrast: var(--background-contrast); /* user popout background contrast [default: var(---background-contrast)] */ | |||
--user-popout-saturation: var(--background-saturation); /* user popout background saturation [default: var(---background-saturation)] */ | |||
--user-popout-invert: var(--background-invert); /* user popout background invert (0 - 100%) [default: var(---background-invert)] */ | |||
--user-popout-grayscale: var(--background-grayscale); /* user popout background grayscale (0 - 100%) [default: var(---background-grayscale)] */ | |||
--user-popout-sepia: var(--background-sepia); /* user popout background sepia (0 - 100%) [default: var(---background-sepia)] */ | |||
--user-popout-blur: calc(var(--background-blur) + 3px); /* user popout background blur [default: calc(var(--background-blur) + 3px)] */ | |||
/* USER MODAL BACKGROUND */ | |||
--user-modal-image: var(--background-image); /* app background image (link must be HTTPS) [default: var(---background-image)] */ | |||
--user-modal-position: var(--background-position); /* user modal background position [default: var(---background-position)] */ | |||
--user-modal-size: var(--background-size); /* user modal background size [default: var(---background-size)] */ | |||
--user-modal-repeat: var(--background-repeat); /* user modal background repeat [default: var(---background-repeat)] */ | |||
--user-modal-attachment: var(--background-attachment); /* user modal background attachment [default: var(--background-attachment)] */ | |||
--user-modal-brightness: var(--background-brightness); /* user modal background brightness (< 100% for darken, > 100% for lighten) [default: var(---background-brightness)] */ | |||
--user-modal-contrast: var(--background-contrast); /* user modal background contrast [default: var(---background-contrast)] */ | |||
--user-modal-saturation: var(--background-saturation); /* user modal background saturation [default: var(---background-saturation)] */ | |||
--user-modal-invert: var(--background-invert); /* user modal background invert (0 - 100%) [default: var(---background-invert)] */ | |||
--user-modal-grayscale: var(--background-grayscale); /* user modal background grayscale (0 - 100%) [default: var(---background-grayscale)] */ | |||
--user-modal-sepia: var(--background-sepia); /* user modal background sepia (0 - 100%) [default: var(---background-sepia)] */ | |||
--user-modal-blur: calc(var(--background-blur) + 3px); /* user modal background blur [default: calc(var(--background-blur) + 3px)] */ | |||
/* THEME BD COLORS */ | |||
--bd-blue: var(--main-color); /* betterdiscord main color [default: var(--main-color)] */ | |||
--bd-blue-hover: var(--hover-color); /* betterdiscord hover color [default: var(--hover-color)] */ | |||
--bd-blue-active: var(--hover-color); /* betterdiscord active color [default: var(--hover-color)] */ | |||
} |
@ -1,14 +0,0 @@ | |||
/** | |||
* @name Dark Discord | |||
* @version 1.0 | |||
* @description An actual dark mode for discord. | |||
* @source https://github.com/zzzmario/dark-discord | |||
* @authorId 583062692596547585 | |||
* @author mario | |||
* @donate https://paypal.me/zzzmario | |||
* @invite 7JceW7S | |||
**/ | |||
@import url(https://zzzmario.github.io/dark-discord/src/source.css); |
@ -1,3 +1,3 @@ | |||
setlocal wrap linebreak nolist | |||
autocmd BufWritePost *.tex :GrammarousCheck | |||
autocmd BufWritePost *.tex :GrammarousCheck --lang=en-GB |
@ -1,161 +1,53 @@ | |||
let g:lightline = { | |||
\ 'colorscheme': 'material_vim', | |||
\ 'active': { | |||
\ 'right': [ [ 'lineinfo' ], [ 'percent', 'wordcount' ], [ 'fileformat', 'fileencoding', 'filetype' ] ], | |||
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ], | |||
\ 'right':[[ 'filetype', 'percent', 'lineinfo' ], [ 'cocstatus' ]] | |||
\ }, | |||
\ 'component_function': { | |||
\ 'wordcount': 'WordCount', | |||
\ }, | |||
\ 'tabline': { | |||
\ 'left': [['explorer_pad'], ['buffers']], | |||
\ 'right': [['gitbranch', 'smarttabs']] | |||
\ 'left': [ ['buffers'] ], | |||
\ 'right': [ ['close'] ], | |||
\ }, | |||
\ 'component_expand': { | |||
\ 'buffers': 'lightline#bufferline#buffers', | |||
\ 'smarttabs': 'SmartTabsIndicator', | |||
\ 'trailing': 'lightline#trailing_whitespace#component' | |||
\ }, | |||
\ 'component_function': { | |||
\ 'explorer_pad': 'lightline#explorer_pad#left_pad', | |||
\ 'percent': 'LightlinePercent', | |||
\ 'lineinfo': 'LightlineLineinfo', | |||
\ 'filename': 'LightlineFilename', | |||
\ 'fullname': 'LightlineFullname', | |||
\ 'mode': 'LightlineMode', | |||
\ 'gitbranch': 'LightlineGitbranch', | |||
\ 'readonly': 'LightlineReadonly', | |||
\ 'modified': 'LightlineModified', | |||
\ 'filetype': 'LightlineFiletype', | |||
\ 'cocstatus': 'LightlineCoc', | |||
\ 'buffers': 'lightline#bufferline#buffers', | |||
\ }, | |||
\ 'component_type': { | |||
\ 'buffers': 'tabsel', | |||
\ 'trailing': 'warning' | |||
\ }, | |||
\ 'buffers': 'tabsel', | |||
\ } | |||
\ } | |||
function! s:trim(maxlen, str) abort | |||
let trimed = len(a:str) > a:maxlen ? a:str[0:a:maxlen] . '..' : a:str | |||
return trimed | |||
endfunction | |||
function! LightlineCoc() abort | |||
if winwidth(0) < 60 | |||
return '' | |||
endif | |||
return coc#status() | |||
endfunction | |||
function! LightlinePercent() abort | |||
if winwidth(0) < 60 | |||
return '' | |||
endif | |||
let l:percent = line('.') * 100 / line('$') . '%' | |||
return printf('%-4s', l:percent) | |||
endfunction | |||
function! LightlineLineinfo() abort | |||
if winwidth(0) < 86 | |||
return '' | |||
endif | |||
let l:current_line = printf('%-3s', line('.')) | |||
let l:max_line = printf('%-3s', line('$')) | |||
let l:lineinfo = ' ' . l:current_line . '/' . l:max_line | |||
return l:lineinfo | |||
endfunction | |||
function! LightlineFilename() abort | |||
let l:prefix = expand('%:p') =~? "fugitive://" ? '(fugitive) ' : '' | |||
let l:maxlen = winwidth(0) - winwidth(0) / 2 | |||
let l:relative = expand('%:.') | |||
let l:tail = expand('%:t') | |||
let l:noname = 'No Name' | |||
if winwidth(0) < 50 | |||
return '' | |||
function! WordCount() | |||
let currentmode = mode() | |||
if !exists("g:lastmode_wc") | |||
let g:lastmode_wc = currentmode | |||
endif | |||
if winwidth(0) < 86 | |||
return l:tail ==# '' ? l:noname : l:prefix . s:trim(l:maxlen, l:tail) | |||
" if we modify file, open a new buffer, be in visual ever, or switch modes | |||
" since last run, we recompute. | |||
if &modified || !exists("b:wordcount") || currentmode =~? '\c.*v' || currentmode != g:lastmode_wc | |||
let g:lastmode_wc = currentmode | |||
let l:old_position = getpos('.') | |||
let l:old_status = v:statusmsg | |||
execute "silent normal g\<c-g>" | |||
if v:statusmsg == "--No lines in buffer--" | |||
let b:wordcount = 0 | |||
else | |||
let s:split_wc = split(v:statusmsg) | |||
if index(s:split_wc, "Selected") < 0 | |||
let b:wordcount = str2nr(s:split_wc[11]) | |||
else | |||
let b:wordcount = str2nr(s:split_wc[5]) | |||
endif | |||
let v:statusmsg = l:old_status | |||
endif | |||
call setpos('.', l:old_position) | |||
return b:wordcount | |||
else | |||
return b:wordcount | |||
endif | |||
return l:relative ==# '' ? l:noname : l:prefix . s:trim(l:maxlen, l:relative) | |||
endfunction | |||
function! LightlineFullname() abort | |||
let l:relative = expand('%') | |||
return l:relative | |||
endfunction | |||
function! LightlineModified() abort | |||
return &modified ? '*' : '' | |||
endfunction | |||
function! LightlineMode() abort | |||
let ftmap = { | |||
\ 'coc-explorer': 'EXPLORER', | |||
\ 'fugitive': 'FUGITIVE', | |||
\ 'vista': 'OUTLINE' | |||
\ } | |||
return get(ftmap, &filetype, lightline#mode()) | |||
endfunction | |||
let g:lightline.component_function = { 'lineinfo': 'LightlineLineinfo' } | |||
function! LightlineLineinfo() abort | |||
if winwidth(0) < 86 | |||
return '' | |||
endif | |||
let l:current_line = printf('%-3s', line('.')) | |||
let l:max_line = printf('%-3s', line('$')) | |||
let l:lineinfo = ' ' . l:current_line . '/' . l:max_line | |||
return l:lineinfo | |||
endfunction | |||
function! LightlineReadonly() abort | |||
let ftmap = { | |||
\ 'coc-explorer': '', | |||
\ 'fugitive': '', | |||
\ 'vista': '' | |||
\ } | |||
let l:char = get(ftmap, &filetype, '') | |||
return &readonly ? l:char : '' | |||
endfunction | |||
function! LightlineGitbranch() abort | |||
if exists('*fugitive#head') | |||
let maxlen = 20 | |||
let branch = fugitive#head() | |||
return branch !=# '' ? ' '. s:trim(maxlen, branch) : '' | |||
endif | |||
return fugitive#head() | |||
endfunction | |||
function! LightlineFiletype() abort | |||
let l:icon = WebDevIconsGetFileTypeSymbol() | |||
return winwidth(0) > 86 ? (strlen(&filetype) ? &filetype . ' ' . l:icon : l:icon) : '' | |||
endfunction | |||
function! String2() | |||
return 'BUFFERS' | |||
endfunction | |||
function! SmartTabsIndicator() abort | |||
let tabs = lightline#tab#tabnum(tabpagenr()) | |||
let tab_total = tabpagenr('$') | |||
return tabpagenr('$') > 1 ? ('TABS ' . tabs . '/' . tab_total) : '' | |||
endfunction | |||
" autoreload | |||
command! LightlineReload call LightlineReload() | |||
function! LightlineReload() abort | |||
call lightline#init() | |||
call lightline#colorscheme() | |||
call lightline#update() | |||
endfunction | |||
let g:lightline#trailing_whitespace#indicator = '' |
@ -0,0 +1,10 @@ | |||
#!/bin/sh | |||
# This script uses grabc (https://github.com/muquit/grabc) to grab | |||
# a pixel from your screen and copy its value to clipboard | |||
color=$(grabc) | |||
printf "%s" "$color" | xclip -selection clipboard | |||
notify-send -h "string:fgcolor:$color" -a " Color Grabbed" "$color" |
@ -0,0 +1,19 @@ | |||
License is MIT | |||
Permission is hereby granted, free of charge, to any person obtaining | |||
a copy of this software and associated documentation files (the "Software"), | |||
to deal in the Software without restriction, including without limitation | |||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
and/or sell copies of the Software, and to permit persons to whom the | |||
Software is furnished to do so, subject to the following conditions: | |||
The above copyright notice and this permission notice shall be included | |||
in all copies or substantial portions of the Software. | |||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | |||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,58 @@ | |||
## | |||
# Makefile automatically generated by genmake 1.0, Mar-16-97 | |||
# genmake 1.0 by ma_muquit@fccc.edu, RCS | |||
## | |||
CC= cc | |||
DEFS= | |||
PROGNAME= grabc | |||
LIBS= -L/usr/X11R6/lib -lX11 | |||
INCLUDES= -I. | |||
cp=/bin/cp -fv | |||
DESTDIR = | |||
binary=./grabc | |||
manpage=./grabc.1 | |||
bindir=/usr/local/bin | |||
mandir=/usr/local/share/man/man1 | |||
# replace -O with -g in order to debug | |||
DEFINES= $(INCLUDES) $(DEFS) -D__USE_FIXED_PROTOTYPES__ -DSYS_UNIX=1 | |||
CFLAGS= -O $(DEFINES) | |||
SRCS = grabc.c | |||
OBJS = grabc.o | |||
.c.o: | |||
rm -f $@ | |||
$(CC) $(CFLAGS) -c $*.c | |||
all: $(PROGNAME) | |||
$(PROGNAME) : $(OBJS) | |||
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS) | |||
doc: | |||
pod2man grabc.pod > grabc.1 | |||
install: installdirs install-bin install-man | |||
install-bin: | |||
${cp} ${binary} ${DESTDIR}${bindir} | |||
installdirs: | |||
$(SHELL) ./mkinstalldirs ${DESTDIR}${bindir} | |||
$(SHELL) ./mkinstalldirs ${DESTDIR}${mandir} | |||
install-man: | |||
${cp} ${manpage} ${DESTDIR}${mandir} | |||
deb: | |||
/bin/rm -f *.deb | |||
/bin/rm -rf /tmp/grabc | |||
make DESTDIR=/tmp/grabc install | |||
fpm -s dir -t deb -C /tmp/grabc --name grabc --version 1.0.2 --iteration 1 --description "A program to id entify a pixel color on an X Window" | |||
/bin/rm -rf /tmp/grabc | |||
clean: | |||
rm -f $(OBJS) $(PROGNAME) core *.deb |
@ -0,0 +1,109 @@ | |||
# grabc | |||
A command line tool to identify a pixel color on an X Window. | |||
When this program is run, the mouse pointer is grabbed and changed to | |||
a cross hair and when the mouse is clicked, the color of the clicked | |||
pixel is written to stdout in hex prefixed with # | |||
This program can be useful when you see a color and want to use the | |||
color in xterm or your window manager's border but no clue what the | |||
name of the color is. It's silly to use a image processing software | |||
to find it out. (That's how I described it 20 years ago, so keeping it | |||
this way for historical reasons - Apr-11-2018). | |||
# Synopsis | |||
``` | |||
grabc v1.0.2 | |||
A program to identify a pixel color of an X Window | |||
by muquit@muquit.com https://www.muquit.com/ | |||
Usage: grabc [options] | |||
Where the options are: | |||
-v - show version info | |||
-h - show this usage | |||
-hex - print pixel value as Hex on stdout | |||
-rgb - print pixel value as RGB on stderr | |||
-W - print the Window id at mouse click | |||
-w id - window id in hex, use with -l +x+y | |||
-l +x+y - pixel co-ordinate. requires window id | |||
-d - show debug messages | |||
-a - Print all 16 bits of color. Default is high order 8 bits | |||
Example: | |||
* Print pixel color in hex on stdout: | |||
$ grabc | |||
* Show usage: | |||
$ grabc -h | |||
* Print Window Id (Note the upper case W): | |||
$ grabc -W | |||
* Print pixel color of Window with id 0x13234 at location 10,20 | |||
$ grabc -w 0x13234 -l +10+20 | |||
``` | |||
# How to compile | |||
Older version of this program is available on Ubuntu. However, if you need to get the latest version, you have to compile it yourself. | |||
* You will need ```libx11-dev``` package if you are on Ubuntu. | |||
``` | |||
sudo apt-get -y install libx11-dev | |||
``` | |||
* To compile, at the shell prompt, type: | |||
``` | |||
make | |||
``` | |||
* To install, at the shell prompt, type: | |||
``` | |||
sudo make install | |||
``` | |||
The binary *grabc* will be install in /usr/local/bin/ and the man page *grabc.1* | |||
will be installed in /usr/local/share/man/man1/ | |||
If you want to install it in some other directory: | |||
``` | |||
make DESTDIR=/tmp/grabc install | |||
``` | |||
* If you want to create a debian package, install [fpm](https://github.com/jordansissel/fpm) first, then type: | |||
``` | |||
make deb | |||
``` | |||
* Install the debian package: | |||
``` | |||
sudo dpkg -i ./grabc_1.0.2-1_amd64.deb | |||
``` | |||
* To uninstall the debian package: | |||
``` | |||
sudo dpkg -r grabc | |||
``` | |||
# Know Issues | |||
* If color grabbed from root window, it might always show #000000 (Depending | |||
on the Window Manager in use) | |||
# ChangeLog | |||
# v1.0.2 | |||
* Was not working properly on Ubuntu Terminal. It was using default Colormap. Do not use default colormap, rather get it from window attributes. | |||
* If could not get XImage from target window, it is probably root window, | |||
so try to grab it from there. | |||
* Added some options | |||
* Color can be grabbed from a specific location | |||
* Change Copyright to MIT from GNU GPL | |||
(Apr-10-2018) | |||
# v1.0.1 | |||
* first cut | |||
(march-16-1997) | |||
# License | |||
MIT |
@ -0,0 +1,187 @@ | |||
.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) | |||
.\" | |||
.\" Standard preamble: | |||
.\" ======================================================================== | |||
.de Sp \" Vertical space (when we can't use .PP) | |||
.if t .sp .5v | |||
.if n .sp | |||
.. | |||
.de Vb \" Begin verbatim text | |||
.ft CW | |||
.nf | |||
.ne \\$1 | |||
.. | |||
.de Ve \" End verbatim text | |||
.ft R | |||
.fi | |||
.. | |||
.\" Set up some character translations and predefined strings. \*(-- will | |||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will | |||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and | |||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, | |||
.\" nothing in troff, for use with C<>. | |||
.tr \(*W- | |||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |||
.ie n \{\ | |||
. ds -- \(*W- | |||
. ds PI pi | |||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |||
. ds L" "" | |||
. ds R" "" | |||
. ds C` "" | |||
. ds C' "" | |||
'br\} | |||
.el\{\ | |||
. ds -- \|\(em\| | |||
. ds PI \(*p | |||
. ds L" `` | |||
. ds R" '' | |||
. ds C` | |||
. ds C' | |||
'br\} | |||
.\" | |||
.\" Escape single quotes in literal strings from groff's Unicode transform. | |||
.ie \n(.g .ds Aq \(aq | |||
.el .ds Aq ' | |||
.\" | |||
.\" If the F register is turned on, we'll generate index entries on stderr for | |||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index | |||
.\" entries marked with X<> in POD. Of course, you'll have to process the | |||
.\" output yourself in some meaningful fashion. | |||
.\" | |||
.\" Avoid warning from groff about undefined register 'F'. | |||
.de IX | |||
.. | |||
.nr rF 0 | |||
.if \n(.g .if rF .nr rF 1 | |||
.if (\n(rF:(\n(.g==0)) \{ | |||
. if \nF \{ | |||
. de IX | |||
. tm Index:\\$1\t\\n%\t"\\$2" | |||
.. | |||
. if !\nF==2 \{ | |||
. nr % 0 | |||
. nr F 2 | |||
. \} | |||
. \} | |||
.\} | |||
.rr rF | |||
.\" | |||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |||
.\" Fear. Run. Save yourself. No user-serviceable parts. | |||
. \" fudge factors for nroff and troff | |||
.if n \{\ | |||
. ds #H 0 | |||
. ds #V .8m | |||
. ds #F .3m | |||
. ds #[ \f1 | |||
. ds #] \fP | |||
.\} | |||
.if t \{\ | |||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |||
. ds #V .6m | |||
. ds #F 0 | |||
. ds #[ \& | |||
. ds #] \& | |||
.\} | |||
. \" simple accents for nroff and troff | |||
.if n \{\ | |||
. ds ' \& | |||
. ds ` \& | |||
. ds ^ \& | |||
. ds , \& | |||
. ds ~ ~ | |||
. ds / | |||
.\} | |||
.if t \{\ | |||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |||
.\} | |||
. \" troff and (daisy-wheel) nroff accents | |||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |||
.ds ae a\h'-(\w'a'u*4/10)'e | |||
.ds Ae A\h'-(\w'A'u*4/10)'E | |||
. \" corrections for vroff | |||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |||
. \" for low resolution devices (crt and lpr) | |||
.if \n(.H>23 .if \n(.V>19 \ | |||
\{\ | |||
. ds : e | |||
. ds 8 ss | |||
. ds o a | |||
. ds d- d\h'-1'\(ga | |||
. ds D- D\h'-1'\(hy | |||
. ds th \o'bp' | |||
. ds Th \o'LP' | |||
. ds ae ae | |||
. ds Ae AE | |||
.\} | |||
.rm #[ #] #H #V #F C | |||
.\" ======================================================================== | |||
.\" | |||
.IX Title "GRABC 1" | |||
.TH GRABC 1 "2018-04-16" "perl v5.22.1" "User Contributed Perl Documentation" | |||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes | |||
.\" way too many mistakes in technical documents. | |||
.if n .ad l | |||
.nh | |||
.SH "NAME" | |||
grabc \- A tool to identify a pixel color of an X Window. | |||
.SH "SYNOPSIS" | |||
.IX Header "SYNOPSIS" | |||
.Vb 3 | |||
\& grabc v1.0.2 | |||
\& A program to identify a pixel color of an X Window | |||
\& by muquit@muquit.com https://www.muquit.com/ | |||
\& | |||
\& Usage: grabc [options] | |||
\& Where the options are: | |||
\& \-v \- show version info | |||
\& \-h \- show this usage | |||
\& \-hex \- print pixel value as Hex on stdout | |||
\& \-rgb \- print pixel value as RGB on stderr | |||
\& \-W \- print the Window id at mouse click | |||
\& \-w id \- window id in hex, use \-l +x+y | |||
\& \-l +x+y \- pixel co\-ordinate. requires window id | |||
\& \-d \- show debug messages | |||
\& \-a \- Print all 16 bits of color. Default is high order 8 bits | |||
\& Example: | |||
\& * Print pixel color in hex on stdout: | |||
\& $ grabc | |||
\& * Show usage: | |||
\& $ grabc \-h | |||
\& * Print Window Id (Note the upper case W): | |||
\& $ grabc \-W | |||
\& * Print pixel color of Window iwith id 0x13234 at location 10,20 | |||
\& $ grabc \-w 0x13234 \-l +10+20 | |||
.Ve | |||
.SH "DESCRIPTION" | |||
.IX Header "DESCRIPTION" | |||
grabc is a simple but very useful program to determine the color string in | |||
hex (or in \s-1RGB\s0 components) by clicking on a pixel on the screen. While web | |||
browsing, lots of time you find a nice color and wonder what color is that. | |||
Well just use grabc! | |||
.PP | |||
When this program is run, the mouse pointer is grabbed and changed to a | |||
cross hair and when the mouse is clicked, the color of the clicked pixel | |||
is written to stdout in hex prefixed with #. | |||
.SH "LICENSE" | |||
.IX Header "LICENSE" | |||
\&\s-1MIT\s0 | |||
.SH "AUTHOR" | |||
.IX Header "AUTHOR" | |||
grabc is written by Muhammad Muquit <muquit@muquit.com>. | |||
Homepage: <https://www.muquit.com/>. |
@ -0,0 +1,631 @@ | |||
/* A program to pick a color by clicking the mouse. | |||
* | |||
* RCS: | |||
* $Revision$ | |||
* $Date$ | |||
* | |||
* Description: | |||
* | |||
* When this program is run, the mouse pointer is grabbed and changed to | |||
* a cross hair and when the mouse is clicked, the color of the clicked | |||
* pixel is written to stdout in hex prefixed with # | |||
* | |||
* This program can be useful when you see a color and want to use the | |||
* color in xterm or your window manager's border but no clue what the | |||
* name of the color is. It's silly to use a image processing software | |||
* to find it out. | |||
* | |||
* Example: | |||
* xterm -bg `grabc` -fg `grabc` (silly but esoteric!) | |||
* | |||
* Development History: | |||
* who when why | |||
* ma_muquit@fccc.edu march-16-1997 first cut | |||
* muquit@muquit.com Apr-10-2018 Do not use default colormap, | |||
* rather get it from window attributes. | |||
*/ | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <unistd.h> | |||
#include <assert.h> | |||
#include <ctype.h> | |||
#include <string.h> | |||
#include <stdarg.h> | |||
#include <math.h> | |||
#include <signal.h> | |||
#include <time.h> | |||
#include <errno.h> | |||
#include <X11/Xos.h> | |||
#include <X11/Xlib.h> | |||
#include <X11/Xutil.h> | |||
#include <X11/Xresource.h> | |||
#include <X11/Xproto.h> | |||
#include <X11/Xatom.h> | |||
#include <X11/cursorfont.h> | |||
#include <X11/keysym.h> | |||
#ifndef True | |||
#define True 1 | |||
#endif | |||
#ifndef False | |||
#define False 0 | |||
#endif | |||
#define VERSION_S "1.0.2" | |||
static int g_debug = False; | |||
static int g_print_in_hex = True; | |||
static int g_print_in_rgb = False; | |||
static int g_print_all_16_bits = False; | |||
static Window g_window_id = (Window) NULL; | |||
static int g_loc_specified = False; | |||
static int g_x = 1; | |||
static int g_y = 1; | |||
static unsigned int g_width = 0; | |||
static unsigned int g_height = 0; | |||
static Cursor g_cross_cursor=(Cursor) NULL; | |||
/* private function prototypes */ | |||
static Window select_window (Display *,int *x,int *y); | |||
static Window findSubWindow(Display *display,Window top_winodw, | |||
Window window_to_check,int *x,int *y); | |||
static Window get_window_color(Display *display,XColor *color); | |||
static int MXError(Display *display,XErrorEvent *error); | |||
static void show_usage(void) | |||
{ | |||
char | |||
**p; | |||
static char *options[]= | |||
{ | |||
" -v - show version info", | |||
" -h - show this usage", | |||
" -hex - print pixel value as Hex on stdout", | |||
" -rgb - print pixel value as RGB on stderr", | |||
" -W - print the Window id at mouse click", | |||
" -w id - window id in hex, use -l +x+y", | |||
" -l +x+y - pixel co-ordinate. requires window id", | |||
" -d - show debug messages", | |||
" -a - Print all 16 bits RGB components of color", | |||
" Default is high order 8 bits of components", | |||
"Example:", | |||
"* Print pixel color in hex on stdout:", | |||
" $ grabc", | |||
"* Show usage:", | |||
" $ grabc -h", | |||
"* Print Window Id (Note the upper case W):", | |||
" $ grabc -W", | |||
"* Print pixel color of Window iwith id 0x13234 at location 10,20", | |||
" $ grabc -w 0x13234 -l +10+20", | |||
(char *) NULL | |||
}; | |||
(void) printf("\n"); | |||
(void) printf("grabc v%s\n",VERSION_S); | |||
(void) printf("A program to identify a pixel color of an X Window\n"); | |||
(void) printf("by muquit@muquit.com https://www.muquit.com/\n\n"); | |||
(void) printf("Usage: grabc [options]\n"); | |||
(void) printf("Where the options are:\n"); | |||
for (p=options; *p != NULL; p++) | |||
{ | |||
(void) fprintf(stdout,"%s\n",*p); | |||
(void) fflush(stdout); | |||
} | |||
} | |||
static void log_debug(const char *fmt,...) | |||
{ | |||
va_list | |||
args; | |||
if (!g_debug) | |||
{ | |||
return; | |||
} | |||
va_start(args, fmt); | |||
(void) fprintf(stderr,"[Debug]: "); | |||
vfprintf(stderr,fmt,args); | |||
(void) fprintf(stderr,"\n"); | |||
va_end(args); | |||
} | |||
static Cursor get_cross_cursor(Display *display) | |||
{ | |||
if (g_cross_cursor == (Cursor) NULL) | |||
{ | |||
g_cross_cursor=XCreateFontCursor(display,XC_tcross); | |||
if (g_cross_cursor == (Cursor) NULL) | |||
{ | |||
(void) fprintf (stderr,"ERROR: Failed to create Cross Cursor!\n"); | |||
exit(1); | |||
} | |||
} | |||
return g_cross_cursor; | |||
} | |||
static Window grab_mouse(Display *display,Window root_window) | |||
{ | |||
int | |||
status; | |||
Window | |||
subwindow; | |||
XEvent | |||
event; | |||
Cursor | |||
target_cursor; | |||
if (g_window_id != (Window) NULL) | |||
{ | |||
return g_window_id; | |||
} | |||
target_cursor = get_cross_cursor(display); | |||
status=XGrabPointer(display,root_window,False, | |||
(unsigned int) ButtonPressMask,GrabModeSync, | |||
GrabModeAsync,root_window,target_cursor,CurrentTime); | |||
if (status == GrabSuccess) | |||
{ | |||
XAllowEvents(display,SyncPointer,CurrentTime); | |||
XWindowEvent(display,root_window,ButtonPressMask,&event); | |||
subwindow = event.xbutton.subwindow; | |||
} | |||
else | |||
{ | |||
return root_window; | |||
} | |||
return subwindow; | |||
} | |||
static void upgrab_mouse(Display *display) | |||
{ | |||
if (g_window_id != (Window) NULL) | |||
{ | |||
XUngrabPointer(display,CurrentTime); | |||
} | |||
} | |||
/* | |||
** function to select a window | |||
** output parameters: x,y (coordinate of the point of click) | |||
** reutrns Window | |||
** exits if mouse can not be grabbed | |||
*/ | |||
static Window select_window(Display *display,int *x,int *y) | |||
{ | |||
Cursor | |||
target_cursor; | |||
int | |||
status; | |||
Window | |||
target_window, | |||
root_window; | |||
XEvent | |||
event; | |||
/* | |||
** If window id and location is specified return the window id as | |||
** target window. Also initilaize x, y those specified with -l | |||
*/ | |||
if ((g_window_id != (Window) NULL) && g_loc_specified) | |||
{ | |||
log_debug("Returning passing window: %lx",g_window_id); | |||
(*x) = g_x; | |||
(*y) = g_y; | |||
return g_window_id; | |||
} | |||
target_window=(Window) NULL; | |||
target_cursor = get_cross_cursor(display); | |||
root_window=XRootWindow(display,XDefaultScreen(display)); | |||
// log_debug("Root Window ID: 0x%08lx",root_window); | |||
status=XGrabPointer(display,root_window,False, | |||
(unsigned int) ButtonPressMask,GrabModeSync, | |||
GrabModeAsync,root_window,target_cursor,CurrentTime); | |||
if (status == GrabSuccess) | |||
{ | |||
XAllowEvents(display,SyncPointer,CurrentTime); | |||
XWindowEvent(display,root_window,ButtonPressMask,&event); | |||
Window subwindow = event.xbutton.subwindow; | |||
if (event.type == ButtonPress) | |||
{ | |||
target_window=findSubWindow(display,root_window, | |||
subwindow, | |||
&event.xbutton.x, | |||
&event.xbutton.y ); | |||
if (target_window == (Window) NULL) | |||
{ | |||
(void) fprintf (stderr, | |||
"ERROR: Failed to get target window, getting root window!\n"); | |||
target_window=root_window; | |||
} | |||
if (!g_loc_specified) | |||
{ | |||
XUngrabPointer(display,CurrentTime); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
(void) fprintf (stderr,"ERROR: Failed to grab mouse pointer!\n"); | |||
exit(1); | |||
} | |||
/* free things we do not need, always a good practice */ | |||
(*x)=event.xbutton.x; | |||
(*y)=event.xbutton.y; | |||
return (target_window); | |||
} | |||
/* find a window */ | |||
static Window findSubWindow(Display *display,Window top_window, | |||
Window window_to_check,int *x,int *y) | |||
{ | |||
int | |||
newx, | |||
newy; | |||
Window | |||
window; | |||
if (top_window == (Window) NULL) | |||
return ((Window) NULL); | |||
if (window_to_check == (Window) NULL) | |||
return ((Window) NULL); | |||
/* initialize automatics */ | |||
window=window_to_check; | |||
while ((XTranslateCoordinates(display,top_window,window_to_check, | |||
*x,*y,&newx,&newy,&window) != 0) && | |||
(window != (Window) NULL)) | |||
{ | |||
if (window != (Window) NULL) | |||
{ | |||
top_window=window_to_check; | |||
window_to_check=window; | |||
(*x)=newx; | |||
(*y)=newy; | |||
} | |||
} | |||
if (window == (Window) NULL) | |||
window=window_to_check; | |||
(*x)=newx; | |||
(*y)=newy; | |||
return (window); | |||
} | |||
/* | |||
* get the color of the pixel of the point of mouse click | |||
* output paramter: XColor *color | |||
* | |||
* returns | |||
* target Window on success | |||
* NULL on failure | |||
* | |||
*/ | |||
static Window get_window_color(Display *display,XColor *color) | |||
{ | |||
Window | |||
root_window, | |||
target_window; | |||
XImage | |||
*ximage; | |||
int | |||
x, | |||
y; | |||
Status | |||
status; | |||
root_window=XRootWindow(display,XDefaultScreen(display)); | |||
target_window=select_window(display,&x,&y); | |||
log_debug(" Root Window Id: 0x%08lx",root_window); | |||
log_debug("Target Window Id: 0x%08lx X,Y: +%d+%d",target_window,x,y); | |||
if (target_window == (Window) NULL) | |||
return (Window) NULL; | |||
ximage=XGetImage(display,target_window,x,y,1,1,AllPlanes,ZPixmap); | |||
if (ximage == (XImage *) NULL) | |||
{ | |||
/* Try root window */ | |||
log_debug("Could not get XImage from Window: 0x%08lx",target_window); | |||
log_debug("Trying to get XImage from root window: 0x%08lx",root_window); | |||
ximage=XGetImage(display,root_window,x,y,1,1,AllPlanes,ZPixmap); | |||
if (ximage == (XImage *) NULL) | |||
{ | |||
log_debug("Could not get XImage from target or root window"); | |||
return (Window) NULL; | |||
} | |||
else | |||
{ | |||
log_debug("OK successfully got XImage from root window"); | |||
target_window = root_window; | |||
} | |||
} | |||
color->pixel=XGetPixel(ximage,0,0); | |||
XDestroyImage(ximage); | |||
return (target_window); | |||
} | |||
/* forgiving X error handler */ | |||
static int MXError (Display *display, XErrorEvent *error) | |||
{ | |||
int | |||
xerrcode; | |||
xerrcode = error->error_code; | |||
if (xerrcode == BadAlloc || | |||
(xerrcode == BadAccess && error->request_code==88)) | |||
{ | |||
return (False); | |||
} | |||
else | |||
{ | |||
switch (error->request_code) | |||
{ | |||
case X_GetGeometry: | |||
{ | |||
if (error->error_code == BadDrawable) | |||
return (False); | |||
break; | |||
} | |||
case X_GetWindowAttributes: | |||
case X_QueryTree: | |||
{ | |||
if (error->error_code == BadWindow) | |||
return (False); | |||
break; | |||
} | |||
case X_QueryColors: | |||
{ | |||
if (error->error_code == BadValue) | |||
return(False); | |||
break; | |||
} | |||
} | |||
} | |||
return (True); | |||
} | |||
int main(int argc,char **argv) | |||
{ | |||
Display | |||
*display; | |||
int | |||
x, | |||
y, | |||
status; | |||
XColor | |||
color; | |||
int | |||
rc, | |||
i, | |||
r, | |||
g, | |||
b; | |||
Window | |||
window_id, | |||
target_window; | |||
XWindowAttributes | |||
window_attributes; | |||
char | |||
*option; | |||
for (i=1; i < argc; i++) | |||
{ | |||
option = argv[i]; | |||
switch(*(option+1)) | |||
{ | |||
case 'a': | |||
{ | |||
g_print_all_16_bits = True; | |||
break; | |||
} | |||
case 'd': | |||
{ | |||
g_debug = True; | |||
break; | |||
} | |||
case 'h': | |||
{ | |||
if (strncmp("hex",option+1,3) == 0) | |||
{ | |||
g_print_in_hex = True; | |||
} | |||
else | |||
{ | |||
show_usage(); | |||
return(1); | |||
} | |||
break; | |||
} | |||
case 'r': | |||
{ | |||
if (strncmp("rgb",option+1,3) == 0) | |||
{ | |||
g_print_in_rgb = True; | |||
} | |||
break; | |||
} | |||
case 'w': | |||
{ | |||
if (*option == '-') | |||
{ | |||
i++; | |||
if (i == argc) | |||
{ | |||
(void) fprintf(stderr,"ERROR: Missing Window id\n"); | |||
return(1); | |||
} | |||
} | |||
g_window_id = (Window) strtol(argv[i],NULL, 16); | |||
break; | |||
} | |||
case 'W': | |||
{ | |||
display=XOpenDisplay((char *) NULL); | |||
if (display == NULL) | |||
{ | |||
(void) fprintf(stderr,"ERROR: Could not open Display\n"); | |||
return(1); | |||
} | |||
Window window = select_window(display, &x, &y); | |||
if (window != (Window) NULL) | |||
{ | |||
log_debug("Window ID: 0x%08lx",window); | |||
(void) fprintf(stdout,"0x%lx\n",window); | |||
} | |||
return(1); | |||
break; | |||
} | |||
case 'l': | |||
{ | |||
if (*option == '-') | |||
{ | |||
i++; | |||
if (i == argc) | |||
{ | |||
(void) fprintf(stderr,"ERROR: Missing location +x+y\n"); | |||
return(1); | |||
} | |||
} | |||
rc = XParseGeometry(argv[i], &g_x,&g_y,&g_width,&g_height); | |||
if (rc == 0) | |||
{ | |||
(void) fprintf(stderr,"ERROR: Could not parse location: %s\n",argv[i]); | |||
(void) fprintf(stderr,"Example: -l +10+20\n"); | |||
return(1); | |||
} | |||
g_loc_specified = True; | |||
break; | |||
} | |||
case 'v': | |||
{ | |||
(void) fprintf(stderr,"grabc v%s\n",VERSION_S); | |||
return(1); | |||
break; | |||
} | |||
default: | |||
{ | |||
break; | |||
} | |||
} | |||
} | |||
if (g_loc_specified && (g_window_id == (Window) NULL)) | |||
{ | |||
(void) fprintf(stderr,"ERROR: Please specify window id with -w in hex to use this option\n"); | |||
(void) fprintf(stderr,"Use -W option to find the Window Id\n"); | |||
return(1); | |||
} | |||
display=XOpenDisplay((char *) NULL); | |||
XSetErrorHandler(MXError); | |||
if (display == (Display *) NULL) | |||
{ | |||
(void) fprintf (stderr,"ERROR: Failed to open DISPLAY!\n"); | |||
exit(1); | |||
} | |||
target_window = get_window_color(display,&color); | |||
if (target_window != (Window) NULL) | |||
{ | |||
status = XGetWindowAttributes(display, target_window, | |||
&window_attributes); | |||
if (status == False || window_attributes.map_state != IsViewable) | |||
{ | |||
(void) fprintf(stderr,"ERROR: Could not get Window Attributes\n"); | |||
return(1); | |||
} | |||
XQueryColor(display, window_attributes.colormap, &color); | |||
if (g_print_all_16_bits) | |||
{ | |||
(void) fprintf(stdout,"#%04x%04x%04x\n", | |||
(unsigned int)color.red, | |||
(unsigned int) color.green, | |||
(unsigned int) color.blue); | |||
(void) fflush(stdout); | |||
if (g_print_in_rgb) | |||
{ | |||
(void) fprintf(stderr,"%d,%d,%d\n", | |||
(unsigned int)color.red, | |||
(unsigned int) color.green, | |||
(unsigned int) color.blue); | |||
} | |||
} | |||
else | |||
{ | |||
r=(color.red >> 8); | |||
g=(color.green >> 8); | |||
b=(color.blue >> 8); | |||
log_debug("Color: #%02x%02x%02x",r,g,b); | |||
(void) fprintf (stdout,"#%02x%02x%02x\n",r,g,b); | |||
(void) fflush(stdout); | |||
/* | |||
** write the values in decimal on stderr | |||
*/ | |||
if (g_print_in_rgb) | |||
{ | |||
(void) fprintf(stderr,"%d,%d,%d\n",r,g,b); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
(void) fprintf (stderr,"ERROR: Failed to grab color!\n"); | |||
} | |||
return (0); | |||
} |
@ -0,0 +1,50 @@ | |||
=head1 NAME | |||
grabc - A tool to identify a pixel color of an X Window. | |||
=head1 SYNOPSIS | |||
grabc v1.0.2 | |||
A program to identify a pixel color of an X Window | |||
by muquit@muquit.com https://www.muquit.com/ | |||
Usage: grabc [options] | |||
Where the options are: | |||
-v - show version info | |||
-h - show this usage | |||
-hex - print pixel value as Hex on stdout | |||
-rgb - print pixel value as RGB on stderr | |||
-W - print the Window id at mouse click | |||
-w id - window id in hex, use -l +x+y | |||
-l +x+y - pixel co-ordinate. requires window id | |||
-d - show debug messages | |||
-a - Print all 16 bits of color. Default is high order 8 bits | |||
Example: | |||
* Print pixel color in hex on stdout: | |||
$ grabc | |||
* Show usage: | |||
$ grabc -h | |||
* Print Window Id (Note the upper case W): | |||
$ grabc -W | |||
* Print pixel color of Window iwith id 0x13234 at location 10,20 | |||
$ grabc -w 0x13234 -l +10+20 | |||
=head1 DESCRIPTION | |||
grabc is a simple but very useful program to determine the color string in | |||
hex (or in RGB components) by clicking on a pixel on the screen. While web | |||
browsing, lots of time you find a nice color and wonder what color is that. | |||
Well just use grabc! | |||
When this program is run, the mouse pointer is grabbed and changed to a | |||
cross hair and when the mouse is clicked, the color of the clicked pixel | |||
is written to stdout in hex prefixed with #. | |||
=head1 LICENSE | |||
MIT | |||
=head1 AUTHOR | |||
grabc is written by Muhammad Muquit E<lt>muquit@muquit.comE<gt>. | |||
Homepage: L<https://www.muquit.com/>. |
@ -0,0 +1,250 @@ | |||
#! /bin/sh | |||
# | |||
# install - install a program, script, or datafile | |||
# This comes from X11R5 (mit/util/scripts/install.sh). | |||
# | |||
# Copyright 1991 by the Massachusetts Institute of Technology | |||
# | |||
# Permission to use, copy, modify, distribute, and sell this software and its | |||
# documentation for any purpose is hereby granted without fee, provided that | |||
# the above copyright notice appear in all copies and that both that | |||
# copyright notice and this permission notice appear in supporting | |||
# documentation, and that the name of M.I.T. not be used in advertising or | |||
# publicity pertaining to distribution of the software without specific, | |||
# written prior permission. M.I.T. makes no representations about the | |||
# suitability of this software for any purpose. It is provided "as is" | |||
# without express or implied warranty. | |||
# | |||
# Calling this script install-sh is preferred over install.sh, to prevent | |||
# `make' implicit rules from creating a file called install from it | |||
# when there is no Makefile. | |||
# | |||
# This script is compatible with the BSD install script, but was written | |||
# from scratch. It can only install one file at a time, a restriction | |||
# shared with many OS's install programs. | |||
# set DOITPROG to echo to test this script | |||
# Don't use :- since 4.3BSD and earlier shells don't like it. | |||
doit="${DOITPROG-}" | |||
# put in absolute paths if you don't have them in your path; or use env. vars. | |||
mvprog="${MVPROG-mv}" | |||
cpprog="${CPPROG-cp}" | |||
chmodprog="${CHMODPROG-chmod}" | |||
chownprog="${CHOWNPROG-chown}" | |||
chgrpprog="${CHGRPPROG-chgrp}" | |||
stripprog="${STRIPPROG-strip}" | |||
rmprog="${RMPROG-rm}" | |||
mkdirprog="${MKDIRPROG-mkdir}" | |||
transformbasename="" | |||
transform_arg="" | |||
instcmd="$mvprog" | |||
chmodcmd="$chmodprog 0755" | |||
chowncmd="" | |||
chgrpcmd="" | |||
stripcmd="" | |||
rmcmd="$rmprog -f" | |||
mvcmd="$mvprog" | |||
src="" | |||
dst="" | |||
dir_arg="" | |||
while [ x"$1" != x ]; do | |||
case $1 in | |||
-c) instcmd="$cpprog" | |||
shift | |||
continue;; | |||
-d) dir_arg=true | |||
shift | |||
continue;; | |||
-m) chmodcmd="$chmodprog $2" | |||
shift | |||
shift | |||
continue;; | |||
-o) chowncmd="$chownprog $2" | |||
shift | |||
shift | |||
continue;; | |||
-g) chgrpcmd="$chgrpprog $2" | |||
shift | |||
shift | |||
continue;; | |||
-s) stripcmd="$stripprog" | |||
shift | |||
continue;; | |||
-t=*) transformarg=`echo $1 | sed 's/-t=//'` | |||
shift | |||
continue;; | |||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'` | |||
shift | |||
continue;; | |||
*) if [ x"$src" = x ] | |||
then | |||
src=$1 | |||
else | |||
# this colon is to work around a 386BSD /bin/sh bug | |||
: | |||
dst=$1 | |||
fi | |||
shift | |||
continue;; | |||
esac | |||
done | |||
if [ x"$src" = x ] | |||
then | |||
echo "install: no input file specified" | |||
exit 1 | |||
else | |||
true | |||
fi | |||
if [ x"$dir_arg" != x ]; then | |||
dst=$src | |||
src="" | |||
if [ -d $dst ]; then | |||
instcmd=: | |||
else | |||
instcmd=mkdir | |||
fi | |||
else | |||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command | |||
# might cause directories to be created, which would be especially bad | |||
# if $src (and thus $dsttmp) contains '*'. | |||
if [ -f $src -o -d $src ] | |||
then | |||
true | |||
else | |||
echo "install: $src does not exist" | |||
exit 1 | |||
fi | |||
if [ x"$dst" = x ] | |||
then | |||
echo "install: no destination specified" | |||
exit 1 | |||
else | |||
true | |||
fi | |||
# If destination is a directory, append the input filename; if your system | |||
# does not like double slashes in filenames, you may need to add some logic | |||
if [ -d $dst ] | |||
then | |||
dst="$dst"/`basename $src` | |||
else | |||
true | |||
fi | |||
fi | |||
## this sed command emulates the dirname command | |||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` | |||
# Make sure that the destination directory exists. | |||
# this part is taken from Noah Friedman's mkinstalldirs script | |||
# Skip lots of stat calls in the usual case. | |||
if [ ! -d "$dstdir" ]; then | |||
defaultIFS=' | |||
' | |||
IFS="${IFS-${defaultIFS}}" | |||
oIFS="${IFS}" | |||
# Some sh's can't handle IFS=/ for some reason. | |||
IFS='%' | |||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` | |||
IFS="${oIFS}" | |||
pathcomp='' | |||
while [ $# -ne 0 ] ; do | |||
pathcomp="${pathcomp}${1}" | |||
shift | |||
if [ ! -d "${pathcomp}" ] ; | |||
then | |||
$mkdirprog "${pathcomp}" | |||
else | |||
true | |||
fi | |||
pathcomp="${pathcomp}/" | |||
done | |||
fi | |||
if [ x"$dir_arg" != x ] | |||
then | |||
$doit $instcmd $dst && | |||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && | |||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && | |||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && | |||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi | |||
else | |||
# If we're going to rename the final executable, determine the name now. | |||
if [ x"$transformarg" = x ] | |||
then | |||
dstfile=`basename $dst` | |||
else | |||
dstfile=`basename $dst $transformbasename | | |||
sed $transformarg`$transformbasename | |||
fi | |||
# don't allow the sed command to completely eliminate the filename | |||
if [ x"$dstfile" = x ] | |||
then | |||
dstfile=`basename $dst` | |||
else | |||
true | |||
fi | |||
# Make a temp file name in the proper directory. | |||
dsttmp=$dstdir/#inst.$$# | |||
# Move or copy the file name to the temp name | |||
$doit $instcmd $src $dsttmp && | |||
trap "rm -f ${dsttmp}" 0 && | |||
# and set any options; do chmod last to preserve setuid bits | |||
# If any of these fail, we abort the whole thing. If we want to | |||
# ignore errors from any of these, just make sure not to ignore | |||
# errors from the above "$doit $instcmd $src $dsttmp" command. | |||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && | |||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && | |||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && | |||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && | |||
# Now rename the file to the real destination. | |||
$doit $rmcmd -f $dstdir/$dstfile && | |||
$doit $mvcmd $dsttmp $dstdir/$dstfile | |||
fi && | |||
exit 0 |
@ -0,0 +1,40 @@ | |||
#! /bin/sh | |||
# mkinstalldirs --- make directory hierarchy | |||
# Author: Noah Friedman <friedman@prep.ai.mit.edu> | |||
# Created: 1993-05-16 | |||
# Public domain | |||
# $Id: mkinstalldirs,v 1.1 2000/09/20 19:05:51 gson Exp $ | |||
errstatus=0 | |||
for file | |||
do | |||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` | |||
shift | |||
pathcomp= | |||
for d | |||
do | |||
pathcomp="$pathcomp$d" | |||
case "$pathcomp" in | |||
-* ) pathcomp=./$pathcomp ;; | |||
esac | |||
if test ! -d "$pathcomp"; then | |||
echo "mkdir $pathcomp" 1>&2 | |||
mkdir "$pathcomp" || lasterr=$? | |||
if test ! -d "$pathcomp"; then | |||
errstatus=$lasterr | |||
fi | |||
fi | |||
pathcomp="$pathcomp/" | |||
done | |||
done | |||
exit $errstatus | |||
# mkinstalldirs ends here |