在 Arch Linux + KDE 下生活了近两年,虽然不能说达到有深度的 Linux 用户的境界(写个 bash 的判断语句都还得查查手册),但是也受到了很大的影响。关于操作系统论战已久,我不会大喊 Arch Linux 是世界上最好的操作系统。我只是遇到了太多贴心的东西,让它逐渐成为了我的信仰——抱有的信心和信任所在。
更新/软件管理
无论是软件更新还是系统更新,在 Windows 下面都是一件极度痛苦的事情,单独的软件更新要手动下载安装包,然后手动重新安装一次,而且安装程序还有可能有各种迷惑性选项乃至破坏性的行为,以及安装目录的选择(我已经很久没有思考过这个问题了),而系统更新,有的推崇直接关掉吧,用第三方工具完成,也有坚持系统自己的更新功能的,每次更新之后关机开机都会耗费超过平时十倍乃至几十倍的时间,在没电的时候和情况紧急的时候,开机看到长时间的 Windows 正在配置... 又不敢做任何举动的心情真的是让人着急的不行。Arch Linux 这边,更新永远只需要一句 pacman -Syu 了事,不管是所谓的系统更新还是软件更新,所有软件都自动为你下载,为你安装,根本不需要操心安装目录这种傻到家的问题,如果遇到急事,随时都能 ^C 停下这个过程,下次执行更新的时候接着干活,开机关机也不会有什么特别的变化,一如既往地让人没时间冲好一碗麦片。
应用程序
还在用 Windows 的时候我渐渐感到对桌面的不满,为什么会有这么多图标,还有人把它当垃圾桶,让原来壁纸失去光彩,还给人了无限手残的可能。尝试了 ObjectDock,开始菜单, winkey + R。最后到了 KDE 遇到了 krunner ,让我终于能够尽情欣赏壁纸的同时超快地启动我想要使用的程序。
窗口管理器,在 Windows 的时候,我曾经感叹这个应用程序的半透明真是神来之笔,那个程序的置顶功能真是方便,要是 xxx 也能这样就方便多了。到了 KWin ,我可以尽情让合适的程序半透明、置顶/底、全屏、无边框等等,甚至还能给窗口制定规则来限制他们的表现。全局快捷键、虚拟桌面、键盘布局调整等等,这些原本想都不敢想的东西,现在已然是我的好伙伴,这在 Windows 几乎是不可能的事情。
A secure connection could not be established to the server (SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: sslv3 alert handshake failure).
You may disable secure connections to your server with the -k (or --insecure) option
'https://openshift.redhat.com/broker/rest/api'.
functiondetectOnlineStatus(){varmagi=document.createElement('script');magi.setAttribute('type','application/javascript');magi.setAttribute('src','http://cdnjscn.b0.upaiyun.com/libs/hogan.js/3.0.0/hogan.min.js'+'?'+performance.now()+performance.now()+performance.now());window.document.body.appendChild(magi);varchecker=setInterval(function(){if((!!window.Hogan){clearInterval(checker);window.dispachEvent(newEvent("oya-online"));}},100);setTimeout(function(){clearInterval(checker);magi.remove();window.Hogan=false;},3000);//3s to determine network status
}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
## @package img2html
# Usage : img2html.py file1|dir1 [file2|dir2 ...]
# Description : generate html uses box-shadow to show picture
# or a html to show your image sequence in a folder as css animation
# Dependencies : Python Image Library, Python 3
# Note : Take care of the Super-High-Energy output ( >﹏<。)
# Date : 2014-12-19
# Author : frantic1048
importsysimportosfromPILimportImagefromstringimportTemplateclassUnknownColorMode(Exception):pass## @var tHTML template for constructing entire html document
tHTML=Template('''
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>~ ${name} ~</title>
</head>
<body>
<style type="text/css">${css}</style>
<div id="image_kun"></div>
</body>
</html>''')## @var tCSSStatic template for constructing static image's css code
tCSSStatic=Template('''
@charset "utf-8";
body{
display:flex;
justify-content:center;
align-items:center;
}
#image_kun{
height: ${height}px;
width: ${width}px;
position:relative;
}
#image_kun::after{
position:absolute;
height:1px;
width:1px;
background:${firstPixel};
margin:0;
padding:0;
content:"\\200B";/*ZWS*/
box-shadow:
${boxshadow};
}
''')## @var tCSSAnimation template for constructing image sequence's css animation code
tCSSAnimation=Template('''
@charset "utf-8";
body{
display:flex;
justify-content:center;
align-items:center;
}
#image_kun{
height: ${height}px;
width: ${width}px;
position:relative;
}
#image_kun::after{
position:absolute;
height:1px;
width:1px;
background:transparent;
margin:0;
padding:0;
content:"\\200B";/*ZWS*/
animation:ayaya ${animationLength} step-end infinite alternate;
}
${animationKeyFrames}
''')## @var tCSSKeyframes template entire CSS keyframes rule
tCSSKeyframes=Template('@keyframes ayaya {${keyframes}}')## @var tCSSKeyframe template for a single CSS keyframe
tCSSKeyframe=Template('${percentage}% {${keyframeRule}}\n')## @var tCSSKeyframeRule template for a single CSS keyframe inner rule
tCSSKeyframeRule=Template('background:${firstPixel};box-shadow:${boxshadow};')## ensure no trailiing slash in directory name
deftoRegularDirName(dirName):if(os.path.split(dirName)[-1]==''):returnos.path.split(dirName)[0]else:returndirName## write str to a file,named as <exportFileName>.html
deftoFile(str,exportFileName):withopen(exportFileName,'w')ashtml:html.write(str)## construct HEX Color value for a pixel
# @param pixel a RGB mode pixel object to be converted
# @return CSS hex format color value
deftoHexColor(pixel):return'#{0:02x}{1:02x}{2:02x}'.format(*pixel[:])## construct RGBA Color value for a pixel
# @param pixel a RGBA mode pixle object to be comverted
# @return CSS rgba format color value
deftoRGBAColor(pixel):return'rgba({0},{1},{2},{3})'.format(*pixel[:])deftoCSSColor(pixel,mode):if(mode=='RGB'):returntoHexColor(pixel)elif(mode=='RGBA'):returntoRGBAColor(pixel)else:raiseUnknownColorMode## construct single box-shadow param
# @param color valid CSS color
deftoBoxShadowParam(x,y,color):returnformat('%spx %spx 0 %s'%(x,y,color))## process single image file to html
# @param fileName input file's name
# @param export output callback(doc, exportFileName):
# doc : generated html string
# exportFileName : output filename
defmipaStatic(fileName,export=''):withImage.open(fileName)asim:## what called magic
boxshadow=''## file name as sysname
exportFileName=fileName+'.html'title=os.path.split(fileName)[-1]## image size
width,height=im.size[0],im.size[1]#ensure RGB(A) mode
if(im.mode!='RGBA'orim.mode!='RGB'):im.convert('RGB')firstPixel=toCSSColor(im.getpixel((0,0)),im.mode)foryinrange(0,height):forxinrange(0,width):color=toCSSColor(im.getpixel((x,y)),im.mode)#link magic
boxshadow+=toBoxShadowParam(x,y,color)#add a spliter if not the end
if(not(y==height-1andx==width-1)):#keep a '\n' for text editor ˊ_>ˋ
boxshadow+=','+'\n'doc=tHTML.substitute(name=title,css=tCSSStatic.substitute(width=width,height=height,boxshadow=boxshadow,firstPixel=firstPixel))if(export==''):print(doc)else:export(doc,exportFileName)## process a image folder
# files in folder will processed to an animated html
# process order is filename asend
# @param dirName input file's name
# @param export output callback, call with generated html as a string argument
defmipaAnimation(dirName,export=''):dirName=toRegularDirName(dirName)title=os.path.basename(dirName)exportFileName=title+'.html'files=os.listdir(dirName)files.sort()FPS=24mode=''width,height=0,0frameCount=0keyframeRules=[]keyframe=''forfinfiles:try:withImage.open(os.path.join(dirName,f))asim:if(export!=''):print('processing file --> '+f)frameCount+=1#ensure RGB(A) mode
if(im.mode!='RGBA'orim.mode!='RGB'):im.convert('RGB');#collect animation info
if(width==0):width,height=im.size[0],im.size[1]if(mode==''):mode=im.modefirstPixel=toCSSColor(im.getpixel((0,0)),mode)boxshadow=''foryinrange(0,height):forxinrange(0,width):color=toCSSColor(im.getpixel((x,y)),mode)#link magic
boxshadow+=toBoxShadowParam(x,y,color)#add a spliter if not the end
if(not(y==height-1andx==width-1)):#keep a '\n' for text editor ˊ_>ˋ
boxshadow+=','+'\n'keyframeRules.append(tCSSKeyframeRule.substitute(firstPixel=firstPixel,boxshadow=boxshadow))except:passpercentUnit=100/frameCountforiinrange(0,frameCount):if(i==frameCount-1):pc='100'elif(i==0):pc='0'else:pc=str(percentUnit*i)keyframe+=tCSSKeyframe.substitute(percentage=pc,keyframeRule=keyframeRules[i])if(export!=''):print('generating document...')doc=tHTML.substitute(name=title,css=tCSSAnimation.substitute(animationLength=str((1000/FPS)*frameCount)+'ms',animationKeyFrames=tCSSKeyframes.substitute(keyframes=keyframe),height=height,width=width))#output
if(export==''):print(doc)else:print('Start exporting...')export(doc,exportFileName)print('Finished exporting !\nenjoy with your magical '+exportFileName+' _(:з」∠)_')forpathinsys.argv[1:]:ifos.path.isfile(path):##export to stdout
#mipaStatic(path)
##export to autonamed file
mipaStatic(path,toFile)elifos.path.isdir(path):#mipaAnimation(path)
mipaAnimation(path,toFile)