Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fonts-degooglifier
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
libre
fonts-degooglifier
Commits
7a3ea0f5
Commit
7a3ea0f5
authored
Jan 26, 2019
by
Michał 'rysiek' Woźniak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using either wget or curl, whichever is available (fixes
#5
), plus some output cleanups
parent
4eaff68c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
4 deletions
+45
-4
degooglify.sh
degooglify.sh
+45
-4
No files found.
degooglify.sh
View file @
7a3ea0f5
...
...
@@ -6,6 +6,44 @@
# $1, ... - CSS files or URLs to de-googlify
#
#
# helper function -- downloading a file using curl or wget
# depending on which one is installed
#
# using wget if both installed, decided by a coin toss
#
# if the destination file exists, a notice is displayed
# and the file is *NOT* overwritten
#
# $1 -- URL
# $2 -- destination file
function
curlwget
{
# does the destination file exist?
# we do *not* want to overwrite files!
if
[
-f
"
$FONT_FILE
"
]
;
then
echo
"NOTICE: file exists, not downloading"
return
0
fi
# wget?
if
command
-v
wget
>
/dev/null
;
then
wget
--quiet
-O
"
$2
"
"
$1
"
# curl?
elif
command
-v
curl
>
/dev/null
;
then
curl
-s
-S
"
$1
"
>
"
$2
"
# nope?
else
echo
echo
"ERROR: neither curl nor wget found!"
exit
1
fi
}
#
# helper function -- getting a CSS file name
# from a fonts.googleapis.com URL
...
...
@@ -16,6 +54,7 @@ function get_local_filename_from_url() {
echo
'.css'
}
#
# in a local file replace '@import url()' lines
# that lead to fonts.googleapis.com
...
...
@@ -50,8 +89,8 @@ function degooglify_css_file_import() {
else
echo
echo
"NOTICE: destination CSS file already exists: '
$CSS_IMPORT_DEST
'"
echo
"NOTICE:
(this will not work great if the source or destination)
"
echo
"NOTICE:
(files were changed by external programs )
"
echo
"NOTICE:
* this will not work great if the source or destination *
"
echo
"NOTICE:
* files were changed by external programs *
"
echo
fi
[
!
-r
"
$CSS_IMPORT_DEST
"
]
&&
echo
"ERROR: destination CSS file is not readable: '
$CSS_IMPORT_DEST
'"
&&
exit
1
...
...
@@ -91,6 +130,7 @@ function degooglify_css_file_import() {
IFS
=
"
$OLDIFS
"
}
#
# the actual workhorse
#
...
...
@@ -169,7 +209,7 @@ function degooglify_css_file_src() {
# download the font
local
FONT_FILE
=
"
$FONT_DIR
/
$FONT_NAME
.
$FONT_EXT
"
echo
" +-- target:
$FONT_FILE
"
wget
-nc
--progress
=
dot
-O
"
$FONT_FILE
"
"
$FONT_URL
"
curlwget
"
$FONT_URL
"
"
$FONT_FILE
"
# replace the url in the source line in the file
sed
-i
-e
"s%
$FONT_URL
%
$FONT_FILE
%"
"
$CSS_DEST
"
...
...
@@ -226,7 +266,7 @@ function degooglify_css_url() {
echo
" +-- destination file :
$CSS_LOCAL
"
# download
wget
-nc
--progress
=
dot
-O
"
$CSS_LOCAL
"
"
$CSS_REMOTE
"
curlwget
"
$CSS_REMOTE
"
"
$CSS_LOCAL
"
# handle the downlaoded file
degooglify_css_file
"
$FONT_DIR
"
"
$CSS_LOCAL
"
||
exit
1
...
...
@@ -251,6 +291,7 @@ fi
[
!
-r
"
$TARGET_FONT_DIR
"
]
&&
echo
"ERROR: destination font directory not readable: '
$TARGET_FONT_DIR
'"
&&
exit
1
[
!
-w
"
$TARGET_FONT_DIR
"
]
&&
echo
"ERROR: destination font directory not writeable: '
$TARGET_FONT_DIR
'"
&&
exit
1
# do the magic
for
SOURCE_OF_CSS
in
"
$@
"
;
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment