{"componentChunkName":"component---src-templates-post-js","path":"/blog/2021/01/21/linux-screen-resolution-script/","result":{"data":{"site":{"siteMetadata":{"siteUrl":"https://sung.codes"}},"mdx":{"id":"53955409-d2f8-511b-9b10-14cb1a8b05c1","body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Linux screen resolution script\",\n  \"date\": \"2021-01-21\",\n  \"published\": true,\n  \"tags\": \"linux, bash, script, screen\",\n  \"author\": \"Sung M. Kim\",\n  \"banner\": \"./images/featured-image.jpg\",\n  \"bannerCredit\": \"Image by [Pexels](https://pixabay.com/users/pexels-2286921/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=1868496) from [Pixabay](https://pixabay.com/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=1868496)\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h2\", null, \"TL;DR\"), mdx(\"p\", null, \"Change Ubuntu desktop resolution using \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"xandr\"), \".\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Create a script to change resolution\")), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"bash\"\n  }, mdx(\"pre\", _extends({\n    parentName: \"div\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token shebang important\"\n  }), \"#!/bin/bash\"), \"\\nxrandr --output eDP-1-1 --mode \", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token variable\"\n  }), mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"token variable\"\n  }), \"$(\"), mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"token function\"\n  }), \"basename\"), \" $0\", mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"token variable\"\n  }), \")\"))))), mdx(\"ol\", {\n    \"start\": 2\n  }, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Create \\\"hard\\\" symlinks with resolution as file names\")), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"bash\"\n  }, mdx(\"pre\", _extends({\n    parentName: \"div\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token comment\"\n  }), \"# Make `resolution.sh` executable\"), \"\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token comment\"\n  }), \"# Create hard symlinks on the desktop\"), \"\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token function\"\n  }), \"chmod\"), \" +x ./resolution.sh\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token function\"\n  }), \"ln\"), \" ./resolution.sh ~/Desktop/1920x1080\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token function\"\n  }), \"ln\"), \" ./resolution.sh ~/Desktop/1280x720\"))), mdx(\"h2\", null, \"Introduction\"), mdx(\"p\", null, \"During the pandemic, I started playing CS:GO (\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://blog.counter-strike.net/\"\n  }), \"Counter Strike: Global Offensive\"), \") a lot.\"), mdx(\"p\", null, \"When the desktop resolution doesn't match the game resolution, the game looks blurry.\", mdx(\"br\", {\n    parentName: \"p\"\n  }), \"\\n\", \"I play at 720p while the desktop is 1080p.\"), mdx(\"p\", null, \"Changing resolution via Nautilus has its annoyance because it displays so many resolution options.\"), mdx(\"p\", null, \"So I decided to write a bash script to change the resolution\", mdx(\"br\", {\n    parentName: \"p\"\n  }), \"\\n\", \"with a click of a button.\"), mdx(\"h2\", null, \"Scripts\"), mdx(\"p\", null, \"Initially I created two scripts\"), mdx(\"p\", null, \"File Name: \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"1280x720\")), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"bash\"\n  }, mdx(\"pre\", _extends({\n    parentName: \"div\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token shebang important\"\n  }), \"#!/bin/bash\"), \"\\nxrandr --output eDP-1-1 --mode 1280x720\"))), mdx(\"p\", null, \"File Name: \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"1920x1080\")), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"bash\"\n  }, mdx(\"pre\", _extends({\n    parentName: \"div\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token shebang important\"\n  }), \"#!/bin/bash\"), \"\\nxrandr --output eDP-1-1 --mode 1920x1080\"))), mdx(\"p\", null, \"It worked great.\", mdx(\"br\", {\n    parentName: \"p\"\n  }), \"\\n\", \"But in \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.codingblocks.net/slack/\"\n  }), \"Coding Blocks slack channel\"), \" (#Linux), \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://twitter.com/davefollett\"\n  }), \"Dave Follett\"), \" gave me a tip that I can \\\"abstract\\\" the resolution by reading the file name as the resolution.\"), mdx(\"p\", null, \"And why not?\"), mdx(\"h2\", null, \"Abstracting the script\"), mdx(\"p\", null, \"Dave taught me that \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"$0\"), \" \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://bash.cyberciti.biz/guide/$0\"\n  }), \"expands the name of the shell/script\"), \" and to extract the resolution (file name), I could use \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://linux.die.net/man/1/basename\"\n  }), \"basename\"), \".\"), mdx(\"p\", null, \"So basically for a file on Desktop, \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"~/Desktop/1280x720\"), \", \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"$0\"), \" returns \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"/home/dance2die/Desktop/1280x720\"), \" while \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"basename $0\"), \" will remove the directory, returning \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"1280x720\"), \".\"), mdx(\"p\", null, \"Then the result \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"1280x720\"), \" is passed to \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"xrandr\"), \".\"), mdx(\"h2\", null, \"Implementation\"), mdx(\"p\", null, \"This means, I need to create 3 files; One main script, two hard symlinks.\"), mdx(\"p\", null, \"Mainscript: \", mdx(\"code\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"language-text\"\n  }), \"~/scripts/resolution.sh\")), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"bash\"\n  }, mdx(\"pre\", _extends({\n    parentName: \"div\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token shebang important\"\n  }), \"#!/bin/bash\"), \"\\nxrandr --output eDP-1-1 --mode \", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token variable\"\n  }), mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"token variable\"\n  }), \"$(\"), mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"token function\"\n  }), \"basename\"), \" $0\", mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"token variable\"\n  }), \")\"))))), mdx(\"p\", null, \"And then create two hard symlinks.\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"bash\"\n  }, mdx(\"pre\", _extends({\n    parentName: \"div\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-bash\"\n  }), mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token comment\"\n  }), \"# Make `resolution.sh` executable\"), \"\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token function\"\n  }), \"chmod\"), \" +x ./resolution.sh\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token comment\"\n  }), \"# Create hard symlinks on the desktop\"), \"\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token function\"\n  }), \"ln\"), \" ./resolution.sh ~/Desktop/1920x1080\\n\", mdx(\"span\", _extends({\n    parentName: \"code\"\n  }, {\n    \"className\": \"token function\"\n  }), \"ln\"), \" ./resolution.sh ~/Desktop/1280x720\"))), mdx(\"hr\", null), mdx(\"p\", null, \"Image by \", mdx(\"a\", {\n    href: \"https://pixabay.com/users/pexels-2286921/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=1868496\"\n  }, \"Pexels\"), \" from \", mdx(\"a\", {\n    href: \"https://pixabay.com/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=1868496\"\n  }, \"Pixabay\")));\n}\n;\nMDXContent.isMDXComponent = true;","frontmatter":{"title":"Linux screen resolution script","banner":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='400'%20height='267'%20viewBox='0%200%20400%20267'%20preserveAspectRatio='none'%3e%3cpath%20d='M120%2060l-1%2046-1%2045h45c42%200%2054%200%2038%201-4%200-7%201-7%202l-1-1-12-1c-11%200-13%200-13%202l-4%201c-3%200-5%201-7%203l-7%202c-3%200-3%200%200%201%202%201%200%201-6%201-7%200-8%200-6%201l12%201h28v6c0%206%200%206%203%206%202%200%203-1%205-4l5-4c2%200%201%201-3%206l-3%206-3%202-4%203-2%203h4l4-1c-2-3%200-4%2012-4h12v-5l3-5%201-4v-4h28c27%200%2029-1%2031-2V60c-1-2-149-1-151%200m75%204h-71v81h142V63l-71%201M31%2089v6c0%203%201%204%203%204l2%201-2%201v1l-2%201-2%201c0%201%201%202%204%201h9c1-2%202%201%201%204l2%204%202%203c0%203%200%203%202%203v-1c-3-2%201-14%205-12%202%201%204%207%203%207l-1%203v3h14v-5c-1-6%201-7%203-2%201%204%201%205-1%205-1%201%200%201%201%201%203%200%203%200%203-4%200-10-12-16-22-11H45c-3%200-7-2-7-6s-6-11-7-8M9%20112c-3%202-4%202-5%200-3-1-5-1-3%201v1l-1%204c0%203%201%204%202%204l1%203v1c1-2%201-2%201%201v2c0-2%201-1%203%204%205%2011%206%2014%205%2014s-3-3-4-8l-4-9%205%2018a138%20138%200%20016%2023l1%207c-1%202%200%206%202%206%203%201%203%204%200%204-2%200-2%200%201%201s21%201%2024-1c2%200%202%200%200-3l-2-3-11%201H19v-3c-1-3%200-4%203-4l3-1c1%200-2-7-4-7v-1c1-1-2-11-10-32-4-8-5-12-4-14%200-2%200-2-2-2-4%200-4-3%201-4l13-2-5-1h-2c2-3%200-2-3%200m306%2016l-5%203c-2%202-1%2021%201%2022%203%203%2028%204%2028%202l1-2c1-1%202-18%201-20s-2-1-1%202%200%2015-2%2016l-1%201h-20c-4%200-6-2-6-10-1-8%200-10%204-12s19-1%2021%201l3%201c1-1-3-3-8-4h-16m-254%205l-1%202c0-5-2%200-2%205%200%204%200%205-2%206s-2%201%200%201c3%201%203%201%203%208a1048%201048%200%2000-3%2025c-2%200-2%200-1%201l6%201h3v-18l-1-18c-1-2%201-6%203-6l1-3v-5c1-2-2-1-3%201s-1%202-1-1v-2l-2%203m334%204l-4%201-2%201%203%201%201%202a617%20617%200%2000-3%203c1%202-2%204-5%204l-1%201-1%201-2%201h2l2%202-1%201c-2-2-1%201%202%203%203%203%203%204%205%202%201-2%202-2%203-1l4%202%202%201v-13c0-10%200-13-2-13-1-1-1-1-3%201M91%20157c0%202%201%203%202%203l1%201h-2c-2%200-3%200-3%202l-2%203v1c2-1%202%200%202%204l-1%204c-1-2-1-2-2%200v3h1l-2%202-3%201%202%201c2-1%202%204%200%205-1%201%202%201%207%201%208%200%2011-1%206-2l-2-1v-16c0-9%200-14-1-13%200%202-1%202-1%201%200-3-2-3-2%200m242%202v3c-2%202-1%204%202%204l-1%201-2%201h2l3-1%201-2%201%202c-1%202-8%203-23%203-13-1-16%200-16%202l-3%202c-3%200-5%202-3%202l2%208c0%202%204%202%2011%201%205%200%205%200%203-1-3-1-3-2-2-4v-4c0-2%202-2%2014-1l14%201c2%201-9%204-14%204-3%200-5%200-4%201h27c8%200%208-2%200-2-6%201-7%200-3-4l2-7c0-3%200-3-1-1%200%202-1%202-1%201v-7c-1-4-1-4-5-4s-4%200-4%202m61%2014l-5%201h-4c1%201%203%205%203%208v3l-1-3-1-2-1%203-4%207-1%201c1%201%200%201-2%202-5%201-4%201%206%201%2012-1%2017-2%2012-4h-3l2-3c3-2%203-3%203-7-1-5-4-11-4-7m-175%2011l-4%201-2%201c-1%201%201%201%207%201%205%200%206%200%204%201l-4%202%203%201%2012-3c13-2%2016-4%205-3a171%20171%200%2000-11%201c1-1%201-1-1-1l-4-1c0-2-1-2-5%200m-160%204c-1%203-1%203-3%202-2-2-3%200-3%203%200%202%200%203%202%203l6%201c2%200%203%200%202-1v-3l2%202c1%202%205%203%204%201%200-1%200-2%202-2l1-2-1-2h-2v-2c2-2%201-2-2%200v5c-1%200-4-3-4-5l2-1%201-1c-2-2-5-1-7%202'%20fill='%23FFC600'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.4953271028037383,"src":"/static/93a3361ff0b23e9708c55064360568e6/f422e/featured-image.jpg","srcSet":"/static/93a3361ff0b23e9708c55064360568e6/e75b5/featured-image.jpg 160w,\n/static/93a3361ff0b23e9708c55064360568e6/c01e2/featured-image.jpg 320w,\n/static/93a3361ff0b23e9708c55064360568e6/f422e/featured-image.jpg 640w,\n/static/93a3361ff0b23e9708c55064360568e6/a6352/featured-image.jpg 960w,\n/static/93a3361ff0b23e9708c55064360568e6/ec6c5/featured-image.jpg 1280w","srcWebp":"/static/93a3361ff0b23e9708c55064360568e6/991d2/featured-image.webp","srcSetWebp":"/static/93a3361ff0b23e9708c55064360568e6/578e8/featured-image.webp 160w,\n/static/93a3361ff0b23e9708c55064360568e6/8dbf3/featured-image.webp 320w,\n/static/93a3361ff0b23e9708c55064360568e6/991d2/featured-image.webp 640w,\n/static/93a3361ff0b23e9708c55064360568e6/1fb14/featured-image.webp 960w,\n/static/93a3361ff0b23e9708c55064360568e6/135cd/featured-image.webp 1280w","sizes":"(max-width: 640px) 100vw, 640px"}}}},"excerpt":"TL;DR Change Ubuntu desktop resolution using  xandr . Create a script to change resolution Create \"hard\" symlinks with resolution as file…","fields":{"year":"2021","slug":"/blog/2021/01/21/linux-screen-resolution-script/"}}},"pageContext":{"id":"53955409-d2f8-511b-9b10-14cb1a8b05c1"}},"staticQueryHashes":["398935099"]}